mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Fix interference between covering indexes and partitioned tables
The bug is caused due to the original IndexStmt that DefineIndex receives being overwritten when processing the INCLUDE columns. Use separate list of index params to propagate to child tables. Add tests covering this case. Amit Langote and Alexander Korotkov. Re-commit5c6110c6a9
because it discovered a bug fixed inc266ed31a8
Discussion: https://www.postgresql.org/message-id/CAJGNTeO%3DBguEyG8wxMpU_Vgvg3nGGzy71zUQ0RpzEn_mb0bSWA%40mail.gmail.com
This commit is contained in:
@ -1313,3 +1313,27 @@ 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);
|
||||
-- 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);
|
||||
create table covidxpart1 partition of covidxpart for values in (1);
|
||||
create table covidxpart2 partition of covidxpart for values in (2);
|
||||
insert into covidxpart values (1, 1);
|
||||
insert into covidxpart values (1, 1);
|
||||
ERROR: duplicate key value violates unique constraint "covidxpart1_a_b_idx"
|
||||
DETAIL: Key (a)=(1) already exists.
|
||||
create table covidxpart3 (b int, c int, a int);
|
||||
alter table covidxpart3 drop c;
|
||||
alter table covidxpart attach partition covidxpart3 for values in (3);
|
||||
insert into covidxpart values (3, 1);
|
||||
insert into covidxpart values (3, 1);
|
||||
ERROR: duplicate key value violates unique constraint "covidxpart3_a_b_idx"
|
||||
DETAIL: Key (a)=(3) already exists.
|
||||
create table covidxpart4 (b int, a int);
|
||||
create unique index on covidxpart4 (a) include (b);
|
||||
create unique index on covidxpart4 (a);
|
||||
alter table covidxpart attach partition covidxpart4 for values in (4);
|
||||
insert into covidxpart values (4, 1);
|
||||
insert into covidxpart values (4, 1);
|
||||
ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
|
||||
DETAIL: Key (a)=(4) already exists.
|
||||
|
@ -701,3 +701,22 @@ 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);
|
||||
|
||||
-- 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);
|
||||
create table covidxpart1 partition of covidxpart for values in (1);
|
||||
create table covidxpart2 partition of covidxpart for values in (2);
|
||||
insert into covidxpart values (1, 1);
|
||||
insert into covidxpart values (1, 1);
|
||||
create table covidxpart3 (b int, c int, a int);
|
||||
alter table covidxpart3 drop c;
|
||||
alter table covidxpart attach partition covidxpart3 for values in (3);
|
||||
insert into covidxpart values (3, 1);
|
||||
insert into covidxpart values (3, 1);
|
||||
create table covidxpart4 (b int, a int);
|
||||
create unique index on covidxpart4 (a) include (b);
|
||||
create unique index on covidxpart4 (a);
|
||||
alter table covidxpart attach partition covidxpart4 for values in (4);
|
||||
insert into covidxpart values (4, 1);
|
||||
insert into covidxpart values (4, 1);
|
||||
|
Reference in New Issue
Block a user