Commit 1440acd7 authored by Tom Lane's avatar Tom Lane

Wups, didn't mean to commit that just yet.

parent 0da6cf54
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.104 2002/08/31 19:09:27 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.105 2002/08/31 19:10:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -69,8 +69,7 @@ static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext, ...@@ -69,8 +69,7 @@ static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone); bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalBooleanTest(BooleanTest *btest, ExprContext *econtext, static Datum ExecEvalBooleanTest(BooleanTest *btest, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone); bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalConstraintTest(ConstraintTest *constraint, static Datum ExecEvalConstraint(Constraint *constraint, ExprContext *econtext,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone); bool *isNull, ExprDoneCond *isDone);
...@@ -1466,6 +1465,43 @@ ExecEvalNullTest(NullTest *ntest, ...@@ -1466,6 +1465,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 * ExecEvalBooleanTest
* *
...@@ -1546,41 +1582,6 @@ ExecEvalBooleanTest(BooleanTest *btest, ...@@ -1546,41 +1582,6 @@ ExecEvalBooleanTest(BooleanTest *btest,
} }
} }
/*
* ExecEvalConstraintTest
*
* 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
ExecEvalConstraintTest(ConstraintTest *constraint, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
Datum result;
result = ExecEvalExpr(constraint->arg, econtext, isNull, isDone);
switch (constraint->testtype)
{
case CONSTR_TEST_NOTNULL:
if (*isNull)
elog(ERROR, "Domain %s does not allow NULL values",
constraint->name);
break;
case CONSTR_TEST_CHECK:
/* TODO: Add CHECK Constraints to domains */
elog(ERROR, "Domain CHECK Constraints not yet implemented");
break;
default:
elog(ERROR, "ExecEvalConstraintTest: Constraint type unknown");
break;
}
/* If all has gone well (constraint did not fail) return the datum */
return result;
}
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* ExecEvalFieldSelect * ExecEvalFieldSelect
* *
...@@ -1748,6 +1749,12 @@ ExecEvalExpr(Node *expression, ...@@ -1748,6 +1749,12 @@ ExecEvalExpr(Node *expression,
isNull, isNull,
isDone); isDone);
break; break;
case T_Constraint:
retDatum = ExecEvalConstraint((Constraint *) expression,
econtext,
isNull,
isDone);
break;
case T_CaseExpr: case T_CaseExpr:
retDatum = ExecEvalCase((CaseExpr *) expression, retDatum = ExecEvalCase((CaseExpr *) expression,
econtext, econtext,
...@@ -1766,12 +1773,6 @@ ExecEvalExpr(Node *expression, ...@@ -1766,12 +1773,6 @@ ExecEvalExpr(Node *expression,
isNull, isNull,
isDone); isDone);
break; break;
case T_ConstraintTest:
retDatum = ExecEvalConstraintTest((ConstraintTest *) expression,
econtext,
isNull,
isDone);
break;
default: default:
elog(ERROR, "ExecEvalExpr: unknown expression type %d", elog(ERROR, "ExecEvalExpr: unknown expression type %d",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment