Re: Foreign key validation failure in 18beta1

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Antonin Houska <ah(at)cybertec(dot)at>, Amul Sul <sulamul(at)gmail(dot)com>
Subject: Re: Foreign key validation failure in 18beta1
Date: 2025-05-28 12:26:06
Message-ID: 202505281226.ohdyrr2jrw6r@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 time the pk rel is pk, and it's ok.
> The second time the pk rel is only pk_1, and the type(1) is not in pk_1, so
> an error is reported.
>
> In this case, the two children newconstraint should not be added to the
> queue.

Yeah, I reached the same conclusion and this is the preliminary fix I
had written for it. I don't like that I had to duplicate a few lines of
code, but maybe it's not too bad. Also the comments need to be
clarified a bit more.

Clearly b663b9436e75 lacked tests.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Sallah, I said NO camels! That's FIVE camels; can't you count?"
(Indiana Jones)

Attachment Content-Type Size
0001-Don-t-validate-referenced-side-FK-subconstraints.patch text/x-diff 2.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tender Wang 2025-05-28 12:38:15 Re: Foreign key validation failure in 18beta1
Previous Message Tender Wang 2025-05-28 12:12:16 Re: Foreign key validation failure in 18beta1