Re: BUG #18628: Race condition during attach/detach partition breaks constraints of partition having foreign key

Поиск
Список
Период
Сортировка
От Alexander Lakhin
Тема Re: BUG #18628: Race condition during attach/detach partition breaks constraints of partition having foreign key
Дата
Msg-id 2db29417-eac1-35b6-94e3-a9c0bdb9c035@gmail.com
обсуждение исходный текст
Ответ на BUG #18628: Race condition during attach/detach partition breaks constraints of partition having foreign key  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #18628: Race condition during attach/detach partition breaks constraints of partition having foreign key
Re: BUG #18628: Race condition during attach/detach partition breaks constraints of partition having foreign key
Список pgsql-bugs
22.09.2024 17:00, PG Bug reporting form wrote:
> The following script:
> ...
> ends up with:
> ERROR:  could not find ON INSERT check triggers of foreign key constraint
> 16409

I'm sorry,  I' was too hasty to untangle those queries. Now I see that
this error can be produced with this serial script:
CREATE TABLE pt (id int PRIMARY KEY, rid int,
   FOREIGN KEY (rid) REFERENCES pt(id))
PARTITION BY LIST (id);

CREATE TABLE p1 PARTITION OF pt FOR VALUES IN (1);
ALTER TABLE pt DETACH PARTITION p1;
-- p1 gets a constraint:
-- "pt_rid_fkey" FOREIGN KEY (rid) REFERENCES pt(id)

CREATE TABLE p2 PARTITION OF pt FOR VALUES IN (2);
-- CloneFkReferenced() -> addFkRecurseReferenced() clones the above
-- constraint and creates another one:
-- conname: p1_rid_fkey, conrelid: id of p1, confrelid: id of p2,
-- conparentid: id of the above constraint
-- (\d+ p2 doesn't show this constraint due to conparentid != 0)

ALTER TABLE pt ATTACH PARTITION p1 FOR VALUES IN (1);
-- p1 attached with no constraints added or removed

ALTER TABLE pt DETACH PARTITION p1;
-- DetachPartitionFinalize() gets the p1_rid_fkey constraint with
-- RelationGetFKeyList(partRel) and then fails to find INSERT trigger for
-- it, because the constraint has only DELETE and UPDATE triggers linked
-- to the p2 relation.

ERROR:  could not find ON INSERT check triggers of foreign key constraint 16410

Alvaro, could you please take a look at this?

Best regards,
Alexander



В списке pgsql-bugs по дате отправления: