Re: BUG #18463: Possible bug in stored procedures with polymorphic OUT parameters
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: drewk@cockroachlabs.com, pgsql-bugs@lists.postgresql.org
Date: 2024-05-15T17:28:57Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix failure with SQL-procedure polymorphic output arguments in v12.
- d88dcdf0fa5b 14.13 landed
- bb331af4aeb7 16.4 landed
- 9de0ff91a501 13.16 landed
- 751598263690 17.0 landed
- 5fe43d41db59 15.8 landed
- 4208f44c9469 12.20 landed
-
Fix handling of polymorphic output arguments for procedures.
- f535f350c1f9 17.0 landed
- e85f641b2b52 13.16 landed
- c40e78d239a8 15.8 landed
- 8e0e99972ad9 16.4 landed
- 70ffb27b2349 12.20 landed
- 525bd1620e9b 14.13 landed
Dmitry Dolgov <9erthalion6@gmail.com> writes: > I'm now curious why it is different for functions, when creating one > with an INOUT ANYELEMENT argument and record return type will error out. > Disabling the corresponding ereport check in CreateFunction seems to > produce a function that works in the similar way as the procedure in > this thread. Are those type of functions incorrect in some way? With procedures, there's no explicit RETURNS clause; we just automatically fill RECORD into prorettype because (a) we gotta put something and (b) that's the right thing anyway if there's multiple OUT parameters. Arguably it's not wrong for a single output parameter, either, since CALL will return a tuple in that case too. I think it might've been better to put VOID for the case of zero output parameters, since CALL doesn't return a zero-column tuple in that case. But that ship's sailed, and it's not worth quibbling about. We do this differently for functions: if there's exactly one output parameter, that is the function result, so prorettype has to match. If we were to allow RETURNS RECORD with a single output parameter, I think that'd have to mean that we return a one-column tuple containing that parameter value. That's not implemented, and I have doubts that it'd be useful. It'd certainly be a bit inefficient. regards, tom lane