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-15T00:00:31Z
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
Attachments
- fix-polymorphic-procedure-outputs-v13.patch (text/x-diff) patch v13
I wrote: > Some experimentation showed that we need to return the correct > output column names in this tupdesc, so continuing to use > build_function_result_tupdesc_t seems like the easiest path for that. > However, stmt->outargs does hold nodes of the correct resolved data > types, so overwriting the atttypid's from that produces a nicely > small patch, as attached. Bleah ... that works fine back to v14, but in 12 and 13 it falls down because there's no outargs list in CallStmt. We can look at stmt->funcexpr->args instead, but (a) we have to rediscover which elements of that are output args, and (b) that list hasn't been run through expand_function_arguments, so we have to do that an extra time. (b) is pretty annoying, since the work is 100% duplicative of what's about to happen in ExecuteCallStmt. I thought briefly about moving the expand_function_arguments call from execution to transformCallStmt, the way it's done in v14 and later. I'm afraid to do that though, because it seems just barely possible that there's third-party code that knows that that list hasn't been expanded in these old branches. I fear we just have to eat the additional cycles. They're not that much compared to what will happen to run a user-defined procedure, but still, bleah. So I end with the attached modification for 12/13. regards, tom lane