1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

Fix ON CONFLICT bugs that manifest when used in rules.

Specifically the tlist and rti of the pseudo "excluded" relation weren't
properly treated by expression_tree_walker, which lead to errors when
excluded was referenced inside a rule because the varnos where not
properly adjusted.  Similar omissions in OffsetVarNodes and
expression_tree_mutator had less impact, but should obviously be fixed
nonetheless.

A couple tests of for ON CONFLICT UPDATE into INSERT rule bearing
relations have been added.

In passing I updated a couple comments.
This commit is contained in:
Andres Freund
2015-05-13 00:13:22 +02:00
parent 5c7df74204
commit 4af6e61a36
6 changed files with 151 additions and 17 deletions

View File

@ -1922,6 +1922,8 @@ expression_tree_walker(Node *node,
return true;
if (walker(onconflict->onConflictWhere, context))
return true;
if (walker(onconflict->exclRelTlist, context))
return true;
}
break;
case T_JoinExpr:
@ -2642,6 +2644,7 @@ expression_tree_mutator(Node *node,
MUTATE(newnode->arbiterWhere, oc->arbiterWhere, Node *);
MUTATE(newnode->onConflictSet, oc->onConflictSet, List *);
MUTATE(newnode->onConflictWhere, oc->onConflictWhere, Node *);
MUTATE(newnode->exclRelTlist, oc->exclRelTlist, List *);
return (Node *) newnode;
}