Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ff5ac04

Browse files
author
Commitfest Bot
committed
[CF 5285] v21 - NOT ENFORCED constraint feature
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5285 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAAJ_b94B8PByv_b4oxhHDzbGzjoY8cptKGAu-GX0_eiOkqEhHQ@mail.gmail.com Author(s): Amul Sul
2 parents 2a5e709 + 8c8fb5c commit ff5ac04

File tree

18 files changed

+1048
-286
lines changed

18 files changed

+1048
-286
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
26202620
</para>
26212621
<para>
26222622
Is the constraint enforced?
2623-
Currently, can be false only for CHECK constraints
2623+
Currently, can be false only for foreign keys and CHECK constraints
26242624
</para></entry>
26252625
</row>
26262626

doc/src/sgml/ref/alter_table.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
5858
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable>
5959
ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]
6060
ADD <replaceable class="parameter">table_constraint_using_index</replaceable>
61-
ALTER CONSTRAINT <replaceable class="parameter">constraint_name</replaceable> [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
61+
ALTER CONSTRAINT <replaceable class="parameter">constraint_name</replaceable> [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]
6262
ALTER CONSTRAINT <replaceable class="parameter">constraint_name</replaceable> [ INHERIT | NO INHERIT ]
6363
VALIDATE CONSTRAINT <replaceable class="parameter">constraint_name</replaceable>
6464
DROP CONSTRAINT [ IF EXISTS ] <replaceable class="parameter">constraint_name</replaceable> [ RESTRICT | CASCADE ]
@@ -589,7 +589,8 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
589589
This form validates a foreign key or check constraint that was
590590
previously created as <literal>NOT VALID</literal>, by scanning the
591591
table to ensure there are no rows for which the constraint is not
592-
satisfied. Nothing happens if the constraint is already marked valid.
592+
satisfied. If the constraint is not enforced, an error is thrown.
593+
Nothing happens if the constraint is already marked valid.
593594
(See <xref linkend="sql-altertable-notes"/> below for an explanation
594595
of the usefulness of this command.)
595596
</para>

doc/src/sgml/ref/create_table.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
14091409
</para>
14101410

14111411
<para>
1412-
This is currently only supported for <literal>CHECK</literal>
1412+
This is currently only supported for foreign key and <literal>CHECK</literal>
14131413
constraints.
14141414
</para>
14151415
</listitem>

src/backend/catalog/pg_constraint.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ CreateConstraintEntry(const char *constraintName,
100100
ObjectAddresses *addrs_auto;
101101
ObjectAddresses *addrs_normal;
102102

103-
/* Only CHECK constraint can be not enforced */
104-
Assert(isEnforced || constraintType == CONSTRAINT_CHECK);
103+
/* Only CHECK or FOREIGN KEY constraint can be not enforced */
104+
Assert(isEnforced || constraintType == CONSTRAINT_CHECK ||
105+
constraintType == CONSTRAINT_FOREIGN);
105106
/* NOT ENFORCED constraint must be NOT VALID */
106107
Assert(isEnforced || !isValidated);
107108

src/backend/catalog/sql_features.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ F461 Named character sets NO
281281
F471 Scalar subquery values YES
282282
F481 Expanded NULL predicate YES
283283
F491 Constraint management YES
284-
F492 Optional table constraint enforcement NO check constraints only
284+
F492 Optional table constraint enforcement YES except not-null constraints
285285
F501 Features and conformance views YES
286286
F501 Features and conformance views 01 SQL_FEATURES view YES
287287
F501 Features and conformance views 02 SQL_SIZING view YES

0 commit comments

Comments
 (0)