Fix ON CONFLICT bugs that manifest when used in rules.
Andres Freund <andres@anarazel.de>
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.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/executor/nodeModifyTable.c | modified | +1 −0 |
| src/backend/nodes/nodeFuncs.c | modified | +3 −0 |
| src/backend/optimizer/plan/setrefs.c | modified | +6 −3 |
| src/backend/rewrite/rewriteManip.c | modified | +12 −3 |
| src/test/regress/expected/rules.out | modified | +96 −9 |
| src/test/regress/sql/rules.sql | modified | +33 −2 |