Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit479ebce

Browse files
committed
doc: mention unusability of dropped CHECK to verify NOT NULL
It's possible to use a CHECK (col IS NOT NULL) constraint to skipscanning a table for nulls when adding a NOT NULL constraint on the samecolumn. However, if the CHECK constraint is dropped on the same commandthat the NOT NULL is added, this fails, i.e., makes the NOT NULL additionslow. The best we can do about it at this stage is to document this sothat users aren't taken by surprise.(In Postgres 18 you can directly add the NOT NULL constraint as NOTVALID 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
1 parent1d3ded5 commit479ebce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎doc/src/sgml/ref/alter_table.sgml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
237237
provided none of the records in the table contain a
238238
<literal>NULL</literal> value for the column. Ordinarily this is
239239
checked during the <literal>ALTER TABLE</literal> by scanning the
240-
entire table; however, if a valid <literal>CHECK</literal> constraint is
241-
found which proves no <literal>NULL</literal> can exist, then the
242-
table scan is skipped.
240+
entire table;
241+
however, if a valid <literal>CHECK</literal> constraint exists
242+
(and is not dropped in the same command) which proves no
243+
<literal>NULL</literal> can exist, then the table scan is skipped.
243244
</para>
244245

245246
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp