NOT NULL NOT ENFORCED - Mailing list pgsql-hackers

From jian he
Subject NOT NULL NOT ENFORCED
Date
Msg-id CACJufxFbH1_9BDow=4nMSdBfLSOAkiGD5hxO6bouWjZAyHbV+A@mail.gmail.com
Whole thread Raw
Responses Re: NOT NULL NOT ENFORCED
List pgsql-hackers
hi.

attached patch will remove sql_features.txt item F492: "Optional table
constraint
enforcement" Comment: "except not-null constraints". see [1]

main points about NOT NULL NOT ENFORCED
* one column can have at most one NOT-NULL constraint, regardless constraints
  property (not enforced or enforced)
* if column already have not enforced not-null constraint then:
  ALTER TABLE ALTER COLUMN SET NOT NULL: error out, can not validate
not enforced not-null constraint
  ALTER TABLE ADD NOT NULL: error out, can not add another not-null
constraint, one column can only have one.

not null in partitioned table:
* If the partitioned table has an enforced not-null constraint, its partitions
cannot have not enforced.
* If the partitioned table has a NOT ENFORCED not-null constraint, its
partitions may have either ENFORCED or NOT ENFORCED not-null constraints, but
the constraint itself is still required.

not null in table inheritance:
OK: parent is not enforced, while child is enforced
NOT OK: parent is enforced, while child is not enforced
If a column inherits from multiple tables and the ancestor tables have
conflicting ENFORCED statuses, raise an error.

I have written extensive tests to cover the corner case, the tests may be
overwhelming.

[1]: https://www.postgresql.org/docs/devel/features-sql-standard.html

Attachment

pgsql-hackers by date:

Previous
From: kasaharatt
Date:
Subject: Re: Add log_autovacuum_{vacuum|analyze}_min_duration
Next
From: Michael Paquier
Date:
Subject: Re: Sequence Access Methods, round two