]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Extend DomainHasConstraints() to optionally check constraint volatility
authorAndrew Dunstan <andrew@dunslane.net>
Thu, 12 Mar 2026 21:52:33 +0000 (17:52 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Thu, 12 Mar 2026 22:04:16 +0000 (18:04 -0400)
commit487cf2cbd2f5a32cf9756eb9bd6dbf9f3956c8b7
tree1a96c75c35e8a8a11a1f7a4fbe7b1f7a3ae33a5f
parenta630ac5c2016e523a1c29df117b7c1a563a7f6f8
Extend DomainHasConstraints() to optionally check constraint volatility

Add an optional bool *has_volatile output parameter to
DomainHasConstraints().  When non-NULL, the function checks whether any
CHECK constraint contains a volatile expression.  Callers that don't
need this information pass NULL and get the same behavior as before.

This is needed by a subsequent commit that enables the fast default
optimization for domains with non-volatile constraints: we can safely
evaluate such constraints once at ALTER TABLE time, but volatile
constraints require a full table rewrite.

Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Viktor Holmberg <viktor.holmberg@aiven.io>
Discussion: https://postgr.es/m/CACJufxE_+iZBR1i49k_AHigppPwLTJi6km8NOsC7FWvKdEmmXg@mail.gmail.com
src/backend/commands/copyfrom.c
src/backend/commands/tablecmds.c
src/backend/executor/execExpr.c
src/backend/optimizer/util/clauses.c
src/backend/parser/parse_expr.c
src/backend/utils/cache/typcache.c
src/include/utils/typcache.h