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