diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 44625a507b..7857df6bcd 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -1871,7 +1871,6 @@ CompareIndexInfo(IndexInfo *info1, IndexInfo *info2, if (info1->ii_NumIndexKeyAttrs != info2->ii_NumIndexKeyAttrs) return false; - /* * and columns match through the attribute map (actual attribute numbers * might differ!) Note that this implies that index columns that are diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index fec5bc5dd6..f8ee4b0a84 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -928,7 +928,6 @@ DefineIndex(Oid relationId, gettext_noop("could not convert row type")); maplen = parentDesc->natts; - foreach(cell, childidxs) { Oid cldidxid = lfirst_oid(cell); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0f72f51d37..23c2e92375 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -15518,7 +15518,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name) partIdx->rd_opfamily, parentIdx->rd_opfamily, attmap, - RelationGetDescr(partTbl)->natts)) + RelationGetDescr(parentTbl)->natts)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("cannot attach index \"%s\" as a partition of index \"%s\"", diff --git a/src/test/regress/expected/indexing.out b/src/test/regress/expected/indexing.out index 769b7b83d4..6a21c0c2e1 100644 --- a/src/test/regress/expected/indexing.out +++ b/src/test/regress/expected/indexing.out @@ -1360,6 +1360,11 @@ alter index idxpart2_a_idx attach partition idxpart22_a_idx; create index on idxpart (a); create table idxpart_another (a int, b int, primary key (a, b)) partition by range (a); create table idxpart_another_1 partition of idxpart_another for values from (0) to (100); +create table idxpart3 (c int, b int, a int) partition by range (a); +alter table idxpart3 drop column b, drop column c; +create table idxpart31 partition of idxpart3 for values from (1000) to (1200); +create table idxpart32 partition of idxpart3 for values from (1200) to (1400); +alter table idxpart attach partition idxpart3 for values from (1000) to (2000); -- Test that covering partitioned indexes work in various cases create table covidxpart (a int, b int) partition by list (a); create unique index on covidxpart (a) include (b); diff --git a/src/test/regress/sql/indexing.sql b/src/test/regress/sql/indexing.sql index 9adc5be10c..d14d9f8528 100644 --- a/src/test/regress/sql/indexing.sql +++ b/src/test/regress/sql/indexing.sql @@ -720,6 +720,11 @@ alter index idxpart2_a_idx attach partition idxpart22_a_idx; create index on idxpart (a); create table idxpart_another (a int, b int, primary key (a, b)) partition by range (a); create table idxpart_another_1 partition of idxpart_another for values from (0) to (100); +create table idxpart3 (c int, b int, a int) partition by range (a); +alter table idxpart3 drop column b, drop column c; +create table idxpart31 partition of idxpart3 for values from (1000) to (1200); +create table idxpart32 partition of idxpart3 for values from (1200) to (1400); +alter table idxpart attach partition idxpart3 for values from (1000) to (2000); -- Test that covering partitioned indexes work in various cases create table covidxpart (a int, b int) partition by list (a);