mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user