88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.103 2002/08/30 23:59:46 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.104 2002/08/31 19:09:27 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -69,8 +69,9 @@ 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 ExecEvalConstraint (Constraint * constraint ,ExprContext * econtext ,
73- bool * isNull ,ExprDoneCond * isDone );
72+ static Datum ExecEvalConstraintTest (ConstraintTest * constraint ,
73+ ExprContext * econtext ,
74+ bool * isNull ,ExprDoneCond * isDone );
7475
7576
7677/*----------
@@ -1465,43 +1466,6 @@ ExecEvalNullTest(NullTest *ntest,
14651466}
14661467}
14671468
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-
15051469/* ----------------------------------------------------------------
15061470 *ExecEvalBooleanTest
15071471 *
@@ -1582,6 +1546,41 @@ ExecEvalBooleanTest(BooleanTest *btest,
15821546}
15831547}
15841548
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+
15851584/* ----------------------------------------------------------------
15861585 *ExecEvalFieldSelect
15871586 *
@@ -1749,12 +1748,6 @@ ExecEvalExpr(Node *expression,
17491748isNull ,
17501749isDone );
17511750break ;
1752- case T_Constraint :
1753- retDatum = ExecEvalConstraint ((Constraint * )expression ,
1754- econtext ,
1755- isNull ,
1756- isDone );
1757- break ;
17581751case T_CaseExpr :
17591752retDatum = ExecEvalCase ((CaseExpr * )expression ,
17601753econtext ,
@@ -1773,6 +1766,12 @@ ExecEvalExpr(Node *expression,
17731766isNull ,
17741767isDone );
17751768break ;
1769+ case T_ConstraintTest :
1770+ retDatum = ExecEvalConstraintTest ((ConstraintTest * )expression ,
1771+ econtext ,
1772+ isNull ,
1773+ isDone );
1774+ break ;
17761775
17771776default :
17781777elog (ERROR ,"ExecEvalExpr: unknown expression type %d" ,