Fix assertion failure with ALTER TABLE ATTACH PARTITION and indexes
authorMichael Paquier <michael@paquier.xyz>
Tue, 3 Mar 2020 04:55:41 +0000 (13:55 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 3 Mar 2020 04:55:41 +0000 (13:55 +0900)
commit0b48f1335dddb7141160e392cccac98edfb3fa85
treeceed64af27f821185ee2bd3ece37ec627546eb8d
parent54a4f52a9258198243c53fceaf8da70546ebd652
Fix assertion failure with ALTER TABLE ATTACH PARTITION and indexes

Using ALTER TABLE ATTACH PARTITION causes an assertion failure when
attempting to work on a partitioned index, because partitioned indexes
cannot have partition bounds.

The grammar of ALTER TABLE ATTACH PARTITION requires partition bounds,
but not ALTER INDEX, so mixing ALTER TABLE with partitioned indexes is
confusing.  Hence, on HEAD, prevent ALTER TABLE to attach a partition if
the relation involved is a partitioned index.  On back-branches, as
applications may rely on the existing behavior, just remove the
culprit assertion.

Reported-by: Alexander Lakhin
Author: Amit Langote, Michael Paquier
Discussion: https://postgr.es/m/16276-5cd1dcc8fb8be7b5@postgresql.org
Backpatch-through: 11
src/backend/parser/parse_utilcmd.c
src/test/regress/expected/indexing.out
src/test/regress/sql/indexing.sql