summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorBruce Momjian2002-07-06 20:16:36 +0000
committerBruce Momjian2002-07-06 20:16:36 +0000
commit1666970275cf6cc44d2944888a6199c31b3e6832 (patch)
treee79f2615f20b5c65600f0b95787e246a1f580996 /src/backend/executor
parent5af6e0a4ac57f11d071d6200f0264bf6798b64f6 (diff)
I've fixed up the way domain constraints (not null and type length)
are managed as per request. Moved from merging with table attributes to applying themselves during coerce_type() and coerce_type_typmod. Regression tests altered to test the cast() scenarios. Rod Taylor
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execQual.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 789251b70e7..6bb2b5fa942 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.96 2002/07/04 16:44:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.97 2002/07/06 20:16:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,6 +66,8 @@ static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalBooleanTest(BooleanTest *btest, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
+static Datum ExecEvalConstraint(Constraint *constraint, ExprContext *econtext,
+ bool *isNull, ExprDoneCond *isDone);
/*----------
@@ -1226,6 +1228,43 @@ ExecEvalNullTest(NullTest *ntest,
}
}
+/*
+ * ExecEvalConstraint
+ *
+ * Test the constraint against the data provided. If the data fits
+ * within the constraint specifications, pass it through (return the
+ * datum) otherwise throw an error.
+ */
+static Datum
+ExecEvalConstraint(Constraint *constraint, ExprContext *econtext,
+ bool *isNull, ExprDoneCond *isDone)
+{
+ Datum result;
+
+ result = ExecEvalExpr(constraint->raw_expr, econtext, isNull, isDone);
+
+ /* Test for the constraint type */
+ switch(constraint->contype)
+ {
+ case CONSTR_NOTNULL:
+ if (*isNull)
+ {
+ elog(ERROR, "Domain %s does not allow NULL values", constraint->name);
+ }
+ break;
+ case CONSTR_CHECK:
+
+ elog(ERROR, "ExecEvalConstraint: Domain CHECK Constraints not yet implemented");
+ break;
+ default:
+ elog(ERROR, "ExecEvalConstraint: Constraint type unknown");
+ break;
+ }
+
+ /* If all has gone well (constraint did not fail) return the datum */
+ return result;
+}
+
/* ----------------------------------------------------------------
* ExecEvalBooleanTest
*
@@ -1473,6 +1512,12 @@ ExecEvalExpr(Node *expression,
isNull,
isDone);
break;
+ case T_Constraint:
+ retDatum = ExecEvalConstraint((Constraint *) expression,
+ econtext,
+ isNull,
+ isDone);
+ break;
case T_CaseExpr:
retDatum = ExecEvalCase((CaseExpr *) expression,
econtext,