postgresql/src/pl/plpgsql/src
Tom Lane f535f350c1 Fix handling of polymorphic output arguments for procedures.
Most of the infrastructure for procedure arguments was already
okay with polymorphic output arguments, but it turns out that
CallStmtResultDesc() was a few bricks shy of a load here.  It thought
all it needed to do was call build_function_result_tupdesc_t, but
that function specifically disclaims responsibility for resolving
polymorphic arguments.  Failing to handle that doesn't seem to be
a problem for CALL in plpgsql, but CALL from plain SQL would get
errors like "cannot display a value of type anyelement", or even
crash outright.

In v14 and later we can simply examine the exposed types of the
CallStmt.outargs nodes to get the right type OIDs.  But it's a lot
more complicated to fix in v12/v13, because those versions don't
have CallStmt.outargs, nor do they do expand_function_arguments
until ExecuteCallStmt runs.  We have to duplicatively run
expand_function_arguments, and then re-determine which elements
of the args list are output arguments.

Per bug #18463 from Drew Kimball.  Back-patch to all supported
versions, since it's busted in all of them.

Discussion: https://postgr.es/m/18463-f8cd77e12564d8a2@postgresql.org
2024-05-14 20:19:20 -04:00
..
data Add tests for COPY in PL/pgSQL 2019-11-09 14:50:20 +09:00
expected Fix handling of polymorphic output arguments for procedures. 2024-05-14 20:19:20 -04:00
po Translation updates 2024-05-06 12:06:31 +02:00
sql Fix handling of polymorphic output arguments for procedures. 2024-05-14 20:19:20 -04:00
.gitignore Replace the data structure used for keyword lookup. 2019-01-06 17:02:57 -05:00
Makefile Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command. 2024-01-18 16:11:16 -05:00
generate-plerrcodes.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command. 2024-01-18 16:11:16 -05:00
nls.mk Break up long GETTEXT_FILES lists 2023-03-08 15:05:43 +01:00
pl_comp.c Improve plpgsql's error messages for incorrect %TYPE and %ROWTYPE. 2024-02-28 16:05:28 -05:00
pl_exec.c Add RETURNING support to MERGE. 2024-03-17 13:58:59 +00:00
pl_funcs.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
pl_gram.y Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00
pl_handler.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
pl_reserved_kwlist.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pl_scanner.c Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00
pl_unreserved_kwlist.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
plpgsql--1.0.sql Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
plpgsql.control Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
plpgsql.h Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00