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/optimizer/prep/preptlist.c | |
| parent | 1440acd703e04f39340f7fb3a432b028a791e038 (diff) | |
| download | postgresql-845a6c3acccea0ec34e70808787aa7d431b0d96d.tar.gz | |
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/optimizer/prep/preptlist.c')
| -rw-r--r-- | src/backend/optimizer/prep/preptlist.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index b7c0bac12c..41f9b2f947 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 */ |
