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-05T07:29:55Z
Lists: pgsql-hackers
Attachments
- v7-0002-NOT-NULL-NOT-VALID.patch (text/x-patch) patch v7-0002
- v7-0001-mark-conislocal-as-false-while-merging-valid-cons.patch (text/x-patch) patch v7-0001
On Fri, Apr 4, 2025 at 7:54 PM Rushabh Lathia <rushabh.lathia@gmail.com> wrote:
>
> Hi Alvaro,
>
> I’ve consolidated all the changes and attached the latest version of the patch, which
> includes the updates submitted by Jian for pg_dump as well.
>
> Patch 0001 contains changes to MergeWithExistingConstraint to fix the marking on local constraints.
> Patch 0002 includes support for NOT NULL NOT VALID, corresponding pg_dump changes, test cases,
> and documentation updates.
>
hi.
+ /* FIXME use CompactAttribute */
Form_pg_attribute att = TupleDescAttr(relation->rd_att, i - 1);
if (att->attnotnull && att->attnotnullvalid &&
!att->attisdropped)
{
NullTest *ntest = makeNode(NullTest);
ntest->arg = (Expr *) makeVar(varno,
i,
att->atttypid,
att->atttypmod,
att->attcollation,
0);
ntest->nulltesttype = IS_NOT_NULL;
CompactAttribute doesn't have {atttypmod, attcollation} information,
now it is impossible to use CompactAttribute here,
so I removed this FIXME in get_relation_constraints.
i noticed that we have
"mode change 100644 => 100755 src/bin/pg_dump/t/002_pg_dump.pl"
in 0002-Support-NOT-VALID-and-VALIDATE-CONSTRAINT-for-named-.patch.
i am uncomfortable with the change in
'CREATE TABLE dump_test.test_table_generated'
so I only added 'CONSTRAINT NOT NULL / INVALID' tests in
002_pg_dump.pl.
so I only added a test case 'CONSTRAINT NOT NULL / INVALID'
to 002_pg_dump.pl.
v7-0001 commit message explains what kind of problem
MergeWithExistingConstraint is trying to fix.
v7-0002 bullet points summary about NOT NULL NOT VALID added to the
commit message.
add a test for CREATE TABLE LIKE.
CREATE TABLE LIKE will copy the invalid not-null constraint and will become
valid, i think this is what we want.
The added regress test is a little bit verbose, trying to make it less verbose.
polish comments here and there.
Commits
-
Allow NOT NULL constraints to be added as NOT VALID
- a379061a22a8 18.0 landed
-
Add missing deparsing of [NO] IDENT to XMLSERIALIZE()
- 984410b92326 18.0 cited
-
backend launchers void * arguments for binary data
- 7202d72787d3 18.0 cited
-
Add pg_constraint rows for not-null constraints
- 14e87ffa5c54 18.0 cited
-
Create the infrastructure for planner support functions.
- 1fb57af92069 12.0 cited
-
Add prokind column, replacing proisagg and proiswindow
- fd1a421fe661 11.0 cited