]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Reject attempts to alter composite types used in indexes.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 27 Mar 2023 19:04:02 +0000 (15:04 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 27 Mar 2023 19:04:02 +0000 (15:04 -0400)
commitcd07163c0e36596a53154c7fb7ffb479d225fe78
tree2b6e6cce8162c8d222ba8c9ec0f86fa22669dfdf
parentad5fe7420594811d3ca4054a8397c5cc8c6575e2
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
src/backend/commands/tablecmds.c
src/test/regress/expected/alter_table.out
src/test/regress/sql/alter_table.sql