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

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Rushabh Lathia <rushabh.lathia@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-04-07T12:43:03Z
Lists: pgsql-hackers

Attachments

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.

Commits

  1. Allow NOT NULL constraints to be added as NOT VALID

  2. Add missing deparsing of [NO] IDENT to XMLSERIALIZE()

  3. backend launchers void * arguments for binary data

  4. Add pg_constraint rows for not-null constraints

  5. Create the infrastructure for planner support functions.

  6. Add prokind column, replacing proisagg and proiswindow