diff options
author | Michael Paquier <michael@paquier.xyz> | 2020-03-03 13:55:41 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2020-03-03 13:55:41 +0900 |
commit | 0b48f1335dddb7141160e392cccac98edfb3fa85 (patch) | |
tree | ceed64af27f821185ee2bd3ece37ec627546eb8d /src/backend/parser/parse_utilcmd.c | |
parent | 54a4f52a9258198243c53fceaf8da70546ebd652 (diff) | |
download | postgresql-0b48f1335dddb7141160e392cccac98edfb3fa85.tar.gz postgresql-0b48f1335dddb7141160e392cccac98edfb3fa85.zip |
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
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r-- | src/backend/parser/parse_utilcmd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index ee2d2b54a1d..973eab6ae2c 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -3698,8 +3698,16 @@ transformPartitionCmd(CreateStmtContext *cxt, PartitionCmd *cmd) cmd->bound); break; case RELKIND_PARTITIONED_INDEX: - /* nothing to check */ - Assert(cmd->bound == NULL); + + /* + * A partitioned index cannot have a partition bound set. ALTER + * INDEX prevents that with its grammar, but not ALTER TABLE. + */ + if (cmd->bound != NULL) + ereport(ERROR, + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("\"%s\" is not a partitioned table", + RelationGetRelationName(parentRel)))); break; case RELKIND_RELATION: /* the table must be partitioned */ |