Re: Another FK violation when referencing a multi-level partitionedtable

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Another FK violation when referencing a multi-level partitionedtable
Дата
Msg-id 20200207213051.GA32185@alvherre.pgsql
обсуждение исходный текст
Ответ на Another FK violation when referencing a multi-level partitionedtable  (Jehan-Guillaume de Rorthais <jgdr@dalibo.com>)
Ответы Re: Another FK violation when referencing a multi-level partitionedtable  (Jehan-Guillaume de Rorthais <jgdr@dalibo.com>)
Re: Another FK violation when referencing a multi-level partitioned table  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On 2020-Feb-06, Jehan-Guillaume de Rorthais wrote:

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.

Uh.

> 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.)
>      */

Strange that this escaped testing previously.

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

You fix looks correct to me, so pushed.  I took a minute to apply some
minor corrections to the comments, too.

Thanks for reporting!

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

Предыдущее
От: 0010203112132233
Дата:
Сообщение: Re: BUG #16249: Partition pruning blocks on exclusively locked table partition
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #16250: As the owner of a database, I can't CREATE EXTENSION postgis;