Extend DomainHasConstraints() to optionally check constraint volatility
Andrew Dunstan <andrew@dunslane.net>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/copyfrom.c | modified | +1 −1 |
| src/backend/commands/tablecmds.c | modified | +2 −2 |
| src/backend/executor/execExpr.c | modified | +1 −1 |
| src/backend/optimizer/util/clauses.c | modified | +1 −1 |
| src/backend/parser/parse_expr.c | modified | +1 −1 |
| src/backend/utils/cache/typcache.c | modified | +25 −2 |
| src/include/utils/typcache.h | modified | +1 −1 |
Discussion
- support fast default for domain with constraints 20 messages · 2025-03-05 → 2026-03-13