@@ -4397,13 +4397,14 @@ ExecModifyTable(PlanState *pstate)
43974397 CmdType operation = node -> operation ;
43984398 ResultRelInfo * resultRelInfo ;
43994399 PlanState * subplanstate ;
4400- TupleTableSlot * slot ;
4400+ TupleTableSlot * slot = NULL ;
44014401 TupleTableSlot * oldSlot ;
44024402 ItemPointerData tuple_ctid ;
44034403 HeapTupleData oldtupdata ;
44044404 HeapTuple oldtuple ;
44054405 ItemPointer tupleid ;
44064406 bool tuplock ;
4407+ List * items_to_delete = NULL ;
44074408
44084409 CHECK_FOR_INTERRUPTS ();
44094410
@@ -4773,8 +4774,15 @@ ExecModifyTable(PlanState *pstate)
47734774 break ;
47744775
47754776 case CMD_DELETE :
4776- slot = ExecDelete (& context , resultRelInfo , tupleid , oldtuple ,
4777- true, false, node -> canSetTag , NULL , NULL , NULL );
4777+ ItemPointer item_ptr = (ItemPointer ) palloc0 (sizeof (ItemPointerData ));
4778+ item_ptr -> ip_blkid = tupleid -> ip_blkid ;
4779+ item_ptr -> ip_posid = tupleid -> ip_posid ;
4780+
4781+ if (!items_to_delete )
4782+ items_to_delete = list_make1 (item_ptr );
4783+ else
4784+ items_to_delete = lappend (items_to_delete , item_ptr );
4785+
47784786 break ;
47794787
47804788 case CMD_MERGE :
@@ -4791,10 +4799,28 @@ ExecModifyTable(PlanState *pstate)
47914799 * If we got a RETURNING result, return it to caller. We'll continue
47924800 * the work on next call.
47934801 */
4794- if (slot )
4802+ if (slot && !( operation == CMD_DELETE ) )
47954803 return slot ;
47964804 }
47974805
4806+ if (list_length (items_to_delete ) > 0 )
4807+ {
4808+ ListCell * cell ;
4809+ ereport (WARNING , errmsg ("NUM ITEMS TO DELETE = %d" , list_length (items_to_delete )));
4810+ foreach (cell , items_to_delete )
4811+ {
4812+ ItemPointer item_ptr = (ItemPointer ) lfirst (cell );
4813+ if (!slot )
4814+ slot = ExecDelete (& context , resultRelInfo , item_ptr , NULL ,
4815+ true, false, node -> canSetTag , NULL , NULL , NULL );
4816+ else
4817+ ExecDelete (& context , resultRelInfo , item_ptr , NULL ,
4818+ true, false, node -> canSetTag , NULL , NULL , NULL );
4819+ }
4820+
4821+ return slot ;
4822+ }
4823+
47984824 /*
47994825 * Insert remaining tuples for batch insert.
48004826 */
0 commit comments