@@ -403,6 +403,33 @@ CREATE TABLE products (
403403 ensure that a column does not contain null values, the not-null
404404 constraint described in the next section can be used.
405405 </para>
406+
407+ <note>
408+ <para>
409+ <productname>PostgreSQL</productname> does not support
410+ <literal>CHECK</literal> constraints that reference table data other than
411+ the new or updated row being checked. While a <literal>CHECK</literal>
412+ constraint that violates this rule may appear to work in simple
413+ tests, it cannot guarantee that the database will not reach a state
414+ in which the constraint condition is false (due to subsequent changes
415+ of the other row(s) involved). This would cause a database dump and
416+ reload to fail. The reload could fail even when the complete
417+ database state is consistent with the constraint, due to rows not
418+ being loaded in an order that will satisfy the constraint. If
419+ possible, use <literal>UNIQUE</literal>, <literal>EXCLUDE</literal>,
420+ or <literal>FOREIGN KEY</literal> constraints to express
421+ cross-row and cross-table restrictions.
422+ </para>
423+
424+ <para>
425+ If what you desire is a one-time check against other rows at row
426+ insertion, rather than a continuously-maintained consistency
427+ guarantee, a custom <link linkend="triggers">trigger</link> can be used
428+ to implement that. (This approach avoids the dump/reload problem because
429+ <application>pg_dump</application> does not reinstall triggers until after
430+ reloading data, so that the check will not be enforced during a dump/reload.)
431+ </para>
432+ </note>
406433 </sect2>
407434
408435 <sect2>
0 commit comments