1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

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.
This commit is contained in:
Tom Lane
2002-08-31 22:10:48 +00:00
parent 1440acd703
commit 845a6c3acc
19 changed files with 335 additions and 176 deletions

View File

@ -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
@ -931,6 +931,38 @@ _readBooleanTest(void)
return local_node;
}
/* ----------------
* _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
*
@ -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);