pgsql: Check for missing dependencies on types

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check for missing dependencies on types
Date: 2026-11-09 14:21:55
Message-ID: E1xQQFv-000000003VI-0FDU@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check for missing dependencies on types

If an expression that's stored in a catalog references a rowtype in a
way that would break ALTERing its attribute, we record a dependency on
the type, and find_composite_type_dependencies() prevents ALTERing it.
However, we have failed to record the dependency in some cases, namely
if the expression itself doesn't depend on the type in an incompatible
way, but produces a *result* of the given datatype which is stored.
That problem arises from index expressions, PARTITION BY expressions,
and from expression statistics.

To fix, scan the pg_index, pg_partitioned_table and pg_statistic_ext
catalogs for those cases as a separate sub-step of
find_composite_type_dependencies(). In the future, after we have
added the missing dependency creation and backfilled any existing
missing dependencies, we can remove this code. That means, in a new
major version.

For all reporters and public discussions, see previous commits.

Co-authored-by: Nathan Bossart <nathan(at)postgresql(dot)org>
Reviewed-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Security: CVE-2026-6460
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/39e620324c02264d14fdc1260b9aa752a9253e43
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>

Modified Files
--------------
src/backend/commands/tablecmds.c | 138 ++++++++++++++++++++++++
src/test/regress/expected/alter_column_type.out | 72 +++----------
src/test/regress/sql/alter_column_type.sql | 35 +-----
3 files changed, 152 insertions(+), 93 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-11-09 14:21:56 pgsql: Add tests for row type changes causing issues
Previous Message Noah Misch 2026-11-09 14:21:54 pgsql: Check for Consts in domain DEFAULTs