From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reconsider the handling of procedure OUT parameters.
Date: Thu, 10 Jun 2021 21:11:46 +0000
Message-ID: <E1lrRxq-0007Eb-FX@gemulon.postgresql.org> (raw)
Reconsider the handling of procedure OUT parameters.
Commit 2453ea142 redefined pg_proc.proargtypes to include the types of
OUT parameters, for procedures only. While that had some advantages
for implementing the SQL-spec behavior of DROP PROCEDURE, it was pretty
disastrous from a number of other perspectives. Notably, since the
primary key of pg_proc is name + proargtypes, this made it possible to
have multiple procedures with identical names + input arguments and
differing output argument types. That would make it impossible to call
any one of the procedures by writing just NULL (or "?", or any other
data-type-free notation) for the output argument(s). The change also
seems likely to cause grave confusion for client applications that
examine pg_proc and expect the traditional definition of proargtypes.
Hence, revert the definition of proargtypes to what it was, and
undo a number of complications that had been added to support that.
To support the SQL-spec behavior of DROP PROCEDURE, when there are
no argmode markers in the command's parameter list, we perform the
lookup both ways (that is, matching against both proargtypes and
proallargtypes), succeeding if we get just one unique match.
In principle this could result in ambiguous-function failures
that would not happen when using only one of the two rules.
However, overloading of procedure names is thought to be a pretty
rare usage, so this shouldn't cause many problems in practice.
Postgres-specific code such as pg_dump can defend against any
possibility of such failures by being careful to specify argmodes
for all procedure arguments.
This also fixes a few other bugs in the area of CALL statements
with named parameters, and improves the documentation a little.
catversion bump forced because the representation of procedures
with OUT arguments changes.
Discussion: https://postgr.es/m/3742981.1621533210@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/e56bce5d43789cce95d099554ae9593ada92b3b7
Modified Files
--------------
doc/src/sgml/catalogs.sgml | 5 +-
doc/src/sgml/plpgsql.sgml | 17 +-
doc/src/sgml/ref/alter_extension.sgml | 11 +-
doc/src/sgml/ref/alter_procedure.sgml | 4 +-
doc/src/sgml/ref/call.sgml | 26 +++-
doc/src/sgml/ref/comment.sgml | 11 +-
doc/src/sgml/ref/drop_procedure.sgml | 92 +++++++++--
doc/src/sgml/ref/drop_routine.sgml | 42 ++++-
doc/src/sgml/ref/security_label.sgml | 11 +-
doc/src/sgml/xfunc.sgml | 22 +--
src/backend/catalog/namespace.c | 68 ++++++--
src/backend/catalog/pg_aggregate.c | 2 +-
src/backend/catalog/pg_proc.c | 6 +-
src/backend/commands/functioncmds.c | 137 ++++++++--------
src/backend/executor/functions.c | 36 +----
src/backend/nodes/copyfuncs.c | 2 +
src/backend/nodes/equalfuncs.c | 2 +
src/backend/optimizer/util/clauses.c | 89 ++++++++---
src/backend/parser/analyze.c | 92 ++++++++++-
src/backend/parser/gram.y | 109 +++++--------
src/backend/parser/parse_func.c | 207 +++++++++++++++++++------
src/backend/parser/parse_oper.c | 4 +-
src/backend/utils/adt/regproc.c | 11 +-
src/backend/utils/adt/ruleutils.c | 12 +-
src/backend/utils/fmgr/funcapi.c | 4 +-
src/bin/pg_dump/t/002_pg_dump.pl | 2 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/namespace.h | 2 +
src/include/catalog/pg_proc.h | 2 +-
src/include/funcapi.h | 3 +-
src/include/nodes/parsenodes.h | 37 +++--
src/include/optimizer/optimizer.h | 3 +-
src/include/parser/parse_func.h | 1 +
src/pl/plpgsql/src/expected/plpgsql_call.out | 76 +++++++++
src/pl/plpgsql/src/pl_comp.c | 1 -
src/pl/plpgsql/src/pl_exec.c | 36 ++---
src/pl/plpgsql/src/sql/plpgsql_call.sql | 64 ++++++++
src/pl/plpython/expected/plpython_call.out | 4 +-
src/pl/plpython/plpy_procedure.c | 4 +-
src/pl/plpython/sql/plpython_call.sql | 2 +-
src/pl/tcl/expected/pltcl_call.out | 4 +-
src/pl/tcl/sql/pltcl_call.sql | 2 +-
src/test/regress/expected/create_procedure.out | 149 +++++++++++++++---
src/test/regress/sql/create_procedure.sql | 45 +++++-
44 files changed, 1069 insertions(+), 392 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Reconsider the handling of procedure OUT parameters.
In-Reply-To: <E1lrRxq-0007Eb-FX@gemulon.postgresql.org>
References: <E1lrRxq-0007Eb-FX@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox