diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-31 22:10:48 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-31 22:10:48 +0000 |
commit | 845a6c3acccea0ec34e70808787aa7d431b0d96d (patch) | |
tree | c6e162146378dc6cdb62793d3b30674b6d64d465 /src/backend/nodes/readfuncs.c | |
parent | 1440acd703e04f39340f7fb3a432b028a791e038 (diff) |
Code review for domain-constraints patch. Use a new ConstraintTest node
type for runtime constraint checks, instead of misusing the parse-time
Constraint node for the purpose. Fix some damage introduced into type
coercion logic; in particular ensure that a coerced expression tree will
read out the correct result type when inspected (patch had broken some
RelabelType cases). Enforce domain NOT NULL constraints against columns
that are omitted from an INSERT.
Diffstat (limited to 'src/backend/nodes/readfuncs.c')
-rw-r--r-- | src/backend/nodes/readfuncs.c | 36 |
1 files changed, 35 insertions, 1 deletions
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); |