Re: not null constraints, again

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tender Wang <tndrwang@gmail.com>, Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-01T14:54:50Z
Lists: pgsql-hackers

Attachments

ATExecDropInherit
    /*
     * If the parent has a primary key, then we decrement counts for all NOT
     * NULL constraints
     */
    ObjectAddressSet(address, RelationRelationId,
                     RelationGetRelid(parent_rel));

only not-null constraint,
with ALTER TABLE NO INHERIT we still decrement counts for not-null constraints.
I feel the comment is in the wrong place?



please check the attached function MergeConstraintsIntoExisting refactoring
1. make it error check more confined within CONSTRAINT_CHECK and
CONSTRAINT_NOTNULL.
2. since get_attname will do system cache search, we can just use
Relation->rd_att and TupleDescAttr

Commits

  1. Suppress "may be used uninitialized" warnings from older compilers.

  2. Elide not-null constraint checks on child tables during PK creation

  3. Remove unnecessary code to handle CONSTR_NOTNULL

  4. Silence compilers about extractNotNullColumn()

  5. Add pg_constraint rows for not-null constraints