> david.g.johns...@gmail.com wrote:
> 
>> On Monday, December 13, 2021, Bryn Llewellyn <b...@yugabyte.com 
>> <mailto:b...@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.

Reply via email to