@@ -1559,22 +1559,6 @@ ExecDelete(ModifyTableContext *context,
1559
1559
{
1560
1560
case TM_Ok :
1561
1561
Assert (context -> tmfd .traversed );
1562
-
1563
- /*
1564
- * Save locked tuple for further processing of
1565
- * RETURNING clause.
1566
- */
1567
- if (processReturning &&
1568
- resultRelInfo -> ri_projectReturning &&
1569
- !resultRelInfo -> ri_FdwRoutine )
1570
- {
1571
- TupleTableSlot * returningSlot ;
1572
-
1573
- returningSlot = ExecGetReturningSlot (estate , resultRelInfo );
1574
- ExecCopySlot (returningSlot , inputslot );
1575
- ExecMaterializeSlot (returningSlot );
1576
- }
1577
-
1578
1562
epqslot = EvalPlanQual (context -> epqstate ,
1579
1563
resultRelationDesc ,
1580
1564
resultRelInfo -> ri_RangeTableIndex ,
@@ -1689,17 +1673,12 @@ ExecDelete(ModifyTableContext *context,
1689
1673
}
1690
1674
else
1691
1675
{
1692
- /*
1693
- * Tuple can be already fetched to the returning slot in case
1694
- * we've previously locked it. Fetch the tuple only if the slot
1695
- * is empty.
1696
- */
1697
1676
slot = ExecGetReturningSlot (estate , resultRelInfo );
1698
1677
if (oldtuple != NULL )
1699
1678
{
1700
1679
ExecForceStoreHeapTuple (oldtuple , slot , false);
1701
1680
}
1702
- else if ( TupIsNull ( slot ))
1681
+ else
1703
1682
{
1704
1683
if (!table_tuple_fetch_row_version (resultRelationDesc , tupleid ,
1705
1684
SnapshotAny , slot ))
@@ -2414,19 +2393,6 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
2414
2393
case TM_Ok :
2415
2394
Assert (context -> tmfd .traversed );
2416
2395
2417
- /* Make sure ri_oldTupleSlot is initialized. */
2418
- if (unlikely (!resultRelInfo -> ri_projectNewInfoValid ))
2419
- ExecInitUpdateProjection (context -> mtstate ,
2420
- resultRelInfo );
2421
-
2422
- /*
2423
- * Save the locked tuple for further calculation
2424
- * of the new tuple.
2425
- */
2426
- oldSlot = resultRelInfo -> ri_oldTupleSlot ;
2427
- ExecCopySlot (oldSlot , inputslot );
2428
- ExecMaterializeSlot (oldSlot );
2429
-
2430
2396
epqslot = EvalPlanQual (context -> epqstate ,
2431
2397
resultRelationDesc ,
2432
2398
resultRelInfo -> ri_RangeTableIndex ,
@@ -2435,6 +2401,18 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
2435
2401
/* Tuple not passing quals anymore, exiting... */
2436
2402
return NULL ;
2437
2403
2404
+ /* Make sure ri_oldTupleSlot is initialized. */
2405
+ if (unlikely (!resultRelInfo -> ri_projectNewInfoValid ))
2406
+ ExecInitUpdateProjection (context -> mtstate ,
2407
+ resultRelInfo );
2408
+
2409
+ /* Fetch the most recent version of old tuple. */
2410
+ oldSlot = resultRelInfo -> ri_oldTupleSlot ;
2411
+ if (!table_tuple_fetch_row_version (resultRelationDesc ,
2412
+ tupleid ,
2413
+ SnapshotAny ,
2414
+ oldSlot ))
2415
+ elog (ERROR , "failed to fetch tuple being updated" );
2438
2416
slot = ExecGetUpdateNewTuple (resultRelInfo ,
2439
2417
epqslot , oldSlot );
2440
2418
goto redo_act ;
0 commit comments