diff options
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r-- | src/backend/optimizer/prep/preptlist.c | 8 | ||||
-rw-r--r-- | src/backend/optimizer/util/clauses.c | 33 |
2 files changed, 23 insertions, 18 deletions
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index b7c0bac12c8..41f9b2f9478 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.54 2002/08/02 18:15:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.55 2002/08/31 22:10:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -27,6 +27,7 @@ #include "nodes/makefuncs.h" #include "optimizer/prep.h" #include "parser/parsetree.h" +#include "parser/parse_coerce.h" static List *expand_targetlist(List *tlist, int command_type, @@ -162,6 +163,8 @@ expand_targetlist(List *tlist, int command_type, * * For INSERT, generate a NULL constant. (We assume the * rewriter would have inserted any available default value.) + * Also, if the column isn't dropped, apply any domain constraints + * that might exist --- this is to catch domain NOT NULL. * * For UPDATE, generate a Var reference to the existing value of * the attribute, so that it gets copied to the new tuple. @@ -182,6 +185,9 @@ expand_targetlist(List *tlist, int command_type, att_tup->attbyval, false, /* not a set */ false); + if (!att_tup->attisdropped) + new_expr = coerce_type_constraints(NULL, new_expr, + atttype, false); break; case CMD_UPDATE: /* Insert NULLs for dropped columns */ diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 9e8372139ef..3b5e6988396 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -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: { /* |