mirror of
https://github.com/postgres/postgres.git
synced 2025-12-10 14:22:35 +03:00
Fix partitioned index attachment
When an existing index in a partition is attached to a new index on its parent, we forgot to set the "relispartition" flag correctly, which meant that it was not possible to find the index in various operations, such as adding a foreign key constraint that references that partitioned table. One of four places that was assigning the parent index was forgetting to do that, so fix by shifting responsibility of updating the flag to the routine that changes the parent. Author: Amit Langote, Álvaro Herrera Reported-by: Hubert "depesz" Lubaczewski Discussion: https://postgr.es/m/CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com
This commit is contained in:
@@ -2367,3 +2367,15 @@ SELECT tableoid::regclass, * FROM fk;
|
||||
(2 rows)
|
||||
|
||||
DROP TABLE fk;
|
||||
-- test for reported bug: relispartition not set
|
||||
-- https://postgr.es/m/CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com
|
||||
CREATE SCHEMA fkpart7
|
||||
CREATE TABLE pkpart (a int) PARTITION BY LIST (a)
|
||||
CREATE TABLE pkpart1 PARTITION OF pkpart FOR VALUES IN (1);
|
||||
ALTER TABLE fkpart7.pkpart1 ADD PRIMARY KEY (a);
|
||||
ALTER TABLE fkpart7.pkpart ADD PRIMARY KEY (a);
|
||||
CREATE TABLE fkpart7.fk (a int REFERENCES fkpart7.pkpart);
|
||||
DROP SCHEMA fkpart7 CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to table fkpart7.pkpart
|
||||
drop cascades to table fkpart7.fk
|
||||
|
||||
@@ -1657,3 +1657,13 @@ DELETE FROM pk WHERE a = 20;
|
||||
UPDATE pk SET a = 90 WHERE a = 30;
|
||||
SELECT tableoid::regclass, * FROM fk;
|
||||
DROP TABLE fk;
|
||||
|
||||
-- test for reported bug: relispartition not set
|
||||
-- https://postgr.es/m/CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com
|
||||
CREATE SCHEMA fkpart7
|
||||
CREATE TABLE pkpart (a int) PARTITION BY LIST (a)
|
||||
CREATE TABLE pkpart1 PARTITION OF pkpart FOR VALUES IN (1);
|
||||
ALTER TABLE fkpart7.pkpart1 ADD PRIMARY KEY (a);
|
||||
ALTER TABLE fkpart7.pkpart ADD PRIMARY KEY (a);
|
||||
CREATE TABLE fkpart7.fk (a int REFERENCES fkpart7.pkpart);
|
||||
DROP SCHEMA fkpart7 CASCADE;
|
||||
|
||||
Reference in New Issue
Block a user