diff options
Diffstat (limited to 'src/backend/nodes')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 38 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 19 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 22 | ||||
-rw-r--r-- | src/backend/nodes/readfuncs.c | 36 |
4 files changed, 93 insertions, 22 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 5b35eea170a..1938e7f4738 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.208 2002/08/30 19:23:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.209 2002/08/31 22:10:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -973,10 +973,6 @@ _copyJoinExpr(JoinExpr *from) return newnode; } -/* ---------------- - * _copyCaseExpr - * ---------------- - */ static CaseExpr * _copyCaseExpr(CaseExpr *from) { @@ -994,10 +990,6 @@ _copyCaseExpr(CaseExpr *from) return newnode; } -/* ---------------- - * _copyCaseWhen - * ---------------- - */ static CaseWhen * _copyCaseWhen(CaseWhen *from) { @@ -1012,10 +1004,6 @@ _copyCaseWhen(CaseWhen *from) return newnode; } -/* ---------------- - * _copyNullTest - * ---------------- - */ static NullTest * _copyNullTest(NullTest *from) { @@ -1030,10 +1018,6 @@ _copyNullTest(NullTest *from) return newnode; } -/* ---------------- - * _copyBooleanTest - * ---------------- - */ static BooleanTest * _copyBooleanTest(BooleanTest *from) { @@ -1048,6 +1032,23 @@ _copyBooleanTest(BooleanTest *from) return newnode; } +static ConstraintTest * +_copyConstraintTest(ConstraintTest *from) +{ + ConstraintTest *newnode = makeNode(ConstraintTest); + + /* + * copy remainder of node + */ + Node_Copy(from, newnode, arg); + newnode->testtype = from->testtype; + if (from->name) + newnode->name = pstrdup(from->name); + Node_Copy(from, newnode, check_expr); + + return newnode; +} + static ArrayRef * _copyArrayRef(ArrayRef *from) { @@ -3206,6 +3207,9 @@ copyObject(void *from) case T_BooleanTest: retval = _copyBooleanTest(from); break; + case T_ConstraintTest: + retval = _copyConstraintTest(from); + break; case T_FkConstraint: retval = _copyFkConstraint(from); break; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 7c9127dbf4f..10b8e79933d 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -20,7 +20,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.156 2002/08/30 19:23:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.157 2002/08/31 22:10:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1924,6 +1924,20 @@ _equalBooleanTest(BooleanTest *a, BooleanTest *b) return true; } +static bool +_equalConstraintTest(ConstraintTest *a, ConstraintTest *b) +{ + if (!equal(a->arg, b->arg)) + return false; + if (a->testtype != b->testtype) + return false; + if (!equalstr(a->name, b->name)) + return false; + if (!equal(a->check_expr, b->check_expr)) + return false; + return true; +} + /* * Stuff from pg_list.h */ @@ -2380,6 +2394,9 @@ equal(void *a, void *b) case T_BooleanTest: retval = _equalBooleanTest(a, b); break; + case T_ConstraintTest: + retval = _equalConstraintTest(a, b); + break; case T_FkConstraint: retval = _equalFkConstraint(a, b); break; diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index a92750caef1..8c255058068 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.171 2002/08/30 19:23:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.172 2002/08/31 22:10:43 tgl Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -1471,7 +1471,6 @@ _outNullTest(StringInfo str, NullTest *node) { appendStringInfo(str, " NULLTEST :arg "); _outNode(str, node->arg); - appendStringInfo(str, " :nulltesttype %d ", (int) node->nulltesttype); } @@ -1484,12 +1483,26 @@ _outBooleanTest(StringInfo str, BooleanTest *node) { appendStringInfo(str, " BOOLEANTEST :arg "); _outNode(str, node->arg); - appendStringInfo(str, " :booltesttype %d ", (int) node->booltesttype); } /* + * ConstraintTest + */ +static void +_outConstraintTest(StringInfo str, ConstraintTest *node) +{ + appendStringInfo(str, " CONSTRAINTTEST :arg "); + _outNode(str, node->arg); + appendStringInfo(str, " :testtype %d :name ", + (int) node->testtype); + _outToken(str, node->name); + appendStringInfo(str, " :check_expr "); + _outNode(str, node->check_expr); +} + +/* * _outNode - * converts a Node into ascii string and append it to 'str' */ @@ -1750,6 +1763,9 @@ _outNode(StringInfo str, void *obj) case T_BooleanTest: _outBooleanTest(str, obj); break; + case T_ConstraintTest: + _outConstraintTest(str, obj); + break; case T_FuncCall: _outFuncCall(str, obj); break; diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 2799bb74604..4d4001d2131 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.130 2002/08/30 19:23:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.131 2002/08/31 22:10:43 tgl Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -932,6 +932,38 @@ _readBooleanTest(void) } /* ---------------- + * _readConstraintTest + * + * ConstraintTest is a subclass of Node + * ---------------- + */ +static ConstraintTest * +_readConstraintTest(void) +{ + ConstraintTest *local_node; + char *token; + int length; + + local_node = makeNode(ConstraintTest); + + token = pg_strtok(&length); /* eat :arg */ + local_node->arg = nodeRead(true); /* now read it */ + + token = pg_strtok(&length); /* eat :testtype */ + token = pg_strtok(&length); /* get testtype */ + local_node->testtype = (ConstraintTestType) atoi(token); + + token = pg_strtok(&length); /* get :name */ + token = pg_strtok(&length); /* now read it */ + local_node->name = nullable_string(token, length); + + token = pg_strtok(&length); /* eat :check_expr */ + local_node->check_expr = nodeRead(true); /* now read it */ + + return local_node; +} + +/* ---------------- * _readVar * * Var is a subclass of Expr @@ -2222,6 +2254,8 @@ parsePlanString(void) return_value = _readNullTest(); else if (length == 11 && strncmp(token, "BOOLEANTEST", length) == 0) return_value = _readBooleanTest(); + else if (length == 14 && strncmp(token, "CONSTRAINTTEST", length) == 0) + return_value = _readConstraintTest(); else elog(ERROR, "badly formatted planstring \"%.10s\"...", token); |