Re: Bug in detaching a partition with a foreign key.

2025-01-21 Thread Amul Sul
On Tue, Jan 21, 2025 at 7:25 PM Álvaro Herrera wrote: > > On 2025-Jan-20, Sami Imseih wrote: > > > Patch looks good to me, > > Thanks, pushed. > A big thanks to Álvaro and Sami for getting it fixed! Regards, Amul

Re: Bug in detaching a partition with a foreign key.

2025-01-21 Thread Álvaro Herrera
On 2025-Jan-20, Sami Imseih wrote: > Patch looks good to me, Thanks, pushed. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

Re: Bug in detaching a partition with a foreign key.

2025-01-21 Thread Álvaro Herrera
On 2025-Jan-20, Sami Imseih wrote: > Patch looks good to me, but I am not sure about this part of the comment: > > "Only the topmost one is to be considered here; the child constraints > must be left alone," > > In this case, none of the pg_constraint entries are actually considered. > right?

Re: Bug in detaching a partition with a foreign key.

2025-01-20 Thread Sami Imseih
> > The patch that Amul and I wrote both achieve the same result. > > The approach that Amul took builds a list of constraint OIDs, > > which could grow with the number of partitions and foreign keys > > on those partitions. Maybe not a big deal? > Nope, not a big deal. It would be a big deal if

Re: Bug in detaching a partition with a foreign key.

2025-01-20 Thread Álvaro Herrera
On 2025-Jan-20, Sami Imseih wrote: > The patch that Amul and I wrote both achieve the same result. > The approach that Amul took builds a list of constraint OIDs, > which could grow with the number of partitions and foreign keys > on those partitions. Maybe not a big deal? Nope, not a big deal.

Re: Bug in detaching a partition with a foreign key.

2025-01-20 Thread Sami Imseih
The patch that Amul and I wrote both achieve the same result. The approach that Amul took builds a list of constraint OIDs, which could grow with the number of partitions and foreign keys on those partitions. Maybe not a big deal? In my suggestion [1], I just do one extra pg_constraint lookup to d

Re: Bug in detaching a partition with a foreign key.

2025-01-20 Thread Álvaro Herrera
On 2025-Jan-20, Sami Imseih wrote: > Below is the repro I used. Similar as you original repro, > but without subpartition on foo_p0. This also results in the segfault > with your attached patch. I think the issue in Amul's patch is just that the list was not initialized to NIL. Other than the la

Re: Bug in detaching a partition with a foreign key.

2025-01-20 Thread Sami Imseih
> should cut the link between the parent constraint and the constraint on > the partition being detached. correct by setting the conparentid to 0 in pg_constraint and to delete the pg_depend record for partition dependency. But in the repro case, we don't have a dependency as the table the foreign

Re: Bug in detaching a partition with a foreign key.

2025-01-19 Thread Amul Sul
On Sat, Jan 18, 2025 at 2:14 AM Sami Imseih 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 c

Re: Bug in detaching a partition with a foreign key.

2025-01-17 Thread Sami Imseih
This is a bug indeed. I tried your patch, but it ends up in a seg fault. I also see this was raised in another thread [0]. It can be reproduced in a slightly simplified case, using only a single level partition. """ CREATE TABLE bar(id int PRIMARY KEY) PARTITION BY RANGE(id); CREATE TABLE bar_p0

Bug in detaching a partition with a foreign key.

2025-01-16 Thread Amul Sul
Hi, While detaching a partition with a foreign key referencing a partitioned table, I am getting the following error: ERROR: could not find ON INSERT check triggers of foreign key constraint 16636 I haven’t looked closely at what the issue might be, but it seems the logic inside DetachPartition