aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/typecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/typecmds.c')
-rw-r--r--src/backend/commands/typecmds.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 353043d581a..7fc3ad7e736 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -2871,7 +2871,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
pstate->p_value_substitute = (Node *) domVal;
- expr = transformExpr(pstate, constr->raw_expr);
+ expr = transformExpr(pstate, constr->raw_expr, EXPR_KIND_DOMAIN_CHECK);
/*
* Make sure it yields a boolean result.
@@ -2884,39 +2884,16 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
assign_expr_collations(pstate, expr);
/*
- * Make sure no outside relations are referred to.
+ * Domains don't allow variables (this is probably dead code now that
+ * add_missing_from is history, but let's be sure).
*/
- if (list_length(pstate->p_rtable) != 0)
+ if (list_length(pstate->p_rtable) != 0 ||
+ contain_var_clause(expr))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot use table references in domain check constraint")));
/*
- * Domains don't allow var clauses (this should be redundant with the
- * above check, but make it anyway)
- */
- if (contain_var_clause(expr))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
- errmsg("cannot use table references in domain check constraint")));
-
- /*
- * No subplans or aggregates, either...
- */
- if (pstate->p_hasSubLinks)
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot use subquery in check constraint")));
- if (pstate->p_hasAggs)
- ereport(ERROR,
- (errcode(ERRCODE_GROUPING_ERROR),
- errmsg("cannot use aggregate function in check constraint")));
- if (pstate->p_hasWindowFuncs)
- ereport(ERROR,
- (errcode(ERRCODE_WINDOWING_ERROR),
- errmsg("cannot use window function in check constraint")));
-
- /*
* Convert to string form for storage.
*/
ccbin = nodeToString(expr);