mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +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:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.106 2002/07/20 05:16:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.107 2002/08/31 22:10:43 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -1882,12 +1882,14 @@ expression_tree_walker(Node *node,
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_Constraint:
|
||||
return walker(((Constraint *) node)->raw_expr, context);
|
||||
case T_NullTest:
|
||||
return walker(((NullTest *) node)->arg, context);
|
||||
case T_BooleanTest:
|
||||
return walker(((BooleanTest *) node)->arg, context);
|
||||
case T_ConstraintTest:
|
||||
if (walker(((ConstraintTest *) node)->arg, context))
|
||||
return true;
|
||||
return walker(((ConstraintTest *) node)->check_expr, context);
|
||||
case T_SubLink:
|
||||
{
|
||||
SubLink *sublink = (SubLink *) node;
|
||||
@@ -2238,20 +2240,6 @@ expression_tree_mutator(Node *node,
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_Constraint:
|
||||
{
|
||||
/*
|
||||
* Used for confirming domains. Only needed fields
|
||||
* within the executor are the name, raw expression
|
||||
* and constraint type.
|
||||
*/
|
||||
Constraint *con = (Constraint *) node;
|
||||
Constraint *newnode;
|
||||
|
||||
FLATCOPY(newnode, con, Constraint);
|
||||
MUTATE(newnode->raw_expr, con->raw_expr, Node *);
|
||||
return (Node *) newnode;
|
||||
}
|
||||
case T_NullTest:
|
||||
{
|
||||
NullTest *ntest = (NullTest *) node;
|
||||
@@ -2272,6 +2260,17 @@ expression_tree_mutator(Node *node,
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_ConstraintTest:
|
||||
{
|
||||
ConstraintTest *ctest = (ConstraintTest *) node;
|
||||
ConstraintTest *newnode;
|
||||
|
||||
FLATCOPY(newnode, ctest, ConstraintTest);
|
||||
MUTATE(newnode->arg, ctest->arg, Node *);
|
||||
MUTATE(newnode->check_expr, ctest->check_expr, Node *);
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_SubLink:
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user