pgsql: Add support for NOT ENFORCED in CHECK constraints

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add support for NOT ENFORCED in CHECK constraints
Date: 2025-01-11 10:54:33
Message-ID: E1tWZ8T-000yuv-3r@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add support for NOT ENFORCED in CHECK constraints

This adds support for the NOT ENFORCED/ENFORCED flag for constraints,
with support for check constraints.

The plan is to eventually support this for foreign key constraints,
where it is typically more useful.

Note that CHECK constraints do not currently support ALTER operations,
so changing the enforceability of an existing constraint isn't
possible without dropping and recreating it. This could be added
later.

Author: Amul Sul <amul(dot)sul(at)enterprisedb(dot)com>
Reviewed-by: Peter Eisentraut <peter(at)eisentraut(dot)org>
Reviewed-by: jian he <jian(dot)universality(at)gmail(dot)com>
Tested-by: Triveni N <triveni(dot)n(at)enterprisedb(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/CAAJ_b962c5AcYW9KUt_R_ER5qs3fUGbe4az-SP-vuwPS-w-AGA(at)mail(dot)gmail(dot)com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ca87c415e2fccf81cec6fd45698dde9fae0ab570

Modified Files
--------------
doc/src/sgml/catalogs.sgml | 10 +++
doc/src/sgml/information_schema.sgml | 4 +-
doc/src/sgml/ref/alter_table.sgml | 12 +--
doc/src/sgml/ref/create_foreign_table.sgml | 6 +-
doc/src/sgml/ref/create_table.sgml | 34 +++++++-
src/backend/access/common/tupdesc.c | 2 +
src/backend/catalog/heap.c | 55 ++++++++++---
src/backend/catalog/index.c | 1 +
src/backend/catalog/information_schema.sql | 2 +-
src/backend/catalog/pg_constraint.c | 9 ++
src/backend/catalog/sql_features.txt | 2 +-
src/backend/commands/tablecmds.c | 51 +++++++++++-
src/backend/commands/trigger.c | 1 +
src/backend/commands/typecmds.c | 17 ++++
src/backend/executor/execMain.c | 8 +-
src/backend/nodes/makefuncs.c | 1 +
src/backend/optimizer/util/plancat.c | 11 +++
src/backend/parser/gram.y | 104 +++++++++++++++++++-----
src/backend/parser/parse_utilcmd.c | 57 +++++++++++--
src/backend/utils/adt/ruleutils.c | 6 +-
src/backend/utils/cache/relcache.c | 1 +
src/include/access/tupdesc.h | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/catalog/heap.h | 1 +
src/include/catalog/pg_constraint.h | 2 +
src/include/nodes/parsenodes.h | 3 +
src/include/parser/kwlist.h | 1 +
src/test/regress/expected/alter_table.out | 10 +++
src/test/regress/expected/constraints.out | 40 ++++++++-
src/test/regress/expected/create_table_like.out | 10 ++-
src/test/regress/expected/domain.out | 22 +++++
src/test/regress/expected/inherit.out | 94 +++++++++++++++++++--
src/test/regress/sql/alter_table.sql | 7 ++
src/test/regress/sql/constraints.sql | 22 ++++-
src/test/regress/sql/create_table_like.sql | 3 +-
src/test/regress/sql/domain.sql | 10 +++
src/test/regress/sql/inherit.sql | 47 ++++++++++-
37 files changed, 599 insertions(+), 70 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2025-01-11 13:14:05 Re: pgsql: TupleHashTable: store additional data along with tuple.
Previous Message Junwang Zhao 2025-01-11 10:18:50 Re: pgsql: TupleHashTable: store additional data along with tuple.