On Sat, Jan 18, 2025 at 2:14 AM Sami Imseih <samims...@gmail.com> wrote: > > This is a bug indeed. I tried your patch, but it ends up in a seg fault. > > [...] > If the relation on the parent and child constraint match, that > tells us we don't have inheritance. > So, I am thinking we should add another condition for checking > if a foreign key is inherited by checking if the parent constraint > relation is different from the child constraint relation. > > I am attaching an unpolished patch ( we need test coverage as well ) that > implements the above. All tests pass with this patch.
Thanks for confirming the bug. TBH, I haven't had a chance to look into the issue in detail yet, but my understanding of the detach operation is that it should cut the link between the parent constraint and the constraint on the partition being detached. The trial patch I posted was meant to prevent cutting the link between the partition's constraint and the constraint that inherits it. Your patch seems to achieve the same, AFAIUC, but I'm not sure I like the way it's doing, nor the trial patch I posted. A crash is certainly possible with that patch, but it would be helpful if you could provide more context -- such as crash detail and/or a test case. Regards, Amul