From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
Cc: | drewk(at)cockroachlabs(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18463: Possible bug in stored procedures with polymorphic OUT parameters |
Date: | 2024-05-15 17:28:57 |
Message-ID: | 1800943.1715794137@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Dmitry Dolgov <9erthalion6(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Rémi Cura | 2024-05-15 18:12:51 | Re: BUG #18464: Replacing a SQL function silently drops the generated columns that use this function |
Previous Message | Tom Lane | 2024-05-15 15:56:03 | Re: BUG #18464: Replacing a SQL function silently drops the generated columns that use this function |