Re: handling multiple matching constraints in DetachPartitionFinalize() - Mailing list pgsql-hackers

From Zhihong Yu
Subject Re: handling multiple matching constraints in DetachPartitionFinalize()
Date
Msg-id CALNJ-vQx1JqRKAvFK+9va-6kh8fe+-=S=+Typo5fGs+CUOhJtA@mail.gmail.com
Whole thread Raw
In response to handling multiple matching constraints in DetachPartitionFinalize()  (Zhihong Yu <zyu@yugabyte.com>)
Responses Re: handling multiple matching constraints in DetachPartitionFinalize()
List pgsql-hackers


On Tue, Aug 23, 2022 at 10:10 AM Zhihong Yu <zyu@yugabyte.com> wrote:
Hi,
I was looking at the following code in DetachPartitionFinalize():

        /* If there's a constraint associated with the index, detach it too */
        constrOid = get_relation_idx_constraint_oid(RelationGetRelid(partRel),
                                                    idxid);

As mentioned in email thread `parenting a PK constraint to a self-FK one`, there may be multiple matching constraints, I think we should call ConstraintSetParentConstraint() for each of them.

This means adding a helper method similar to get_relation_idx_constraint_oid() which finds constraint and calls ConstraintSetParentConstraint().

I am preparing a patch.
Please let me know if my proposal makes sense.

Thanks

This is what I came up with. 
Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: SQL/JSON features for v15
Next
From: Tom Lane
Date:
Subject: Re: SQL/JSON features for v15