Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints
Date: 2025-04-08 00:21:49
Message-ID: CAGPqQf2XeAsK60ZRa-iVQr6ACJjcgOS=P8m_s1PGUuw667f=Bw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 8, 2025 at 1:24 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
wrote:

> On 2025-Apr-07, jian he wrote:
>
> > CREATE TABLE t (a int, b int);
> > INSERT INTO t VALUES (NULL, 1), (300, 3);
> > ALTER TABLE t ADD CONSTRAINT nn NOT NULL a NOT VALID; -- ok
> > ALTER TABLE t add column c float8 default random();
> > the last query should not fail.
>
> Agreed.
>
> > if we want more places use CompactAttribute->attnullability
> > set_attnotnull should also set CompactAttribute->attnullability
> proactively
> > not waiting CommandCounterIncrement invoke RelationBuildTupleDesc.
>
> Actually, the fix here was to tweak equalTupleDescs to also compare
> attnullability, and then ensure that a relcache invalidation happens.
> That way the old tupdesc goes away correctly.
>

Ah okay.

>
> I have pushed this after some small additional changes. I ran some of
> the tests under debug_discard_caches=1 to make sure that invalidations
> are handled correctly also.
>
> I have to admit that this patch was much more difficult than I had
> initially anticipated. Thank you Rushabh very much for the effort in
> writing and rewriting as the different ideas came and went, and Jian for
> the eagle eyes and the additional test cases and debugging.
>

Thank you Alvaro for your support and guidance. Thanks Jian.

> Cheers
>
> --
> Álvaro Herrera Breisgau, Deutschland —
> https://www.EnterpriseDB.com/
> "In Europe they call me Niklaus Wirth; in the US they call me Nickel's
> worth.
> That's because in Europe they call me by name, and in the US by value!"
>

--
Rushabh Lathia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lukas Fittl 2025-04-08 01:11:06 Re: Proposal - Allow extensions to set a Plan Identifier
Previous Message Ryohei Takahashi (Fujitsu) 2025-04-08 00:20:58 Can we use Statistics Import and Export feature to perforamance testing?