Re: ALTER CONSTRAINT on a partitioned FK isn't working - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: ALTER CONSTRAINT on a partitioned FK isn't working
Date
Msg-id 20210429230228.GA25949@alvherre.pgsql
Whole thread Raw
In response to ALTER CONSTRAINT on a partitioned FK isn't working  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ALTER CONSTRAINT on a partitioned FK isn't working
List pgsql-bugs
On 2020-Dec-07, Tom Lane wrote:

> then everything behaves as expected.  So something is broken
> about propagating deferred-ness to partition triggers in an
> ALTER CONSTRAINT.  Oddly, it *looks* like it worked if you
> examine the child tables with "\d+".  I surmise that ALTER CONSTRAINT
> fixes whatever catalog fields psql looks at, but there's some other
> fields that also need to be updated and aren't being.

I came up with this.  As I mentioned in my earlier reply, handling
recursion in the usual way doesn't fix the whole problem, because we
need to recurse on possibly both sides of the constraint.  So I made it
recurse using pg_constraint.conparentid, which seems easier and cover
both ends.  This is pretty crude so far but it handles the trivial
cases.  What I did is split the existing routine in two, and the "inner"
part now recurses on itself if it sees that either table is partitioned.

I'll polish it tomorrow -- intend to get this pushed to branches back to
11, depending on what's needed.

-- 
Álvaro Herrera       Valdivia, Chile

Attachment

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #16976: server crash when deleting via a trigger on a foreign table
Next
From: chenyanfei
Date:
Subject: syslogger file descriptor question