]> git.ipfire.org Git - thirdparty/postgresql.git/commit
doc: mention unusability of dropped CHECK to verify NOT NULL
authorÁlvaro Herrera <alvherre@kurilemu.de>
Mon, 4 Aug 2025 11:26:44 +0000 (13:26 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Mon, 4 Aug 2025 11:26:44 +0000 (13:26 +0200)
commit2f600115a5a95e94f4085a5114ace0116314c4a4
tree53a869a0dbca3515ea8f0aeb169e6e15285d9138
parent6914a330f019feab9fb90fc7d79c93e24ca3193f
doc: mention unusability of dropped CHECK to verify NOT NULL

It's possible to use a CHECK (col IS NOT NULL) constraint to skip
scanning a table for nulls when adding a NOT NULL constraint on the same
column.  However, if the CHECK constraint is dropped on the same command
that the NOT NULL is added, this fails, i.e., makes the NOT NULL addition
slow.  The best we can do about it at this stage is to document this so
that users aren't taken by surprise.

(In Postgres 18 you can directly add the NOT NULL constraint as NOT
VALID instead, so there's no longer much use for the CHECK constraint,
therefore no point in building mechanism to support the case better.)

Reported-by: Andrew <psy2000usa@yahoo.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Discussion: https://postgr.es/m/175385113607.786.16774570234342968908@wrigleys.postgresql.org
doc/src/sgml/ref/alter_table.sgml