Re: Foreign key validation failure in 18beta1

2025-06-05 Thread Amul Sul
On Thu, Jun 5, 2025 at 10:31 PM Alvaro Herrera wrote: > > On 2025-Jun-04, jian he wrote: > > > On Tue, Jun 3, 2025 at 12:14 PM Amul Sul wrote: > > > > > > v7 is way more intuitive compared with v5, v6. > > Agreed, this version is better than the previous ones. I split it as > two commits, for NO

Re: Foreign key validation failure in 18beta1

2025-06-05 Thread Alvaro Herrera
On 2025-Jun-04, jian he wrote: > On Tue, Jun 3, 2025 at 12:14 PM Amul Sul wrote: > > > I found a third approach that requires only a few changes. The key > > idea is to determine the root referenced table and pass it to > > QueueFKConstraintValidation(). We would then enqueue phase 3 > > validati

Re: Foreign key validation failure in 18beta1

2025-06-03 Thread jian he
On Tue, Jun 3, 2025 at 12:14 PM Amul Sul wrote: > > > > I found a third approach that requires only a few changes. The key > idea is to determine the root referenced table and pass it to > QueueFKConstraintValidation(). We would then enqueue phase 3 > validation only if the constraint tuple’s conf

Re: Foreign key validation failure in 18beta1

2025-06-02 Thread Amul Sul
On Mon, Jun 2, 2025 at 9:56 PM Alvaro Herrera wrote: > > Hello > > I find this coding somewhat confusing. Now you have a function > "QueueFkConstraintValidation" which may queue a FK queue constraint > validation, if the flag "queueValidation" is given, but it may also do > something else -- make

Re: Foreign key validation failure in 18beta1

2025-06-02 Thread Alvaro Herrera
Hello I find this coding somewhat confusing. Now you have a function "QueueFkConstraintValidation" which may queue a FK queue constraint validation, if the flag "queueValidation" is given, but it may also do something else -- makes no sense IMO. I think it's better to split this function in two;

Re: Foreign key validation failure in 18beta1

2025-06-01 Thread Amul Sul
On Sun, Jun 1, 2025 at 6:05 PM jian he wrote: > > On Fri, May 30, 2025 at 6:32 PM Amul Sul wrote: > > [...] > > + * Note that validation should be performed against the referencing > + * root table only, not its child partitions. See > + * QueueFKConstraintValidation() for more details. > */ >

Re: Foreign key validation failure in 18beta1

2025-06-01 Thread jian he
On Fri, May 30, 2025 at 6:32 PM Amul Sul wrote: > > > Kindly take a look at the attached version. I've also added the tests. > Thanks for your script -- all tests are passing with this patch. > hi. + * Note that validation should be performed against the referencing + * root table only, not its

Re: Foreign key validation failure in 18beta1

2025-05-30 Thread Amul Sul
On Fri, May 30, 2025 at 1:37 PM jian he wrote: > > On Thu, May 29, 2025 at 8:58 PM Amul Sul wrote: > > > > > > I just realized we have the same problem with ALTER FOREIGN KEY ENFORCED. > > > for example: > > > > Yeah, I think adding a "currcon->confrelid == pkrelid" check before > > enqueueing va

Re: Foreign key validation failure in 18beta1

2025-05-30 Thread jian he
On Thu, May 29, 2025 at 8:58 PM Amul Sul wrote: > > > > I just realized we have the same problem with ALTER FOREIGN KEY ENFORCED. > > for example: > > Yeah, I think adding a "currcon->confrelid == pkrelid" check before > enqueueing validation in ATExecAlterConstrEnforceability() would > address th

Re: Foreign key validation failure in 18beta1

