pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Another FK violation when referencing a multi-level partitioned table
Date: Fri, 7 Feb 2020 18:30:51 -0300
Message-ID: <20200207213051.GA32185@alvherre.pgsql> (raw)
In-Reply-To: <20200206004948.238352db@firost>

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





view thread (9+ messages)  latest in thread

Message-ID: <20200207213051.GA32185@alvherre.pgsql>
Permalink:  ../20200207213051.GA32185@alvherre.pgsql/
Also on:    postgresql.org/message-id/20200207213051.GA32185@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, jgdr@dalibo.com
  Subject: Re: Another FK violation when referencing a multi-level partitioned table
  In-Reply-To: <20200207213051.GA32185@alvherre.pgsql>
  References: <20200206004948.238352db@firost> <20200207213051.GA32185@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox