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