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 <[email protected]> Reviewed-by: Amit Langote <[email protected]> Reviewed-by: Andres Freund <[email protected]> Security: CVE-2026-6460 Backpatch-through: 14 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/39e620324c02264d14fdc1260b9aa752a9253e43 Author: Heikki Linnakangas <[email protected]> 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(-)
