11diff --git a/contrib/Makefile b/contrib/Makefile
2- index bbf220407b..9a82a2db04 100644
2+ index bbf220407b0..9a82a2db046 100644
33--- a/contrib/Makefile
44+++ b/contrib/Makefile
55@@ -34,6 +34,7 @@ SUBDIRS = \
@@ -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- index 47d80b0d25..6689776769 100644
14+ index 594d8da2cdc..a2049e70e95 100644
1515--- a/src/backend/access/transam/xact.c
1616+++ b/src/backend/access/transam/xact.c
1717@@ -78,7 +78,7 @@ int DefaultXactIsoLevel = XACT_READ_COMMITTED;
@@ -24,10 +24,10 @@ index 47d80b0d25..6689776769 100644
2424 bool DefaultXactDeferrable = false;
2525 bool XactDeferrable;
2626diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
27- index e44ad68cda..b9ba79e756 100644
27+ index ef0f9577ab1..95858960d50 100644
2828--- a/src/backend/executor/execExprInterp.c
2929+++ b/src/backend/executor/execExprInterp.c
30- @@ -1831 ,6 +1831 ,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
30+ @@ -1801 ,6 +1801 ,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
3131 }
3232
3333 out:
@@ -45,7 +45,7 @@ index e44ad68cda..b9ba79e756 100644
4545 return state->resvalue;
4646 }
4747diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
48- index ef2fd46092..8551733c55 100644
48+ index ef2fd46092e..8551733c55d 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)
@@ -77,27 +77,32 @@ 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- index a49c3da5b6..2c0b32e2df 100644
80+ index 04454ad6e60..6a52e86b782 100644
8181--- a/src/backend/executor/nodeModifyTable.c
8282+++ b/src/backend/executor/nodeModifyTable.c
83- @@ -551,7 +551,7 @@ ExecInitInsertProjection(ModifyTableState *mtstate,
84- * This is also a convenient place to verify that the output of an UPDATE
85- * matches the target table (ExecBuildUpdateProjection does that).
86- */
87- - static void
83+ @@ -603,6 +603,13 @@ ExecInitUpdateProjection(ModifyTableState *mtstate,
84+ resultRelInfo->ri_projectNewInfoValid = true;
85+ }
86+
8887+ void
89- ExecInitUpdateProjection(ModifyTableState *mtstate,
90- ResultRelInfo *resultRelInfo)
91- {
92- @@ -3460,6 +3460,7 @@ ExecModifyTable(PlanState *pstate)
88+ + PgproExecInitUpdateProjection(ModifyTableState *mtstate,
89+ + ResultRelInfo *resultRelInfo)
90+ + {
91+ + ExecInitUpdateProjection(mtstate, resultRelInfo);
92+ + }
93+ +
94+ /*
95+ * ExecGetInsertNewTuple
96+ * This prepares a "new" tuple ready to be inserted into given result
97+ @@ -3461,6 +3468,7 @@ ExecModifyTable(PlanState *pstate)
9398 PartitionTupleRouting *proute = node->mt_partition_tuple_routing;
9499 List *relinfos = NIL;
95100 ListCell *lc;
96101+ ResultRelInfo *saved_resultRelInfo;
97102
98103 CHECK_FOR_INTERRUPTS();
99104
100- @@ -3501 ,6 +3502 ,8 @@ ExecModifyTable(PlanState *pstate)
105+ @@ -3502 ,6 +3510 ,8 @@ ExecModifyTable(PlanState *pstate)
101106 context.mtstate = node;
102107 context.epqstate = &node->mt_epqstate;
103108 context.estate = estate;
@@ -106,7 +111,7 @@ index a49c3da5b6..2c0b32e2df 100644
106111
107112 /*
108113 * Fetch rows from subplan, and execute the required table modification
109- @@ -3508 ,6 +3511 ,14 @@ ExecModifyTable(PlanState *pstate)
114+ @@ -3509 ,6 +3519 ,14 @@ ExecModifyTable(PlanState *pstate)
110115 */
111116 for (;;)
112117 {
@@ -121,7 +126,7 @@ index a49c3da5b6..2c0b32e2df 100644
121126 /*
122127 * Reset the per-output-tuple exprcontext. This is needed because
123128 * triggers expect to use that context as workspace. It's a bit ugly
124- @@ -3541 ,7 +3552 ,9 @@ ExecModifyTable(PlanState *pstate)
129+ @@ -3542 ,7 +3560 ,9 @@ ExecModifyTable(PlanState *pstate)
125130 bool isNull;
126131 Oid resultoid;
127132
@@ -132,7 +137,7 @@ index a49c3da5b6..2c0b32e2df 100644
132137 &isNull);
133138 if (isNull)
134139 {
135- @@ -3578 ,6 +3591 ,8 @@ ExecModifyTable(PlanState *pstate)
140+ @@ -3579 ,6 +3599 ,8 @@ ExecModifyTable(PlanState *pstate)
136141 if (resultRelInfo->ri_usesFdwDirectModify)
137142 {
138143 Assert(resultRelInfo->ri_projectReturning);
@@ -141,15 +146,15 @@ index a49c3da5b6..2c0b32e2df 100644
141146
142147 /*
143148 * A scan slot containing the data that was actually inserted,
144- @@ -3587 ,6 +3602 ,7 @@ ExecModifyTable(PlanState *pstate)
149+ @@ -3588 ,6 +3610 ,7 @@ ExecModifyTable(PlanState *pstate)
145150 */
146151 slot = ExecProcessReturning(resultRelInfo, NULL, context.planSlot);
147152
148153+ estate->es_result_relation_info = saved_resultRelInfo;
149154 return slot;
150155 }
151156
152- @@ -3617 ,7 +3633 ,8 @@ ExecModifyTable(PlanState *pstate)
157+ @@ -3618 ,7 +3641 ,8 @@ ExecModifyTable(PlanState *pstate)
153158 {
154159 /* ri_RowIdAttNo refers to a ctid attribute */
155160 Assert(AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo));
@@ -159,7 +164,7 @@ index a49c3da5b6..2c0b32e2df 100644
159164 resultRelInfo->ri_RowIdAttNo,
160165 &isNull);
161166
162- @@ -3665 ,7 +3682 ,8 @@ ExecModifyTable(PlanState *pstate)
167+ @@ -3666 ,7 +3690 ,8 @@ ExecModifyTable(PlanState *pstate)
163168 */
164169 else if (AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
165170 {
@@ -169,7 +174,7 @@ index a49c3da5b6..2c0b32e2df 100644
169174 resultRelInfo->ri_RowIdAttNo,
170175 &isNull);
171176 /* shouldn't ever get a null result... */
172- @@ -3696 ,9 +3714 ,12 @@ ExecModifyTable(PlanState *pstate)
177+ @@ -3697 ,9 +3722 ,12 @@ ExecModifyTable(PlanState *pstate)
173178 /* Initialize projection info if first time for this table */
174179 if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
175180 ExecInitInsertProjection(node, resultRelInfo);
@@ -185,7 +190,7 @@ index a49c3da5b6..2c0b32e2df 100644
185190 break;
186191
187192 case CMD_UPDATE:
188- @@ -3706 ,38 +3727 ,46 @@ ExecModifyTable(PlanState *pstate)
193+ @@ -3707 ,38 +3735 ,46 @@ ExecModifyTable(PlanState *pstate)
189194 if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
190195 ExecInitUpdateProjection(node, resultRelInfo);
191196
@@ -255,7 +260,7 @@ index a49c3da5b6..2c0b32e2df 100644
255260 true, false, node->canSetTag, NULL, NULL);
256261 break;
257262
258- @@ -3755 ,7 +3784 ,10 @@ ExecModifyTable(PlanState *pstate)
263+ @@ -3756 ,7 +3792 ,10 @@ ExecModifyTable(PlanState *pstate)
259264 * the work on next call.
260265 */
261266 if (slot)
@@ -266,23 +271,23 @@ index a49c3da5b6..2c0b32e2df 100644
266271 }
267272
268273 /*
269- @@ -3784 ,6 +3816 ,7 @@ ExecModifyTable(PlanState *pstate)
274+ @@ -3785 ,6 +3824 ,7 @@ ExecModifyTable(PlanState *pstate)
270275
271276 node->mt_done = true;
272277
273278+ estate->es_result_relation_info = saved_resultRelInfo;
274279 return NULL;
275280 }
276281
277- @@ -3858 ,6 +3891 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
282+ @@ -3859 ,6 +3899 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
278283 ListCell *l;
279284 int i;
280285 Relation rel;
281286+ ResultRelInfo *saved_resultRelInfo;
282287
283288 /* check for unsupported flags */
284289 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
285- @@ -3958 ,6 +3992 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
290+ @@ -3959 ,6 +4000 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
286291 i++;
287292 }
288293
@@ -296,7 +301,7 @@ index a49c3da5b6..2c0b32e2df 100644
296301 /*
297302 * Now we may initialize the subplan.
298303 */
299- @@ -4040 ,6 +4081 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
304+ @@ -4041 ,6 +4089 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
300305 }
301306 }
302307
@@ -306,7 +311,7 @@ index a49c3da5b6..2c0b32e2df 100644
306311 * If this is an inherited update/delete/merge, there will be a junk
307312 * attribute named "tableoid" present in the subplan's targetlist. It
308313diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
309- index 1a5d29ac9b..c70e3ff8b8 100644
314+ index 1a5d29ac9ba..aadca8ea474 100644
310315--- a/src/backend/utils/init/globals.c
311316+++ b/src/backend/utils/init/globals.c
312317@@ -25,7 +25,7 @@
@@ -319,7 +324,7 @@ index 1a5d29ac9b..c70e3ff8b8 100644
319324 volatile sig_atomic_t InterruptPending = false;
320325 volatile sig_atomic_t QueryCancelPending = false;
321326diff --git a/src/include/access/xact.h b/src/include/access/xact.h
322- index 4794941df3..483050268e 100644
327+ index 65616ca2f79..965eb544217 100644
323328--- a/src/include/access/xact.h
324329+++ b/src/include/access/xact.h
325330@@ -53,6 +53,8 @@ extern PGDLLIMPORT int XactIsoLevel;
@@ -332,19 +337,29 @@ index 4794941df3..483050268e 100644
332337
333338 /* flag for logging statements in this transaction */
334339diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
335- index d68a6b9d28..a96eb93316 100644
340+ index 82925b4b633..de23622ca24 100644
336341--- a/src/include/executor/executor.h
337342+++ b/src/include/executor/executor.h
338- @@ -661 ,5 +661,7 @@ extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
343+ @@ -659 ,5 +659,17 @@ extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
339344 Oid resultoid,
340345 bool missing_ok,
341346 bool update_cache);
342- + extern void ExecInitUpdateProjection(ModifyTableState *mtstate,
343- + ResultRelInfo *resultRelInfo);
347+ + #define PG_HAVE_PGPRO_EXEC_INIT_UPDATE_PROJECTION
348+ + /*
349+ + * This function is static in vanilla, but pg_pathman wants it exported.
350+ + * We cannot make it extern with the same name to avoid compilation errors
351+ + * in timescaledb, which ships it's own static copy of the same function.
352+ + * So, export ExecInitUpdateProjection with Pgpro prefix.
353+ + *
354+ + * The define above helps pg_pathman to expect proper exported symbol
355+ + * from various versions of pgpro.
356+ + */
357+ + extern void PgproExecInitUpdateProjection(ModifyTableState *mtstate,
358+ + ResultRelInfo *resultRelInfo);
344359
345360 #endif /* EXECUTOR_H */
346361diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
347- index 5728801379..ec5496afff 100644
362+ index 57288013795..ec5496afffa 100644
348363--- a/src/include/nodes/execnodes.h
349364+++ b/src/include/nodes/execnodes.h
350365@@ -611,6 +611,12 @@ typedef struct EState
@@ -361,7 +376,7 @@ index 5728801379..ec5496afff 100644
361376
362377 /*
363378diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
364- index 8de79c618c..c9226ba5ad 100644
379+ index 8de79c618cb..c9226ba5ad4 100644
365380--- a/src/tools/msvc/Install.pm
366381+++ b/src/tools/msvc/Install.pm
367382@@ -30,6 +30,18 @@ my @client_program_files = (
@@ -393,7 +408,7 @@ index 8de79c618c..c9226ba5ad 100644
393408
394409 sub CopyIncludeFiles
395410diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
396- index e4feda10fd..74a0a0a062 100644
411+ index e4feda10fd8..74a0a0a062b 100644
397412--- a/src/tools/msvc/Mkvcbuild.pm
398413+++ b/src/tools/msvc/Mkvcbuild.pm
399414@@ -39,8 +39,8 @@ my $contrib_defines = {};
0 commit comments