From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Close old gap in dependency checks for functions returning compo |
Date: | 2022-07-22 16:46:54 |
Message-ID: | E1oEvnh-000kwL-8p@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2022-07-22 17:24:43 | pgsql: Rework grammar for REINDEX |
Previous Message | Tom Lane | 2022-07-22 14:53:36 | pgsql: Fix minor memory leaks in psql's tab completion. |