Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit126d631

Browse files
committed
Fix partitioned index creation bug with dropped columns
ALTER INDEX .. ATTACH PARTITION fails if the partitioned table where theindex is defined contains more dropped columns than its partition, withthis message: ERROR: incorrect attribute mapThe cause was that one caller of CompareIndexInfo was passing the numberof attributes of the partition rather than the parent, which confusedthe length check. Repair.This can cause pg_upgrade to fail when used on such a database. Leavesome more objects around after regression tests, so that the case isdetected by pg_upgrade test suite.Remove some spurious empty lines noticed while looking for other casesof the same problem.Discussion:https://postgr.es/m/20190326213924.GA2322@alvherre.pgsql
1 parent53bcf5e commit126d631

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

‎src/backend/catalog/index.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,6 @@ CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
18501850
if (info1->ii_NumIndexKeyAttrs!=info2->ii_NumIndexKeyAttrs)
18511851
return false;
18521852

1853-
18541853
/*
18551854
* and columns match through the attribute map (actual attribute numbers
18561855
* might differ!) Note that this implies that index columns that are

‎src/backend/commands/indexcmds.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@ DefineIndex(Oid relationId,
925925
gettext_noop("could not convert row type"));
926926
maplen=parentDesc->natts;
927927

928-
929928
foreach(cell,childidxs)
930929
{
931930
Oidcldidxid=lfirst_oid(cell);

‎src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15591,7 +15591,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
1559115591
partIdx->rd_opfamily,
1559215592
parentIdx->rd_opfamily,
1559315593
attmap,
15594-
RelationGetDescr(partTbl)->natts))
15594+
RelationGetDescr(parentTbl)->natts))
1559515595
ereport(ERROR,
1559615596
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1559715597
errmsg("cannot attach index \"%s\" as a partition of index \"%s\"",

‎src/test/regress/expected/indexing.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,11 @@ alter index idxpart2_a_idx attach partition idxpart22_a_idx;
14111411
create index on idxpart (a);
14121412
create table idxpart_another (a int, b int, primary key (a, b)) partition by range (a);
14131413
create table idxpart_another_1 partition of idxpart_another for values from (0) to (100);
1414+
create table idxpart3 (c int, b int, a int) partition by range (a);
1415+
alter table idxpart3 drop column b, drop column c;
1416+
create table idxpart31 partition of idxpart3 for values from (1000) to (1200);
1417+
create table idxpart32 partition of idxpart3 for values from (1200) to (1400);
1418+
alter table idxpart attach partition idxpart3 for values from (1000) to (2000);
14141419
-- More objects intentionally left behind, to verify some pg_dump/pg_upgrade
14151420
-- behavior; see https://postgr.es/m/20190321204928.GA17535@alvherre.pgsql
14161421
create schema regress_indexing;

‎src/test/regress/sql/indexing.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,11 @@ alter index idxpart2_a_idx attach partition idxpart22_a_idx;
747747
createindexon idxpart (a);
748748
createtableidxpart_another (aint, bint,primary key (a, b)) partition by range (a);
749749
createtableidxpart_another_1 partition of idxpart_another forvaluesfrom (0) to (100);
750+
createtableidxpart3 (cint, bint, aint) partition by range (a);
751+
altertable idxpart3 drop column b, drop column c;
752+
createtableidxpart31 partition of idxpart3 forvaluesfrom (1000) to (1200);
753+
createtableidxpart32 partition of idxpart3 forvaluesfrom (1200) to (1400);
754+
altertable idxpart attach partition idxpart3 forvaluesfrom (1000) to (2000);
750755

751756
-- More objects intentionally left behind, to verify some pg_dump/pg_upgrade
752757
-- behavior; see https://postgr.es/m/20190321204928.GA17535@alvherre.pgsql

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp