Another FK violation when referencing a multi-level partitionedtable

Поиск
Список
Период
Сортировка
От Jehan-Guillaume de Rorthais
Тема Another FK violation when referencing a multi-level partitionedtable
Дата
Msg-id 20200206004948.238352db@firost
обсуждение исходный текст
Ответы Re: Another FK violation when referencing a multi-level partitionedtable  (Michael Paquier <michael@paquier.xyz>)
Re: Another FK violation when referencing a multi-level partitionedtable  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-bugs
Hello,

When working on the patch to fix another FK violation [1], I found that FK
constraints were not properly cloned to partition not directly hooked to the
root table.

CloneFkReferenced takes care to avoid inherited constraints to clone top-level
constraints only:

    /*
     * Search for any constraints where this partition is in the referenced
     * side.  However, we must ignore any constraint whose parent constraint
     * is also going to be cloned, to avoid duplicates. [...]
     */

But it seems the top-level constraints are actually never cloned neither.

Surprisingly, the comment explains how this should be done in two steps, but
the code corrupted the first step by skipping inherited constraints and lacks
the second step:


     * [...]to avoid duplicates.  So do it in two
     * steps: first construct the list of constraints to clone, then go over
     * that list cloning those whose parents are not in the list.  (We must
     * not rely on the parent being seen first, since the catalog scan could
     * return children first.)
     */

Please, find in attachment a proposal patch to fix this FK violation.

Regards,

[1] https://www.postgresql.org/message-id/20200204183906.115f693e%40firost

Вложения

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

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: Re: BUG #16242: convert_tuple_* not handling missing values correctly
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #16242: convert_tuple_* not handling missing values correctly