From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make pg_get_expr() more bulletproof.
Date: Sun, 09 Jan 2022 17:43:16 +0000
Message-ID: <E1n6cDs-0002uj-Nn@gemulon.postgresql.org> (raw)
Make pg_get_expr() more bulletproof.
Since this function is defined to accept pg_node_tree values, it could
get applied to any nodetree that can appear in a cataloged pg_node_tree
column. Some such cases can't be supported --- for example, its API
doesn't allow providing referents for more than one relation --- but
we should try to throw a user-facing error rather than an internal
error when encountering such a case.
In support of this, extend expression_tree_walker/mutator to be sure
they'll work on any such node tree (which basically means adding
support for relpartbound node types). That allows us to run pull_varnos
and check for the case of multiple relations before we start processing
the tree. The alternative of changing the low-level error thrown for an
out-of-range varno isn't appealing, because that could mask actual bugs
in other usages of ruleutils.
Per report from Justin Pryzby. This is basically cosmetic, so no
back-patch.
Discussion: https://postgr.es/m/20211219205422.GT17618@telsasoft.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6867f963e319934cbdafeb4bd5beaea5797c7be2
Modified Files
--------------
src/backend/nodes/nodeFuncs.c | 42 +++++++++++++++++++++++++++++++++++++
src/backend/optimizer/util/var.c | 11 ++++++++--
src/backend/utils/adt/ruleutils.c | 44 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 94 insertions(+), 3 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: Make pg_get_expr() more bulletproof.
In-Reply-To: <E1n6cDs-0002uj-Nn@gemulon.postgresql.org>
References: <E1n6cDs-0002uj-Nn@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