Re: Why can't I have a "language sql" anonymous block?
От | Bryn Llewellyn |
---|---|
Тема | Re: Why can't I have a "language sql" anonymous block? |
Дата | |
Msg-id | 25643215-899C-4FF8-A35F-85A61A8AD0A5@yugabyte.com обсуждение исходный текст |
Ответ на | Re: Why can't I have a "language sql" anonymous block? ("David G. Johnston" <david.g.johnston@gmail.com>) |
Список | pgsql-general |
david.g.johnston@gmail.com wrote:On Monday, December 13, 2021, Bryn Llewellyn <bryn@yugabyte.com> wrote:
There must be a reason to prefer a “language sql” procedure over a “language plpgsql” procedure—otherwise the former wouldn’t be supported.I would say that is true for functions. I wouldn’t assume that for procedures—it’s probable that because sql already worked for functions we got that feature for free when implementing procedures.
Interesting. That’s exactly the kind of historical insight I was after. Thanks.
It’s very tempting to think that “language sql” is meaningful only as a performance feature and in that connection only for a stored function because only a function can be inlined in a surrounding regular SQL statement. (You can invoke a procedure only as a singleton in the dedicated “call” statement.) In other words there can be no inlining benefit for a stored procedure.
It’s certainly no problem for the coder to bracket what would have been the body of a “language sql” DO block with a single “begin… end;”.
I should save any of you the effort of telling me this: a DO block is an anonymous, ephemeral procedure. It’s certainly not an anonymous function.
В списке pgsql-general по дате отправления: