summaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-06-09 19:08:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-06-09 19:08:20 +0000
commit7e64dbc6b5e516a2510ae41c8c7999d1d8d25872 (patch)
treec819b78903b490e720b4c20969ed6cf8816889d1 /src/backend/optimizer
parent3a0df651da253879bf133a8556853acfb1f664fd (diff)
Support assignment to subfields of composite columns in UPDATE and INSERT.
As a side effect, cause subscripts in INSERT targetlists to do something more or less sensible; previously we evaluated such subscripts and then effectively ignored them. Another side effect is that UPDATE-ing an element or slice of an array value that is NULL now produces a non-null result, namely an array containing just the assigned-to positions.
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/util/clauses.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index b22360ac2b1..a3a2ddfbd83 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.174 2004/06/05 19:48:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.175 2004/06/09 19:08:16 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -724,6 +724,13 @@ contain_nonstrict_functions_walker(Node *node, void *context)
/* an aggregate could return non-null with null input */
return true;
}
+ if (IsA(node, ArrayRef))
+ {
+ /* array assignment is nonstrict */
+ if (((ArrayRef *) node)->refassgnexpr != NULL)
+ return true;
+ /* else fall through to check args */
+ }
if (IsA(node, FuncExpr))
{
FuncExpr *expr = (FuncExpr *) node;
@@ -771,6 +778,8 @@ contain_nonstrict_functions_walker(Node *node, void *context)
}
if (IsA(node, SubPlan))
return true;
+ if (IsA(node, FieldStore))
+ return true;
if (IsA(node, CaseExpr))
return true;
if (IsA(node, CaseWhen))
@@ -2450,6 +2459,16 @@ expression_tree_walker(Node *node,
break;
case T_FieldSelect:
return walker(((FieldSelect *) node)->arg, context);
+ case T_FieldStore:
+ {
+ FieldStore *fstore = (FieldStore *) node;
+
+ if (walker(fstore->arg, context))
+ return true;
+ if (walker(fstore->newvals, context))
+ return true;
+ }
+ break;
case T_RelabelType:
return walker(((RelabelType *) node)->arg, context);
case T_CaseExpr:
@@ -2840,6 +2859,18 @@ expression_tree_mutator(Node *node,
return (Node *) newnode;
}
break;
+ case T_FieldStore:
+ {
+ FieldStore *fstore = (FieldStore *) node;
+ FieldStore *newnode;
+
+ FLATCOPY(newnode, fstore, FieldStore);
+ MUTATE(newnode->arg, fstore->arg, Expr *);
+ MUTATE(newnode->newvals, fstore->newvals, List *);
+ newnode->fieldnums = list_copy(fstore->fieldnums);
+ return (Node *) newnode;
+ }
+ break;
case T_RelabelType:
{
RelabelType *relabel = (RelabelType *) node;