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

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

hi.

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.

if we want more places use CompactAttribute->attnullability
set_attnotnull should also set CompactAttribute->attnullability proactively
not waiting CommandCounterIncrement invoke RelationBuildTupleDesc.

another reason:
CheckNNConstraintFetch only handle "if (!conform->convalidated)"
what if the not-null is set conform->convalidated to true,
then RelationBuildTupleDesc doesn't set/change
CompactAttribute->attnullability at all.

attached is all the needed changes after v8-0001, v8-0002, i think.

Attachment Content-Type Size
v8-0003-not-null-not-valid-miscellous-fix.no-cfbot application/octet-stream 5.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-04-07 12:47:11 Re: Fix 035_standby_logical_decoding.pl race conditions
Previous Message Álvaro Herrera 2025-04-07 12:39:23 Re: Restrict publishing of partitioned table with a foreign table as partition