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: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Robert Haas <robertmhaas@gmail.com>, Rushabh Lathia <rushabh.lathia@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-03-31T12:25:35Z
Lists: pgsql-hackers
hi.
in notnull-notvalid.patch

+ if (coninfo->contype == 'c')
+ keyword = "CHECK CONSTRAINT";
+ else
+ keyword = "INVALID NOT NULL CONSTRAINT";

we have a new TocEntry->desc kind.
so the following related code within src/bin/pg_dump also needs change
----------------

                                if (strcmp(te->desc, "CONSTRAINT") == 0 ||
                                    strcmp(te->desc, "CHECK CONSTRAINT") == 0 ||
                                    strcmp(te->desc, "FK CONSTRAINT") == 0)
                                    strcpy(buffer, "DROP CONSTRAINT");
                                else
                                    snprintf(buffer, sizeof(buffer), "DROP %s",
                                             te->desc);
----------------
            else if (strcmp(te->desc, "CONSTRAINT") == 0 ||
                     strcmp(te->desc, "CHECK CONSTRAINT") == 0 ||
                     strcmp(te->desc, "FK CONSTRAINT") == 0 ||
                     strcmp(te->desc, "INDEX") == 0 ||
                     strcmp(te->desc, "RULE") == 0 ||
                     strcmp(te->desc, "TRIGGER") == 0)
                te->section = SECTION_POST_DATA;
----------------
    /* these object types don't have separate owners */
    else if (strcmp(type, "CAST") == 0 ||
             strcmp(type, "CHECK CONSTRAINT") == 0 ||
             strcmp(type, "CONSTRAINT") == 0 ||
             strcmp(type, "DATABASE PROPERTIES") == 0 ||
             strcmp(type, "DEFAULT") == 0 ||
             strcmp(type, "FK CONSTRAINT") == 0 ||
             strcmp(type, "INDEX") == 0 ||
             strcmp(type, "RULE") == 0 ||
             strcmp(type, "TRIGGER") == 0 ||
             strcmp(type, "ROW SECURITY") == 0 ||
             strcmp(type, "POLICY") == 0 ||
             strcmp(type, "USER MAPPING") == 0)
    {
        /* do nothing */
    }



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