Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-27 Thread Amul Sul
On Sun, Jan 26, 2025 at 10:08 PM Álvaro Herrera wrote: > > On 2025-Jan-25, Álvaro Herrera wrote: > > > On Sat, Jan 25, 2025, at 6:00 AM, Alexander Lakhin wrote: > > > Hello Álvaro, > > > > > > Please look at the script that produces an error starting from b663b9436: > > > > Ah yes, this is my bug:

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-26 Thread Álvaro Herrera
On 2025-Jan-25, Álvaro Herrera wrote: > On Sat, Jan 25, 2025, at 6:00 AM, Alexander Lakhin wrote: > > Hello Álvaro, > > > > Please look at the script that produces an error starting from b663b9436: > > Ah yes, this is my bug: I moved a CCI where it became conditional. > Will fix, thanks for the

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-25 Thread Álvaro Herrera
On Sat, Jan 25, 2025, at 6:00 AM, Alexander Lakhin wrote: > Hello Álvaro, > > Please look at the script that produces an error starting from b663b9436: Ah yes, this is my bug: I moved a CCI where it became conditional. Will fix, thanks for the test case.

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-24 Thread Alexander Lakhin
Hello Álvaro, 23.01.2025 17:04, Álvaro Herrera wrote: OK thanks, looks good, I have pushed it now with some trivial amendments. Please look at the script that produces an error starting from b663b9436: CREATE TABLE st (a int, primary key (a)); CREATE TABLE pt (a int,   FOREIGN KEY (a) REFERENC

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-24 Thread Amul Sul
On Fri, Jan 24, 2025 at 7:46 AM Tom Lane wrote: > > =?utf-8?Q?=C3=81lvaro?= Herrera writes: > > OK thanks, looks good, I have pushed it now with some trivial > > amendments. > > Looks like some of the queries need ORDER BY for stability. > > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-23 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > OK thanks, looks good, I have pushed it now with some trivial > amendments. Looks like some of the queries need ORDER BY for stability. https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=morepork&dt=2025-01-23%2023%3A35%3A57

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-23 Thread Álvaro Herrera
On 2025-Jan-22, Amul Sul wrote: > You’re correct; it’s fixed in the attached version, along with an > assert(!convalidated) in QueueFKConstraintValidation(), and I’ve > included tests to cover the change. Thanks for reviewing this patch. OK thanks, looks good, I have pushed it now with some trivi

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-21 Thread Amul Sul
On Wed, Jan 22, 2025 at 2:36 AM Álvaro Herrera wrote: > > > Suppose I have a hierarchy like this > > parent > | > child >/\ > / \ > /grandchild2 > / > grandchild1 > > and I have a validated constraint on grandchild1 and an invalid > constraint on c

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-21 Thread Álvaro Herrera
Suppose I have a hierarchy like this parent | child /\ / \ /grandchild2 / grandchild1 and I have a validated constraint on grandchild1 and an invalid constraint on child. What happens if I add a constraint on parent? In my understanding, it sho

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-16 Thread Álvaro Herrera
On 2025-Jan-15, Amul Sul wrote: > I made the minor changes to the attached version and rebased it > against the latest master(9a45a89c38f). Pushed 0001, thanks. -- Álvaro HerreraBreisgau, Deutschland — https://www.EnterpriseDB.com/

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-14 Thread Amul Sul
On Mon, Jan 6, 2025 at 9:53 AM Amul Sul wrote: > I made the minor changes to the attached version and rebased it against the latest master(9a45a89c38f). Regards, Amul v2-0001-Refactor-Split-ATExecValidateConstraint.patch Description: Binary data v2-0002-Allow-NOT-VALID-foreign-key-constraint

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-05 Thread Amul Sul
On Fri, Jan 3, 2025 at 12:11 AM Álvaro Herrera wrote: > > > > On Thu, Jan 2, 2025, at 5:49 PM, Amul Sul wrote: > > When adding a new FK constraint or attaching a partitioned table, where > matching FK constraints are merged, we allow the parent constraint to be NOT > VALID while the child constrai

Re: Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-02 Thread Álvaro Herrera
On Thu, Jan 2, 2025, at 5:49 PM, Amul Sul wrote: > When adding a new FK constraint or attaching a partitioned table, where > matching FK constraints are merged, we allow the parent constraint to be NOT > VALID while the child constraint remains VALID, which is harmless. However, > the > reverse

Allow NOT VALID foreign key constraints on partitioned tables.

2025-01-02 Thread Amul Sul
uple(tuple); - copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); - copy_con->convalidated = true; - CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple); - - InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0); - - heap_freetuple(copyTuple); - ObjectAddressSet(address,