pgsql: Reject attempts to alter composite types used in indexes.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Reject attempts to alter composite types used in indexes.
Date: 2023-03-27 19:04:29
Message-ID: E1pgs8q-0001cS-Kk@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reject attempts to alter composite types used in indexes.

find_composite_type_dependencies() ignored indexes, which is a poor
decision because an expression index could have a stored column of
a composite (or other container) type even when the underlying table
does not. Teach it to detect such cases and error out. We have to
work a bit harder than for other relations because the pg_depend entry
won't identify the specific index column of concern, but it's not much
new code.

This does not address bug #17872's original complaint that dropping
a column in such a type might lead to violations of the uniqueness
property that a unique index is supposed to ensure. That seems of
much less concern to me because it won't lead to crashes.

Per bug #17872 from Alexander Lakhin. Back-patch to all supported
branches.

Discussion: https://postgr.es/m/17872-d0fbb799dc3fd85d@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cd07163c0e36596a53154c7fb7ffb479d225fe78

Modified Files
--------------
src/backend/commands/tablecmds.c | 57 ++++++++++++++++++++++++++-----
src/test/regress/expected/alter_table.out | 10 +++++-
src/test/regress/sql/alter_table.sql | 11 +++++-
3 files changed, 68 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2023-03-27 19:46:09 pgsql: doc: Fix XML_CATALOG_FILES env var for Apple Silicon machines
Previous Message Peter Geoghegan 2023-03-27 18:34:16 Re: pgsql: amcheck: Fix verify_heapam for tuples where xmin or xmax is 0.