@@ -24,7 +24,7 @@ index bf551b0395..10d2044ae6 100644
24
24
bool DefaultXactDeferrable = false;
25
25
bool XactDeferrable;
26
26
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
27
- index 6b63f93e6d..060146d127 100644
27
+ index bdf59a10fc..972453d9a5 100644
28
28
--- a/src/backend/executor/execExprInterp.c
29
29
+++ b/src/backend/executor/execExprInterp.c
30
30
@@ -1799,6 +1799,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
@@ -77,7 +77,7 @@ index b3ce4bae53..8f2bb12542 100644
77
77
* ResultRelInfos needed by subplans are initialized from scratch when the
78
78
* subplans themselves are initialized.
79
79
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
80
- index 0780554246..a90f3a495d 100644
80
+ index 55c430c9ec..21d9e6304a 100644
81
81
--- a/src/backend/executor/nodeModifyTable.c
82
82
+++ b/src/backend/executor/nodeModifyTable.c
83
83
@@ -510,7 +510,7 @@ ExecInitInsertProjection(ModifyTableState *mtstate,
@@ -89,15 +89,15 @@ index 0780554246..a90f3a495d 100644
89
89
ExecInitUpdateProjection(ModifyTableState *mtstate,
90
90
ResultRelInfo *resultRelInfo)
91
91
{
92
- @@ -2487 ,6 +2487 ,7 @@ ExecModifyTable(PlanState *pstate)
92
+ @@ -2486 ,6 +2486 ,7 @@ ExecModifyTable(PlanState *pstate)
93
93
ItemPointerData tuple_ctid;
94
94
HeapTupleData oldtupdata;
95
95
HeapTuple oldtuple;
96
96
+ ResultRelInfo *saved_resultRelInfo;
97
97
98
98
CHECK_FOR_INTERRUPTS();
99
99
100
- @@ -2524 ,12 +2525 ,23 @@ ExecModifyTable(PlanState *pstate)
100
+ @@ -2523 ,12 +2524 ,23 @@ ExecModifyTable(PlanState *pstate)
101
101
resultRelInfo = node->resultRelInfo + node->mt_lastResultIndex;
102
102
subplanstate = outerPlanState(node);
103
103
@@ -121,7 +121,7 @@ index 0780554246..a90f3a495d 100644
121
121
/*
122
122
* Reset the per-output-tuple exprcontext. This is needed because
123
123
* triggers expect to use that context as workspace. It's a bit ugly
124
- @@ -2563 ,7 +2575 ,9 @@ ExecModifyTable(PlanState *pstate)
124
+ @@ -2562 ,7 +2574 ,9 @@ ExecModifyTable(PlanState *pstate)
125
125
bool isNull;
126
126
Oid resultoid;
127
127
@@ -132,7 +132,7 @@ index 0780554246..a90f3a495d 100644
132
132
&isNull);
133
133
if (isNull)
134
134
elog(ERROR, "tableoid is NULL");
135
- @@ -2582 ,6 +2596 ,8 @@ ExecModifyTable(PlanState *pstate)
135
+ @@ -2581 ,6 +2595 ,8 @@ ExecModifyTable(PlanState *pstate)
136
136
if (resultRelInfo->ri_usesFdwDirectModify)
137
137
{
138
138
Assert(resultRelInfo->ri_projectReturning);
@@ -141,15 +141,15 @@ index 0780554246..a90f3a495d 100644
141
141
142
142
/*
143
143
* A scan slot containing the data that was actually inserted,
144
- @@ -2591 ,6 +2607 ,7 @@ ExecModifyTable(PlanState *pstate)
144
+ @@ -2590 ,6 +2606 ,7 @@ ExecModifyTable(PlanState *pstate)
145
145
*/
146
146
slot = ExecProcessReturning(resultRelInfo, NULL, planSlot);
147
147
148
148
+ estate->es_result_relation_info = saved_resultRelInfo;
149
149
return slot;
150
150
}
151
151
152
- @@ -2620 ,7 +2637 ,8 @@ ExecModifyTable(PlanState *pstate)
152
+ @@ -2619 ,7 +2636 ,8 @@ ExecModifyTable(PlanState *pstate)
153
153
{
154
154
/* ri_RowIdAttNo refers to a ctid attribute */
155
155
Assert(AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo));
@@ -159,7 +159,7 @@ index 0780554246..a90f3a495d 100644
159
159
resultRelInfo->ri_RowIdAttNo,
160
160
&isNull);
161
161
/* shouldn't ever get a null result... */
162
- @@ -2650 ,7 +2668 ,8 @@ ExecModifyTable(PlanState *pstate)
162
+ @@ -2649 ,7 +2667 ,8 @@ ExecModifyTable(PlanState *pstate)
163
163
*/
164
164
else if (AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
165
165
{
@@ -169,7 +169,7 @@ index 0780554246..a90f3a495d 100644
169
169
resultRelInfo->ri_RowIdAttNo,
170
170
&isNull);
171
171
/* shouldn't ever get a null result... */
172
- @@ -2681 ,8 +2700 ,12 @@ ExecModifyTable(PlanState *pstate)
172
+ @@ -2680 ,8 +2699 ,12 @@ ExecModifyTable(PlanState *pstate)
173
173
/* Initialize projection info if first time for this table */
174
174
if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
175
175
ExecInitInsertProjection(node, resultRelInfo);
@@ -184,58 +184,25 @@ index 0780554246..a90f3a495d 100644
184
184
estate, node->canSetTag);
185
185
break;
186
186
case CMD_UPDATE:
187
- @@ -2690,37 +2713,45 @@ ExecModifyTable(PlanState *pstate)
187
+ @@ -2689,6 +2712,13 @@ ExecModifyTable(PlanState *pstate)
188
188
if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
189
189
ExecInitUpdateProjection(node, resultRelInfo);
190
190
191
- - /*
192
- - * Make the new tuple by combining plan's output tuple with
193
- - * the old tuple being updated.
194
- - */
195
- - oldSlot = resultRelInfo->ri_oldTupleSlot;
196
- - if (oldtuple != NULL)
197
- - {
198
- - /* Use the wholerow junk attr as the old tuple. */
199
- - ExecForceStoreHeapTuple(oldtuple, oldSlot, false);
200
- - }
201
- - else
191
+ + /*
192
+ + * Do not change the indentation for PostgreSQL code to make it
193
+ + * easier to merge new PostgreSQL changes.
194
+ + */
202
195
+ /* Do nothing in case tuple was modified in pg_pathman: */
203
196
+ if (!estate->es_original_tuple)
204
- {
205
- - /* Fetch the most recent version of old tuple. */
206
- - Relation relation = resultRelInfo->ri_RelationDesc;
207
- -
208
- - Assert(tupleid != NULL);
209
- - if (!table_tuple_fetch_row_version(relation, tupleid,
210
- - SnapshotAny,
211
- - oldSlot))
212
- - elog(ERROR, "failed to fetch tuple being updated");
213
- + /*
214
- + * Make the new tuple by combining plan's output tuple
215
- + * with the old tuple being updated.
216
- + */
217
- + oldSlot = resultRelInfo->ri_oldTupleSlot;
218
- + if (oldtuple != NULL)
219
- + {
220
- + /* Use the wholerow junk attr as the old tuple. */
221
- + ExecForceStoreHeapTuple(oldtuple, oldSlot, false);
222
- + }
223
- + else
224
- + {
225
- + /* Fetch the most recent version of old tuple. */
226
- + Relation relation = resultRelInfo->ri_RelationDesc;
227
- +
228
- + Assert(tupleid != NULL);
229
- + if (!table_tuple_fetch_row_version(relation, tupleid,
230
- + SnapshotAny,
231
- + oldSlot))
232
- + elog(ERROR, "failed to fetch tuple being updated");
233
- + }
234
- + slot = ExecGetUpdateNewTuple(resultRelInfo, planSlot,
235
- + oldSlot);
197
+ + {
198
+ /*
199
+ * Make the new tuple by combining plan's output tuple with
200
+ * the old tuple being updated.
201
+ @@ -2712,14 +2742,19 @@ ExecModifyTable(PlanState *pstate)
236
202
}
237
- - slot = ExecGetUpdateNewTuple(resultRelInfo, planSlot,
238
- - oldSlot);
203
+ slot = ExecGetUpdateNewTuple(resultRelInfo, planSlot,
204
+ oldSlot);
205
+ + }
239
206
240
207
/* Now apply the update. */
241
208
- slot = ExecUpdate(node, resultRelInfo, tupleid, oldtuple, slot,
@@ -253,7 +220,7 @@ index 0780554246..a90f3a495d 100644
253
220
planSlot, &node->mt_epqstate, estate,
254
221
true, /* processReturning */
255
222
node->canSetTag,
256
- @@ -2737 ,7 +2768 ,10 @@ ExecModifyTable(PlanState *pstate)
223
+ @@ -2736 ,7 +2771 ,10 @@ ExecModifyTable(PlanState *pstate)
257
224
* the work on next call.
258
225
*/
259
226
if (slot)
@@ -264,23 +231,23 @@ index 0780554246..a90f3a495d 100644
264
231
}
265
232
266
233
/*
267
- @@ -2753 ,6 +2787 ,7 @@ ExecModifyTable(PlanState *pstate)
234
+ @@ -2752 ,6 +2790 ,7 @@ ExecModifyTable(PlanState *pstate)
268
235
269
236
node->mt_done = true;
270
237
271
238
+ estate->es_result_relation_info = saved_resultRelInfo;
272
239
return NULL;
273
240
}
274
241
275
- @@ -2827 ,6 +2862 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
242
+ @@ -2826 ,6 +2865 ,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
276
243
ListCell *l;
277
244
int i;
278
245
Relation rel;
279
246
+ ResultRelInfo *saved_resultRelInfo;
280
247
281
248
/* check for unsupported flags */
282
249
Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
283
- @@ -2923 ,6 +2959 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
250
+ @@ -2922 ,6 +2962 ,13 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
284
251
i++;
285
252
}
286
253
@@ -294,7 +261,7 @@ index 0780554246..a90f3a495d 100644
294
261
/*
295
262
* Now we may initialize the subplan.
296
263
*/
297
- @@ -3004 ,6 +3047 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
264
+ @@ -3002 ,6 +3049 ,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
298
265
ExecInitStoredGenerated(resultRelInfo, estate, operation);
299
266
}
300
267
@@ -386,6 +353,19 @@ index ee5ad3c058..dc474819d7 100644
386
353
PartitionDirectory es_partition_directory; /* for PartitionDesc lookup */
387
354
388
355
/*
356
+ diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
357
+ index 33e6c14e81..abd9bba23e 100644
358
+ --- a/src/include/utils/snapmgr.h
359
+ +++ b/src/include/utils/snapmgr.h
360
+ @@ -53,7 +53,7 @@ extern TimestampTz GetSnapshotCurrentTimestamp(void);
361
+ extern TimestampTz GetOldSnapshotThresholdTimestamp(void);
362
+ extern void SnapshotTooOldMagicForTest(void);
363
+
364
+ - extern bool FirstSnapshotSet;
365
+ + extern PGDLLIMPORT bool FirstSnapshotSet;
366
+
367
+ extern PGDLLIMPORT TransactionId TransactionXmin;
368
+ extern PGDLLIMPORT TransactionId RecentXmin;
389
369
diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
390
370
index de22c9ba2c..c8be5323b8 100644
391
371
--- a/src/tools/msvc/Install.pm
0 commit comments