88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.104 2002/08/31 19:09:27 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.105 2002/08/31 19:10:08 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -69,9 +69,8 @@ static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext,
6969bool * isNull ,ExprDoneCond * isDone );
7070static Datum ExecEvalBooleanTest (BooleanTest * btest ,ExprContext * econtext ,
7171bool * isNull ,ExprDoneCond * isDone );
72- static Datum ExecEvalConstraintTest (ConstraintTest * constraint ,
73- ExprContext * econtext ,
74- bool * isNull ,ExprDoneCond * isDone );
72+ static Datum ExecEvalConstraint (Constraint * constraint ,ExprContext * econtext ,
73+ bool * isNull ,ExprDoneCond * isDone );
7574
7675
7776/*----------
@@ -1466,6 +1465,43 @@ ExecEvalNullTest(NullTest *ntest,
14661465}
14671466}
14681467
1468+ /*
1469+ * ExecEvalConstraint
1470+ *
1471+ * Test the constraint against the data provided. If the data fits
1472+ * within the constraint specifications, pass it through (return the
1473+ * datum) otherwise throw an error.
1474+ */
1475+ static Datum
1476+ ExecEvalConstraint (Constraint * constraint ,ExprContext * econtext ,
1477+ bool * isNull ,ExprDoneCond * isDone )
1478+ {
1479+ Datum result ;
1480+
1481+ result = ExecEvalExpr (constraint -> raw_expr ,econtext ,isNull ,isDone );
1482+
1483+ /* Test for the constraint type */
1484+ switch (constraint -> contype )
1485+ {
1486+ case CONSTR_NOTNULL :
1487+ if (* isNull )
1488+ {
1489+ elog (ERROR ,"Domain %s does not allow NULL values" ,constraint -> name );
1490+ }
1491+ break ;
1492+ case CONSTR_CHECK :
1493+
1494+ elog (ERROR ,"ExecEvalConstraint: Domain CHECK Constraints not yet implemented" );
1495+ break ;
1496+ default :
1497+ elog (ERROR ,"ExecEvalConstraint: Constraint type unknown" );
1498+ break ;
1499+ }
1500+
1501+ /* If all has gone well (constraint did not fail) return the datum */
1502+ return result ;
1503+ }
1504+
14691505/* ----------------------------------------------------------------
14701506 *ExecEvalBooleanTest
14711507 *
@@ -1546,41 +1582,6 @@ ExecEvalBooleanTest(BooleanTest *btest,
15461582}
15471583}
15481584
1549- /*
1550- * ExecEvalConstraintTest
1551- *
1552- * Test the constraint against the data provided. If the data fits
1553- * within the constraint specifications, pass it through (return the
1554- * datum) otherwise throw an error.
1555- */
1556- static Datum
1557- ExecEvalConstraintTest (ConstraintTest * constraint ,ExprContext * econtext ,
1558- bool * isNull ,ExprDoneCond * isDone )
1559- {
1560- Datum result ;
1561-
1562- result = ExecEvalExpr (constraint -> arg ,econtext ,isNull ,isDone );
1563-
1564- switch (constraint -> testtype )
1565- {
1566- case CONSTR_TEST_NOTNULL :
1567- if (* isNull )
1568- elog (ERROR ,"Domain %s does not allow NULL values" ,
1569- constraint -> name );
1570- break ;
1571- case CONSTR_TEST_CHECK :
1572- /* TODO: Add CHECK Constraints to domains */
1573- elog (ERROR ,"Domain CHECK Constraints not yet implemented" );
1574- break ;
1575- default :
1576- elog (ERROR ,"ExecEvalConstraintTest: Constraint type unknown" );
1577- break ;
1578- }
1579-
1580- /* If all has gone well (constraint did not fail) return the datum */
1581- return result ;
1582- }
1583-
15841585/* ----------------------------------------------------------------
15851586 *ExecEvalFieldSelect
15861587 *
@@ -1748,6 +1749,12 @@ ExecEvalExpr(Node *expression,
17481749isNull ,
17491750isDone );
17501751break ;
1752+ case T_Constraint :
1753+ retDatum = ExecEvalConstraint ((Constraint * )expression ,
1754+ econtext ,
1755+ isNull ,
1756+ isDone );
1757+ break ;
17511758case T_CaseExpr :
17521759retDatum = ExecEvalCase ((CaseExpr * )expression ,
17531760econtext ,
@@ -1766,12 +1773,6 @@ ExecEvalExpr(Node *expression,
17661773isNull ,
17671774isDone );
17681775break ;
1769- case T_ConstraintTest :
1770- retDatum = ExecEvalConstraintTest ((ConstraintTest * )expression ,
1771- econtext ,
1772- isNull ,
1773- isDone );
1774- break ;
17751776
17761777default :
17771778elog (ERROR ,"ExecEvalExpr: unknown expression type %d" ,