Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails

Поиск
Список
Период
Сортировка
От Tender Wang
Тема Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Дата
Msg-id CAHewXNmF-dn+hMkcsWM=b_f7Zc4nwP7EN0uXK0NG_VNEk-q1uA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Ответы Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Список pgsql-hackers
Hi Alvaro,

Recently, Alexander reported the same issue on [1]. And before that, another same issue was reported on [2].
So I try to re-work those  issues.  In my last email on this thread, I said that 
"
I slightly modified the previous patch,but I didn't add test case, because I found another issue.
After done ALTER TABLE r ATTACH PARTITION r_1 FOR VALUES IN (1);
I run the oidjoins.sql and has warnings as belwo:
psql:/tender/postgres/src/test/regress/sql/oidjoins.sql:49: WARNING:  FK VIOLATION IN pg_trigger({tgparentid}): ("(0,3)",16401)
psql:/tender/postgres/src/test/regress/sql/oidjoins.sql:49: WARNING:  FK VIOLATION IN pg_trigger({tgparentid}): ("(0,4)",16402)
"

And I gave the explanation:
"
The two trigger tuples are deleted in tryAttachPartitionForeignKey called by CloneFkReferencing.
/*
* Looks good!  Attach this constraint.  The action triggers in the new
* partition become redundant -- the parent table already has equivalent
* ones, and those will be able to reach the partition.  Remove the ones
* in the partition.  We identify them because they have our constraint
* OID, as well as being on the referenced rel.
*/
"
I try to fix above fk violation. I have two ideas.
i. Do not remove redundant, but when detaching parittion, the action trigger on referenced side will be create again.
I have consider about this situation.

ii. We still remove redundant, and the remove the child action trigger, too.  If we do this way. 
Should we create action trigger recursively on referced side when detaching partition.

I can't decide which one is better. And I'm not sure that keep this FK VIOLATION will cause some problem.
I rebase and send v3 patch, which only fix NOT FOUND INSERT CHECK TRIGGER.



--
Tender Wang
Вложения

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

Предыдущее
От: Pogosyan Vardan
Дата:
Сообщение: Re: Removing unneeded self joins
Следующее
От: Nitin Jadhav
Дата:
Сообщение: Re: Inconsistency in reporting checkpointer stats