Thread

Commits

  1. Fix SET CONSTRAINTS .. DEFERRED on partitioned tables

  1. deferrable FK constraints on partitioned rels

    Alvaro Herrera <alvherre@2ndquadrant.com> — 2019-11-05T19:19:48Z

    While messing around, I noticed that SET CONSTRAINTS ... DEFERRED
    does not work with partitioned tables.  I had some code to cover this
    case, but it has a bug that prevents it from working at all: the sanity
    check that verifies whether triggers exist fails.
    
    The attached patch fixes this problem: it merely removes the sanity
    check.  With that, everything works.
    
    (Another approach I tried was to split out constraints in partitioned
    tables vs. constraints in regular ones.  That's indeed workable, but it
    requires us to do two additional syscache access per partition for
    get_rel_relkind, which seems excessive.)
    
    The UNIQUE DEFERRABLE case works after the patch.  (I didn't try without
    the patch.)
    
    -- 
    Álvaro Herrera                         Developer, https://www.PostgreSQL.org/
    
  2. Re: deferrable FK constraints on partitioned rels

    Alvaro Herrera <alvherre@2ndquadrant.com> — 2019-11-05T21:29:16Z

    On 2019-Nov-05, Alvaro Herrera wrote:
    
    > While messing around, I noticed that SET CONSTRAINTS ... DEFERRED
    > does not work with partitioned tables.  I had some code to cover this
    > case, but it has a bug that prevents it from working at all: the sanity
    > check that verifies whether triggers exist fails.
    > 
    > The attached patch fixes this problem: it merely removes the sanity
    > check.  With that, everything works.
    > 
    > (Another approach I tried was to split out constraints in partitioned
    > tables vs. constraints in regular ones.  That's indeed workable, but it
    > requires us to do two additional syscache access per partition for
    > get_rel_relkind, which seems excessive.)
    
    Uh, somehow I posted a previous version of the patch that implements my
    rejected approach, instead of the final version I described.  Here's the
    real patch (which also includes tests).
    
    -- 
    Álvaro Herrera                https://www.2ndQuadrant.com/
    PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
    
  3. Re: deferrable FK constraints on partitioned rels

    Alvaro Herrera <alvherre@2ndquadrant.com> — 2019-11-07T17:29:27Z

    On 2019-Nov-05, Alvaro Herrera wrote:
    
    > Uh, somehow I posted a previous version of the patch that implements my
    > rejected approach, instead of the final version I described.  Here's the
    > real patch (which also includes tests).
    
    This was broken in pg11 also.  Pushed to all branches.
    
    -- 
    Álvaro Herrera                https://www.2ndQuadrant.com/
    PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services