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

Started by Tom Laneabout 3 years ago1 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

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: /messages/by-id/17872-d0fbb799dc3fd85d@postgresql.org

Branch
------
master

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

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