From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Close old gap in dependency checks for functions returning compo
Date: Fri, 22 Jul 2022 16:46:54 +0000
Message-ID: <E1oEvnh-000kwL-8p@gemulon.postgresql.org> (raw)
Close old gap in dependency checks for functions returning composite.
The dependency logic failed to register a column-level dependency
when a view or rule contains a reference to a specific column of
the result of a function-returning-composite. That meant you could
drop the column from the composite type, causing trouble for future
executions of the view. We've known about this for years, but never
summoned the energy to actually fix it, instead installing various
low-level defenses to prevent crashing on references to dropped columns.
We had to do that to plug the hole in stable branches, where there might
be pre-existing broken references; but let's fix the root cause today.
To do that, add some logic (borrowed from get_rte_attribute_is_dropped)
to find_expr_references_walker, to check whether a Var referencing an
RTE_FUNCTION RTE is referencing a column of a composite type, and if
so add the proper dependency.
However ... it seems mighty unwise to remove said low-level defenses,
since there could be other bugs now or in the future that allow
reaching them. By the same token, letting those defenses go untested
seems unwise. Hence, rather than just dropping the associated test
cases, hack them to continue working by the expedient of manually
dropping the pg_depend entries that this fix installs.
Back-patch into v15. I don't want to risk changing this behavior
in stable branches, but it seems not too late for v15. (Since
we have already forced initdb for beta3, we can be sure that all
production v15 installations will have these added dependencies.)
Discussion: https://postgr.es/m/182492.1658431155@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/0b292bed9211e5c85b7b102690f526c3a6600c2e
Modified Files
--------------
src/backend/catalog/dependency.c | 68 +++++++++++++++++++++++++
src/backend/utils/adt/ruleutils.c | 6 +--
src/test/regress/expected/create_view.out | 82 ++++++++++++++++++++++++++++++-
src/test/regress/expected/rangefuncs.out | 40 +++++++++++++++
src/test/regress/sql/create_view.sql | 45 ++++++++++++++++-
src/test/regress/sql/rangefuncs.sql | 33 +++++++++++++
6 files changed, 267 insertions(+), 7 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: Close old gap in dependency checks for functions returning compo
In-Reply-To: <E1oEvnh-000kwL-8p@gemulon.postgresql.org>
References: <E1oEvnh-000kwL-8p@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