11diff --git a/contrib/Makefile b/contrib/Makefile
2- indexf27e458482..ea47c341c1 100644
2+ indexf27e458482e..ea47c341c11 100644
33--- a/contrib/Makefile
44+++ b/contrib/Makefile
55@@ -32,6 +32,7 @@ SUBDIRS = \
@@ -11,7 +11,7 @@ index f27e458482..ea47c341c1 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- indexbf551b0395..10d2044ae6 100644
14+ index3f0f711307d..a631b969e25 100644
1515--- a/src/backend/access/transam/xact.c
1616+++ b/src/backend/access/transam/xact.c
1717@@ -76,7 +76,7 @@ intDefaultXactIsoLevel = XACT_READ_COMMITTED;
@@ -24,10 +24,10 @@ index bf551b0395..10d2044ae6 100644
2424 boolDefaultXactDeferrable = false;
2525 boolXactDeferrable;
2626diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
27- indexbdf59a10fc..972453d9a5 100644
27+ index4b31a85a24d..5366e67877a 100644
2828--- a/src/backend/executor/execExprInterp.c
2929+++ b/src/backend/executor/execExprInterp.c
30- @@ -1799 ,6 +1799 ,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
30+ @@ -1811 ,6 +1811 ,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
3131 }
3232
3333 out:
@@ -45,10 +45,10 @@ index bdf59a10fc..972453d9a5 100644
4545 return state->resvalue;
4646 }
4747diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
48- indexb3ce4bae53..8f2bb12542 100644
48+ index5d6410480cd..33a522514d9 100644
4949--- a/src/backend/executor/execMain.c
5050+++ b/src/backend/executor/execMain.c
51- @@ -824 ,6 +824 ,13 @@ InitPlan(QueryDesc *queryDesc, int eflags)
51+ @@ -818 ,6 +818 ,13 @@ InitPlan(QueryDesc *queryDesc, int eflags)
5252
5353 estate->es_plannedstmt = plannedstmt;
5454
@@ -62,7 +62,7 @@ index b3ce4bae53..8f2bb12542 100644
6262 /*
6363 * Next, build the ExecRowMark array from the PlanRowMark(s), if any.
6464 */
65- @@ -2713 ,6 +2720 ,13 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree)
65+ @@ -2777 ,6 +2784 ,13 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree)
6666 rcestate->es_junkFilter = parentestate->es_junkFilter;
6767 rcestate->es_output_cid = parentestate->es_output_cid;
6868
@@ -77,10 +77,10 @@ index b3ce4bae53..8f2bb12542 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- index55c430c9ec..21d9e6304a 100644
80+ indexae1b07847b1..989ba4f7b11 100644
8181--- a/src/backend/executor/nodeModifyTable.c
8282+++ b/src/backend/executor/nodeModifyTable.c
83- @@ -510 ,7 +510 ,7 @@ ExecInitInsertProjection(ModifyTableState *mtstate,
83+ @@ -538 ,7 +538 ,7 @@ ExecInitInsertProjection(ModifyTableState *mtstate,
8484 * This is also a convenient place to verify that the output of an UPDATE
8585 * matches the target table (ExecBuildUpdateProjection does that).
8686 */
@@ -89,15 +89,15 @@ index 55c430c9ec..21d9e6304a 100644
8989 ExecInitUpdateProjection(ModifyTableState *mtstate,
9090 ResultRelInfo *resultRelInfo)
9191 {
92- @@ -2486,6 +2486,7 @@ ExecModifyTable(PlanState *pstate)
93- ItemPointerData tuple_ctid;
92+ @@ -2541,6 +2541,7 @@ ExecModifyTable(PlanState *pstate)
9493 HeapTupleData oldtupdata;
9594 HeapTupleoldtuple;
95+ booltuplock;
9696+ ResultRelInfo *saved_resultRelInfo;
9797
9898 CHECK_FOR_INTERRUPTS();
9999
100- @@ -2523 ,12 +2524 ,23 @@ ExecModifyTable(PlanState *pstate)
100+ @@ -2578 ,12 +2579 ,23 @@ ExecModifyTable(PlanState *pstate)
101101 resultRelInfo = node->resultRelInfo + node->mt_lastResultIndex;
102102 subplanstate = outerPlanState(node);
103103
@@ -121,7 +121,7 @@ index 55c430c9ec..21d9e6304a 100644
121121 /*
122122 * Reset the per-output-tuple exprcontext. This is needed because
123123 * triggers expect to use that context as workspace. It's a bit ugly
124- @@ -2562 ,7 +2574 ,9 @@ ExecModifyTable(PlanState *pstate)
124+ @@ -2617 ,7 +2629 ,9 @@ ExecModifyTable(PlanState *pstate)
125125 boolisNull;
126126 Oidresultoid;
127127
@@ -132,7 +132,7 @@ index 55c430c9ec..21d9e6304a 100644
132132 &isNull);
133133 if (isNull)
134134 elog(ERROR, "tableoid is NULL");
135- @@ -2581 ,6 +2595 ,8 @@ ExecModifyTable(PlanState *pstate)
135+ @@ -2636 ,6 +2650 ,8 @@ ExecModifyTable(PlanState *pstate)
136136 if (resultRelInfo->ri_usesFdwDirectModify)
137137 {
138138 Assert(resultRelInfo->ri_projectReturning);
@@ -141,15 +141,15 @@ index 55c430c9ec..21d9e6304a 100644
141141
142142 /*
143143 * A scan slot containing the data that was actually inserted,
144- @@ -2590 ,6 +2606 ,7 @@ ExecModifyTable(PlanState *pstate)
144+ @@ -2645 ,6 +2661 ,7 @@ ExecModifyTable(PlanState *pstate)
145145 */
146146 slot = ExecProcessReturning(resultRelInfo, NULL, planSlot);
147147
148148+ estate->es_result_relation_info = saved_resultRelInfo;
149149 return slot;
150150 }
151151
152- @@ -2619 ,7 +2636 ,8 @@ ExecModifyTable(PlanState *pstate)
152+ @@ -2674 ,7 +2691 ,8 @@ ExecModifyTable(PlanState *pstate)
153153 {
154154 /* ri_RowIdAttNo refers to a ctid attribute */
155155 Assert(AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo));
@@ -159,7 +159,7 @@ index 55c430c9ec..21d9e6304a 100644
159159 resultRelInfo->ri_RowIdAttNo,
160160 &isNull);
161161 /* shouldn't ever get a null result... */
162- @@ -2649 ,7 +2667 ,8 @@ ExecModifyTable(PlanState *pstate)
162+ @@ -2704 ,7 +2722 ,8 @@ ExecModifyTable(PlanState *pstate)
163163 */
164164 else if (AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
165165 {
@@ -169,7 +169,7 @@ index 55c430c9ec..21d9e6304a 100644
169169 resultRelInfo->ri_RowIdAttNo,
170170 &isNull);
171171 /* shouldn't ever get a null result... */
172- @@ -2680 ,8 +2699 ,12 @@ ExecModifyTable(PlanState *pstate)
172+ @@ -2735 ,8 +2754 ,12 @@ ExecModifyTable(PlanState *pstate)
173173 /* Initialize projection info if first time for this table */
174174 if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
175175 ExecInitInsertProjection(node, resultRelInfo);
@@ -184,7 +184,7 @@ index 55c430c9ec..21d9e6304a 100644
184184 estate, node->canSetTag);
185185 break;
186186 case CMD_UPDATE:
187- @@ -2689 ,6 +2712 ,13 @@ ExecModifyTable(PlanState *pstate)
187+ @@ -2746 ,6 +2769 ,13 @@ ExecModifyTable(PlanState *pstate)
188188 if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
189189 ExecInitUpdateProjection(node, resultRelInfo);
190190
@@ -198,7 +198,7 @@ index 55c430c9ec..21d9e6304a 100644
198198 /*
199199 * Make the new tuple by combining plan's output tuple with
200200 * the old tuple being updated.
201- @@ -2712,14 +2742,19 @@ ExecModifyTable(PlanState *pstate)
201+ @@ -2775,9 +2805,12 @@ ExecModifyTable(PlanState *pstate)
202202 }
203203 slot = ExecGetUpdateNewTuple(resultRelInfo, planSlot,
204204 oldSlot);
@@ -211,6 +211,9 @@ index 55c430c9ec..21d9e6304a 100644
211211+ tupleid, oldtuple, slot,
212212 planSlot, &node->mt_epqstate, estate,
213213 node->canSetTag);
214+ if (tuplock)
215+ @@ -2785,7 +2818,9 @@ ExecModifyTable(PlanState *pstate)
216+ InplaceUpdateTupleLock);
214217 break;
215218 case CMD_DELETE:
216219- slot = ExecDelete(node, resultRelInfo, tupleid, oldtuple,
@@ -220,7 +223,7 @@ index 55c430c9ec..21d9e6304a 100644
220223 planSlot, &node->mt_epqstate, estate,
221224 true, /* processReturning */
222225 node->canSetTag,
223- @@ -2736 ,7 +2771 ,10 @@ ExecModifyTable(PlanState *pstate)
226+ @@ -2802 ,7 +2837 ,10 @@ ExecModifyTable(PlanState *pstate)
224227 * the work on next call.
225228 */
226229 if (slot)
@@ -231,23 +234,23 @@ index 55c430c9ec..21d9e6304a 100644
231234 }
232235
233236 /*
234- @@ -2752 ,6 +2790 ,7 @@ ExecModifyTable(PlanState *pstate)
237+ @@ -2818 ,6 +2856 ,7 @@ ExecModifyTable(PlanState *pstate)
235238
236239 node->mt_done = true;
237240
238241+ estate->es_result_relation_info = saved_resultRelInfo;
239242 return NULL;
240243 }
241244
242- @@ -2826 ,6 +2865 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
245+ @@ -2892 ,6 +2931 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
243246 ListCell *l;
244247 inti;
245248 Relationrel;
246249+ ResultRelInfo *saved_resultRelInfo;
247250
248251 /* check for unsupported flags */
249252 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
250- @@ -2922 ,6 +2962 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
253+ @@ -2991 ,6 +3031 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
251254 i++;
252255 }
253256
@@ -261,7 +264,7 @@ index 55c430c9ec..21d9e6304a 100644
261264 /*
262265 * Now we may initialize the subplan.
263266 */
264- @@ -3002 ,6 +3049 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
267+ @@ -3071 ,6 +3118 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
265268 ExecInitStoredGenerated(resultRelInfo, estate, operation);
266269 }
267270
@@ -271,7 +274,7 @@ index 55c430c9ec..21d9e6304a 100644
271274 * If this is an inherited update/delete, there will be a junk attribute
272275 * named "tableoid" present in the subplan's targetlist. It will be used
273276diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
274- index381d9e548d..0a4657d291 100644
277+ index381d9e548d1..0a4657d2915 100644
275278--- a/src/backend/utils/init/globals.c
276279+++ b/src/backend/utils/init/globals.c
277280@@ -25,7 +25,7 @@
@@ -284,7 +287,7 @@ index 381d9e548d..0a4657d291 100644
284287 volatile sig_atomic_t InterruptPending = false;
285288 volatile sig_atomic_t QueryCancelPending = false;
286289diff --git a/src/include/access/xact.h b/src/include/access/xact.h
287- index5af78bd0dc..0c13bc9d83 100644
290+ index5af78bd0dc7..0c13bc9d83b 100644
288291--- a/src/include/access/xact.h
289292+++ b/src/include/access/xact.h
290293@@ -53,7 +53,9 @@ extern PGDLLIMPORT int XactIsoLevel;
@@ -299,7 +302,7 @@ index 5af78bd0dc..0c13bc9d83 100644
299302 /* flag for logging statements in this transaction */
300303 extern bool xact_is_sampled;
301304diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
302- index2b4e104bb9..80d1274efe 100644
305+ index3903e7a6f2e..49509a56c2d 100644
303306--- a/src/include/catalog/objectaddress.h
304307+++ b/src/include/catalog/objectaddress.h
305308@@ -28,7 +28,7 @@ typedef struct ObjectAddress
@@ -312,10 +315,10 @@ index 2b4e104bb9..80d1274efe 100644
312315 #define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id) \
313316 do { \
314317diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
315- index3dc03c913e..1002d97499 100644
318+ index4bb1744286a..af86e081918 100644
316319--- a/src/include/executor/executor.h
317320+++ b/src/include/executor/executor.h
318- @@ -657 ,5 +657 ,7 @@ extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
321+ @@ -663 ,5 +663 ,7 @@ extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
319322 Oid resultoid,
320323 bool missing_ok,
321324 bool update_cache);
@@ -324,7 +327,7 @@ index 3dc03c913e..1002d97499 100644
324327
325328 #endif/* EXECUTOR_H */
326329diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
327- index4acb1cda6e..fd8d38347d 100644
330+ index4acb1cda6ea..fd8d38347d3 100644
328331--- a/src/include/libpq/libpq-be.h
329332+++ b/src/include/libpq/libpq-be.h
330333@@ -327,7 +327,7 @@ extern ssize_t be_gssapi_read(Port *port, void *ptr, size_t len);
@@ -337,10 +340,10 @@ index 4acb1cda6e..fd8d38347d 100644
337340 /* TCP keepalives configuration. These are no-ops on an AF_UNIX socket. */
338341
339342diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
340- indexee5ad3c058..dc474819d7 100644
343+ index801d7630e9d..400814f0618 100644
341344--- a/src/include/nodes/execnodes.h
342345+++ b/src/include/nodes/execnodes.h
343- @@ -592 ,6 +592 ,12 @@ typedef struct EState
346+ @@ -593 ,6 +593 ,12 @@ typedef struct EState
344347 * es_result_relations in no
345348 * specific order */
346349
@@ -354,7 +357,7 @@ index ee5ad3c058..dc474819d7 100644
354357
355358 /*
356359diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
357- index33e6c14e81..abd9bba23e 100644
360+ index33e6c14e819..abd9bba23e3 100644
358361--- a/src/include/utils/snapmgr.h
359362+++ b/src/include/utils/snapmgr.h
360363@@ -53,7 +53,7 @@ extern TimestampTz GetSnapshotCurrentTimestamp(void);
@@ -367,7 +370,7 @@ index 33e6c14e81..abd9bba23e 100644
367370 extern PGDLLIMPORT TransactionId TransactionXmin;
368371 extern PGDLLIMPORT TransactionId RecentXmin;
369372diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
370- indexde22c9ba2c..c8be5323b8 100644
373+ indexde22c9ba2c7..c8be5323b8f 100644
371374--- a/src/tools/msvc/Install.pm
372375+++ b/src/tools/msvc/Install.pm
373376@@ -30,6 +30,18 @@ my @client_program_files = (
@@ -399,7 +402,7 @@ index de22c9ba2c..c8be5323b8 100644
399402
400403 sub CopyIncludeFiles
401404diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
402- index9b6539fb15..f8a67c6701 100644
405+ index43880a0a34c..ce7b8f7ac72 100644
403406--- a/src/tools/msvc/Mkvcbuild.pm
404407+++ b/src/tools/msvc/Mkvcbuild.pm
405408@@ -41,7 +41,10 @@ my @contrib_uselibpq =
@@ -414,15 +417,15 @@ index 9b6539fb15..f8a67c6701 100644
414417 my $contrib_extrasource = {
415418 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
416419 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
417- @@ -973 ,6 +976 ,7 @@ sub AddContrib
420+ @@ -977 ,6 +980 ,7 @@ sub AddContrib
418421 my $dn = $1;
419422 my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
420423 $proj->AddReference($postgres);
421424+ $proj->RemoveFile("$subdir/$n/src/declarative.c") if $n eq 'pg_pathman';
422425 AdjustContribProj($proj);
423426 }
424427 elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
425- @@ -1002 ,6 +1006 ,19 @@ sub AddContrib
428+ @@ -1006 ,6 +1010 ,19 @@ sub AddContrib
426429 return;
427430 }
428431
@@ -442,7 +445,7 @@ index 9b6539fb15..f8a67c6701 100644
442445 sub GenerateContribSqlFiles
443446 {
444447 my $n = shift;
445- @@ -1026 ,23 +1043 ,53 @@ sub GenerateContribSqlFiles
448+ @@ -1030 ,23 +1047 ,53 @@ sub GenerateContribSqlFiles
446449 substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i + 1);
447450 }
448451