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

Commit7009f1a

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 parente46072d commit7009f1a

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
@@ -1871,7 +1871,6 @@ CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
18711871
if (info1->ii_NumIndexKeyAttrs!=info2->ii_NumIndexKeyAttrs)
18721872
return false;
18731873

1874-
18751874
/*
18761875
* and columns match through the attribute map (actual attribute numbers
18771876
* 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
@@ -928,7 +928,6 @@ DefineIndex(Oid relationId,
928928
gettext_noop("could not convert row type"));
929929
maplen=parentDesc->natts;
930930

931-
932931
foreach(cell,childidxs)
933932
{
934933
Oidcldidxid=lfirst_oid(cell);

‎src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15518,7 +15518,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
1551815518
partIdx->rd_opfamily,
1551915519
parentIdx->rd_opfamily,
1552015520
attmap,
15521-
RelationGetDescr(partTbl)->natts))
15521+
RelationGetDescr(parentTbl)->natts))
1552215522
ereport(ERROR,
1552315523
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1552415524
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
@@ -1360,6 +1360,11 @@ alter index idxpart2_a_idx attach partition idxpart22_a_idx;
13601360
create index on idxpart (a);
13611361
create table idxpart_another (a int, b int, primary key (a, b)) partition by range (a);
13621362
create table idxpart_another_1 partition of idxpart_another for values from (0) to (100);
1363+
create table idxpart3 (c int, b int, a int) partition by range (a);
1364+
alter table idxpart3 drop column b, drop column c;
1365+
create table idxpart31 partition of idxpart3 for values from (1000) to (1200);
1366+
create table idxpart32 partition of idxpart3 for values from (1200) to (1400);
1367+
alter table idxpart attach partition idxpart3 for values from (1000) to (2000);
13631368
-- Test that covering partitioned indexes work in various cases
13641369
create table covidxpart (a int, b int) partition by list (a);
13651370
create unique index on covidxpart (a) include (b);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,11 @@ alter index idxpart2_a_idx attach partition idxpart22_a_idx;
720720
createindexon idxpart (a);
721721
createtableidxpart_another (aint, bint,primary key (a, b)) partition by range (a);
722722
createtableidxpart_another_1 partition of idxpart_another forvaluesfrom (0) to (100);
723+
createtableidxpart3 (cint, bint, aint) partition by range (a);
724+
altertable idxpart3 drop column b, drop column c;
725+
createtableidxpart31 partition of idxpart3 forvaluesfrom (1000) to (1200);
726+
createtableidxpart32 partition of idxpart3 forvaluesfrom (1200) to (1400);
727+
altertable idxpart attach partition idxpart3 forvaluesfrom (1000) to (2000);
723728

724729
-- Test that covering partitioned indexes work in various cases
725730
createtablecovidxpart (aint, bint) partition by list (a);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp