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

Commit4137207

Browse files
committed
Fix crash when ALTER TABLE recreates indexes on partitions
The skip_build flag was not being passed correctly when recursing toindexes on partitions, leading to attempts to rebuild indexes when theywere not yet ready to be rebuilt.Reported-by: Rajkumar RaghuwanshiDiscussion:https://postgr.es/m/CAKcux6mxNCGsgATwf5CGMF8g4WSupCXicCVMeKUTuWbyxHOMsQ@mail.gmail.com
1 parentdad335b commit4137207

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ DefineIndex(Oid relationId,
10331033
indexRelationId,/* this is our child */
10341034
createdConstraintId,
10351035
is_alter_table,check_rights,check_not_in_use,
1036-
false,quiet);
1036+
skip_build,quiet);
10371037
}
10381038

10391039
pfree(attmap);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ SELECT col2 FROM idxpart_two fk LEFT OUTER JOIN idxpart pk ON (col1 = col2);
4040
(0 rows)
4141

4242
DROP table idxpart, idxpart_two;
43+
-- Verify bugfix with index rewrite on ALTER TABLE / SET DATA TYPE
44+
-- https://postgr.es/m/CAKcux6mxNCGsgATwf5CGMF8g4WSupCXicCVMeKUTuWbyxHOMsQ@mail.gmail.com
45+
CREATE TABLE idxpart (a INT, b TEXT, c INT) PARTITION BY RANGE(a);
46+
CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (MINVALUE) TO (MAXVALUE);
47+
CREATE INDEX partidx_abc_idx ON idxpart (a, b, c);
48+
INSERT INTO idxpart (a, b, c) SELECT i, i, i FROM generate_series(1, 50) i;
49+
ALTER TABLE idxpart ALTER COLUMN c TYPE numeric;
50+
DROP TABLE idxpart;
4351
-- If a table without index is attached as partition to a table with
4452
-- an index, the index is automatically created
4553
create table idxpart (a int, b int, c text) partition by range (a);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ CREATE TABLE idxpart_two (col2 INT);
2626
SELECT col2FROM idxpart_two fkLEFT OUTER JOIN idxpart pkON (col1= col2);
2727
DROPtable idxpart, idxpart_two;
2828

29+
-- Verify bugfix with index rewrite on ALTER TABLE / SET DATA TYPE
30+
-- https://postgr.es/m/CAKcux6mxNCGsgATwf5CGMF8g4WSupCXicCVMeKUTuWbyxHOMsQ@mail.gmail.com
31+
CREATETABLEidxpart (aINT, bTEXT, cINT) PARTITION BY RANGE(a);
32+
CREATETABLEidxpart1 PARTITION OF idxpart FORVALUESFROM (MINVALUE) TO (MAXVALUE);
33+
CREATEINDEXpartidx_abc_idxON idxpart (a, b, c);
34+
INSERT INTO idxpart (a, b, c)SELECT i, i, iFROM generate_series(1,50) i;
35+
ALTERTABLE idxpart ALTER COLUMN c TYPEnumeric;
36+
DROPTABLE idxpart;
37+
2938
-- If a table without index is attached as partition to a table with
3039
-- an index, the index is automatically created
3140
createtableidxpart (aint, bint, ctext) partition by range (a);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp