summaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-10-24 14:59:50 +0300
committervvvv <[email protected]>2025-10-24 15:29:24 +0300
commit5b0d18921f2a509d8363c40a5ca208dfed026287 (patch)
treed1369c696d3a9e9a65b68d9208e198269a48cfbc /yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c
parente7fbdb6e81ae4a296e710b133de7a2a04b31bbc4 (diff)
YQL-20567 upgrade PG up to 16.10 & fix instructions
init commit_hash:81aba13295273281d19d2d332a48ff1c44977447
Diffstat (limited to 'yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c')
-rw-r--r--yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c b/yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c
index 49c7864c7cf..f63b5ef420b 100644
--- a/yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c
+++ b/yql/essentials/parser/pg_wrapper/postgresql/src/backend/commands/functioncmds.c
@@ -56,6 +56,7 @@
#include "executor/functions.h"
#include "funcapi.h"
#include "miscadmin.h"
+#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
#include "parser/analyze.h"
#include "parser/parse_coerce.h"
@@ -2366,5 +2367,32 @@ CallStmtResultDesc(CallStmt *stmt)
ReleaseSysCache(tuple);
+ /*
+ * The result of build_function_result_tupdesc_t has the right column
+ * names, but it just has the declared output argument types, which is the
+ * wrong thing in polymorphic cases. Get the correct types by examining
+ * stmt->outargs. We intentionally keep the atttypmod as -1 and the
+ * attcollation as the type's default, since that's always the appropriate
+ * thing for function outputs; there's no point in considering any
+ * additional info available from outargs. Note that tupdesc is null if
+ * there are no outargs.
+ */
+ if (tupdesc)
+ {
+ Assert(tupdesc->natts == list_length(stmt->outargs));
+ for (int i = 0; i < tupdesc->natts; i++)
+ {
+ Form_pg_attribute att = TupleDescAttr(tupdesc, i);
+ Node *outarg = (Node *) list_nth(stmt->outargs, i);
+
+ TupleDescInitEntry(tupdesc,
+ i + 1,
+ NameStr(att->attname),
+ exprType(outarg),
+ -1,
+ 0);
+ }
+ }
+
return tupdesc;
}