2025-05-29 Thread Amul Sul
On Thu, May 29, 2025 at 5:57 PM jian he wrote: > > On Thu, May 29, 2025 at 8:12 PM Amul Sul wrote: > > > > > >> > [...] > > > The attached *draft* patch is based on your idea. > > > > > > The idea is that we only need to conditionally do > > > ``tab->constraints = lappend(tab->constraints, newcon

Re: Foreign key validation failure in 18beta1

2025-05-29 Thread jian he
On Thu, May 29, 2025 at 8:12 PM Amul Sul wrote: > > > >> > [...] > > The attached *draft* patch is based on your idea. > > > > The idea is that we only need to conditionally do > > ``tab->constraints = lappend(tab->constraints, newcon);`` within > > QueueFKConstraintValidation. > > but the catalog

Re: Foreign key validation failure in 18beta1

2025-05-29 Thread Amul Sul
On Thu, May 29, 2025 at 12:38 PM jian he wrote: > > On Wed, May 28, 2025 at 8:38 PM Tender Wang wrote: > > > > > > > > Alvaro Herrera 于2025年5月28日周三 20:26写道: > >> > >> On 2025-May-28, Tender Wang wrote: > >> > >> > [...] > The attached *draft* patch is based on your idea. > > The idea is that we

Re: Foreign key validation failure in 18beta1

2025-05-29 Thread jian he
On Wed, May 28, 2025 at 8:38 PM Tender Wang wrote: > > > > Alvaro Herrera 于2025年5月28日周三 20:26写道: >> >> On 2025-May-28, Tender Wang wrote: >> >> > I dided the codes, in QueueFKConstraintValidation(), we add three >> > newconstraint for the >> > fk rel, because the pk rel is partition table. >> >

Re: Foreign key validation failure in 18beta1

2025-05-28 Thread Tender Wang
Tender Wang 于2025年5月28日周三 20:38写道: > > > Alvaro Herrera 于2025年5月28日周三 20:26写道: > >> On 2025-May-28, Tender Wang wrote: >> >> > I dided the codes, in QueueFKConstraintValidation(), we add three >> > newconstraint for the >> > fk rel, because the pk rel is partition table. >> > >> > During phase

Re: Foreign key validation failure in 18beta1

2025-05-28 Thread Tender Wang
Alvaro Herrera 于2025年5月28日周三 20:26写道: > On 2025-May-28, Tender Wang wrote: > > > I dided the codes, in QueueFKConstraintValidation(), we add three > > newconstraint for the > > fk rel, because the pk rel is partition table. > > > > During phase 3 of AlterTable, in ATRewriteTables(), > > call val

Re: Foreign key validation failure in 18beta1

2025-05-28 Thread Alvaro Herrera
On 2025-May-28, Tender Wang wrote: > I dided the codes, in QueueFKConstraintValidation(), we add three > newconstraint for the > fk rel, because the pk rel is partition table. > > During phase 3 of AlterTable, in ATRewriteTables(), > call validateForeignKeyConstraint() three times. > The first t

Re: Foreign key validation failure in 18beta1

2025-05-28 Thread Tender Wang
Tender Wang 于2025年5月28日周三 18:54写道: > > > Antonin Houska 于2025年5月28日周三 15:51写道: > >> I've come across an unexpected ERROR during validation of FK constraint >> in PG >> 18beta1. The same works in PG 17: >> >> drop table if exists fk; >> drop table if exists pk; >> create table pk(i int primary ke

Re: Foreign key validation failure in 18beta1

2025-05-28 Thread Tender Wang
Antonin Houska 于2025年5月28日周三 15:51写道: > I've come across an unexpected ERROR during validation of FK constraint in > PG > 18beta1. The same works in PG 17: > > drop table if exists fk; > drop table if exists pk; > create table pk(i int primary key) partition by range (i); > create table pk_1 part

Foreign key validation failure in 18beta1

2025-05-28 Thread Antonin Houska
I've come across an unexpected ERROR during validation of FK constraint in PG 18beta1. The same works in PG 17: drop table if exists fk; drop table if exists pk; create table pk(i int primary key) partition by range (i); create table pk_1 partition of pk for values from (0) to (1); create table pk