@@ -11,7 +11,7 @@ index bbf220407b..9a82a2db04 100644
1111 pg_stat_statements \
1212 pg_surgery\
1313diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
14- indexd0e5bc26a7..5ca196518e 100644
14+ index7a3d9b4b01..0c3d2dec6c 100644
1515--- a/src/backend/access/transam/xact.c
1616+++ b/src/backend/access/transam/xact.c
1717@@ -78,7 +78,7 @@ intDefaultXactIsoLevel = XACT_READ_COMMITTED;
@@ -24,7 +24,7 @@ index d0e5bc26a7..5ca196518e 100644
2424 boolDefaultXactDeferrable = false;
2525 boolXactDeferrable;
2626diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
27- indexd5e46098c2..d3c02c1def 100644
27+ index87c7603f2b..9cc0bc0da8 100644
2828--- a/src/backend/executor/execExprInterp.c
2929+++ b/src/backend/executor/execExprInterp.c
3030@@ -1801,6 +1801,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
@@ -45,7 +45,7 @@ index d5e46098c2..d3c02c1def 100644
4545 return state->resvalue;
4646 }
4747diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
48- indexef2fd46092..8551733c55 100644
48+ index0ba61fd547..29d93998b2 100644
4949--- a/src/backend/executor/execMain.c
5050+++ b/src/backend/executor/execMain.c
5151@@ -826,6 +826,13 @@ InitPlan(QueryDesc *queryDesc, int eflags)
@@ -62,7 +62,7 @@ index ef2fd46092..8551733c55 100644
6262 /*
6363 * Next, build the ExecRowMark array from the PlanRowMark(s), if any.
6464 */
65- @@ -2811 ,6 +2818 ,13 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree)
65+ @@ -2849 ,6 +2856 ,13 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree)
6666 rcestate->es_junkFilter = parentestate->es_junkFilter;
6767 rcestate->es_output_cid = parentestate->es_output_cid;
6868
@@ -77,7 +77,7 @@ index ef2fd46092..8551733c55 100644
7777 * ResultRelInfos needed by subplans are initialized from scratch when the
7878 * subplans themselves are initialized.
7979diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
80- index2f6e66b641..d4a1e48c20 100644
80+ index1ad5dcb406..047508e0da 100644
8181--- a/src/backend/executor/nodeModifyTable.c
8282+++ b/src/backend/executor/nodeModifyTable.c
8383@@ -641,6 +641,13 @@ ExecInitUpdateProjection(ModifyTableState *mtstate,
@@ -94,15 +94,15 @@ index 2f6e66b641..d4a1e48c20 100644
9494 /*
9595 * ExecGetInsertNewTuple
9696 *This prepares a "new" tuple ready to be inserted into given result
97- @@ -3524 ,6 +3531 ,7 @@ ExecModifyTable(PlanState *pstate)
97+ @@ -3581 ,6 +3588 ,7 @@ ExecModifyTable(PlanState *pstate)
9898 HeapTupleData oldtupdata;
9999 HeapTupleoldtuple;
100100 ItemPointer tupleid;
101101+ ResultRelInfo *saved_resultRelInfo;
102102
103103 CHECK_FOR_INTERRUPTS();
104104
105- @@ -3565 ,6 +3573 ,8 @@ ExecModifyTable(PlanState *pstate)
105+ @@ -3622 ,6 +3630 ,8 @@ ExecModifyTable(PlanState *pstate)
106106 context.mtstate = node;
107107 context.epqstate = &node->mt_epqstate;
108108 context.estate = estate;
@@ -111,7 +111,7 @@ index 2f6e66b641..d4a1e48c20 100644
111111
112112 /*
113113 * Fetch rows from subplan, and execute the required table modification
114- @@ -3572 ,6 +3582 ,14 @@ ExecModifyTable(PlanState *pstate)
114+ @@ -3629 ,6 +3639 ,14 @@ ExecModifyTable(PlanState *pstate)
115115 */
116116 for (;;)
117117 {
@@ -126,7 +126,7 @@ index 2f6e66b641..d4a1e48c20 100644
126126 /*
127127 * Reset the per-output-tuple exprcontext. This is needed because
128128 * triggers expect to use that context as workspace. It's a bit ugly
129- @@ -3605 ,7 +3623 ,9 @@ ExecModifyTable(PlanState *pstate)
129+ @@ -3662 ,7 +3680 ,9 @@ ExecModifyTable(PlanState *pstate)
130130 boolisNull;
131131 Oidresultoid;
132132
@@ -137,7 +137,7 @@ index 2f6e66b641..d4a1e48c20 100644
137137 &isNull);
138138 if (isNull)
139139 {
140- @@ -3642 ,6 +3662 ,8 @@ ExecModifyTable(PlanState *pstate)
140+ @@ -3699 ,6 +3719 ,8 @@ ExecModifyTable(PlanState *pstate)
141141 if (resultRelInfo->ri_usesFdwDirectModify)
142142 {
143143 Assert(resultRelInfo->ri_projectReturning);
@@ -146,15 +146,15 @@ index 2f6e66b641..d4a1e48c20 100644
146146
147147 /*
148148 * A scan slot containing the data that was actually inserted,
149- @@ -3651 ,6 +3673 ,7 @@ ExecModifyTable(PlanState *pstate)
149+ @@ -3708 ,6 +3730 ,7 @@ ExecModifyTable(PlanState *pstate)
150150 */
151151 slot = ExecProcessReturning(resultRelInfo, NULL, context.planSlot);
152152
153153+ estate->es_result_relation_info = saved_resultRelInfo;
154154 return slot;
155155 }
156156
157- @@ -3681 ,7 +3704 ,8 @@ ExecModifyTable(PlanState *pstate)
157+ @@ -3738 ,7 +3761 ,8 @@ ExecModifyTable(PlanState *pstate)
158158 {
159159 /* ri_RowIdAttNo refers to a ctid attribute */
160160 Assert(AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo));
@@ -164,7 +164,7 @@ index 2f6e66b641..d4a1e48c20 100644
164164 resultRelInfo->ri_RowIdAttNo,
165165 &isNull);
166166
167- @@ -3729 ,7 +3753 ,8 @@ ExecModifyTable(PlanState *pstate)
167+ @@ -3786 ,7 +3810 ,8 @@ ExecModifyTable(PlanState *pstate)
168168 */
169169 else if (AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
170170 {
@@ -174,7 +174,7 @@ index 2f6e66b641..d4a1e48c20 100644
174174 resultRelInfo->ri_RowIdAttNo,
175175 &isNull);
176176 /* shouldn't ever get a null result... */
177- @@ -3760 ,9 +3785 ,12 @@ ExecModifyTable(PlanState *pstate)
177+ @@ -3817 ,9 +3842 ,12 @@ ExecModifyTable(PlanState *pstate)
178178 /* Initialize projection info if first time for this table */
179179 if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
180180 ExecInitInsertProjection(node, resultRelInfo);
@@ -190,7 +190,7 @@ index 2f6e66b641..d4a1e48c20 100644
190190 break;
191191
192192 case CMD_UPDATE:
193- @@ -3770 ,6 +3798 ,13 @@ ExecModifyTable(PlanState *pstate)
193+ @@ -3827 ,6 +3855 ,13 @@ ExecModifyTable(PlanState *pstate)
194194 if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
195195 ExecInitUpdateProjection(node, resultRelInfo);
196196
@@ -204,7 +204,7 @@ index 2f6e66b641..d4a1e48c20 100644
204204 /*
205205 * Make the new tuple by combining plan's output tuple with
206206 * the old tuple being updated.
207- @@ -3793 ,14 +3828 ,19 @@ ExecModifyTable(PlanState *pstate)
207+ @@ -3850 ,14 +3885 ,19 @@ ExecModifyTable(PlanState *pstate)
208208 slot = ExecGetUpdateNewTuple(resultRelInfo, context.planSlot,
209209 oldSlot);
210210 context.relaction = NULL;
@@ -223,10 +223,10 @@ index 2f6e66b641..d4a1e48c20 100644
223223+ slot = ExecDelete(&context, estate->es_result_relation_info ?
224224+ estate->es_result_relation_info : resultRelInfo,
225225+ tupleid, oldtuple,
226- true, false, node->canSetTag, NULL, NULL);
226+ true, false, node->canSetTag, NULL, NULL, NULL );
227227 break;
228228
229- @@ -3818 ,7 +3858 ,10 @@ ExecModifyTable(PlanState *pstate)
229+ @@ -3875 ,7 +3915 ,10 @@ ExecModifyTable(PlanState *pstate)
230230 * the work on next call.
231231 */
232232 if (slot)
@@ -237,23 +237,23 @@ index 2f6e66b641..d4a1e48c20 100644
237237 }
238238
239239 /*
240- @@ -3834 ,6 +3877 ,7 @@ ExecModifyTable(PlanState *pstate)
240+ @@ -3891 ,6 +3934 ,7 @@ ExecModifyTable(PlanState *pstate)
241241
242242 node->mt_done = true;
243243
244244+ estate->es_result_relation_info = saved_resultRelInfo;
245245 return NULL;
246246 }
247247
248- @@ -3908 ,6 +3952 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
248+ @@ -3965 ,6 +4009 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
249249 ListCell *l;
250250 inti;
251251 Relationrel;
252252+ ResultRelInfo *saved_resultRelInfo;
253253
254254 /* check for unsupported flags */
255255 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
256- @@ -4008 ,6 +4053 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
256+ @@ -4067 ,6 +4112 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
257257 i++;
258258 }
259259
@@ -267,7 +267,7 @@ index 2f6e66b641..d4a1e48c20 100644
267267 /*
268268 * Now we may initialize the subplan.
269269 */
270- @@ -4102 ,6 +4154 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
270+ @@ -4161 ,6 +4213 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
271271 ExecInitStoredGenerated(resultRelInfo, estate, operation);
272272 }
273273
@@ -303,10 +303,10 @@ index 8d46a781bb..150d70cb64 100644
303303
304304 /* flag for logging statements in this transaction */
305305diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
306- index82925b4b63..de23622ca2 100644
306+ index7cd9b2f2bf..b31a7934a4 100644
307307--- a/src/include/executor/executor.h
308308+++ b/src/include/executor/executor.h
309- @@ -659 ,5 +659 ,17 @@ extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
309+ @@ -662 ,5 +662 ,17 @@ extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
310310 Oid resultoid,
311311 bool missing_ok,
312312 bool update_cache);
@@ -325,7 +325,7 @@ index 82925b4b63..de23622ca2 100644
325325
326326 #endif/* EXECUTOR_H */
327327diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
328- indexf34d06eff4..0970e5f110 100644
328+ index9f176b0e37..a65799dcce 100644
329329--- a/src/include/nodes/execnodes.h
330330+++ b/src/include/nodes/execnodes.h
331331@@ -624,6 +624,12 @@ typedef struct EState
@@ -374,7 +374,7 @@ index 8de79c618c..c9226ba5ad 100644
374374
375375 sub CopyIncludeFiles
376376diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
377- indexef0a33c10f..27033b0a45 100644
377+ index990c223a9b..cd5048f8d5 100644
378378--- a/src/tools/msvc/Mkvcbuild.pm
379379+++ b/src/tools/msvc/Mkvcbuild.pm
380380@@ -39,8 +39,8 @@ my $contrib_defines = {};