]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove unused tuple fetch in speculative completion
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 7 Jul 2026 22:16:24 +0000 (01:16 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 7 Jul 2026 22:16:24 +0000 (01:16 +0300)
heapam_tuple_complete_speculative() fetched a tuple from the slot only
to free it immediately afterwards, without ever using it.

The function only needs slot->tts_tid to complete or abort the
speculative insertion, so remove the unnecessary fetch and pfree().

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Discussion: https://www.postgresql.org/message-id/FCB61654-575D-4F08-AA7E-ED462EDE48A7@gmail.com

src/backend/access/heap/heapam_handler.c

index 2268cc277bce5b63a0ceaca64beb44d8a7c51668..bf87430cf017673864983febd5263ebdcdf4a725 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * NOTES
- *       This files wires up the lower level heapam.c et al routines with the
+ *       This file wires up the lower level heapam.c et al routines with the
  *       tableam abstraction.
  *
  *-------------------------------------------------------------------------
@@ -192,17 +192,11 @@ static void
 heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
                                                                  uint32 specToken, bool succeeded)
 {
-       bool            shouldFree = true;
-       HeapTuple       tuple = ExecFetchSlotHeapTuple(slot, true, &shouldFree);
-
        /* adjust the tuple's state accordingly */
        if (succeeded)
                heap_finish_speculative(relation, &slot->tts_tid);
        else
                heap_abort_speculative(relation, &slot->tts_tid);
-
-       if (shouldFree)
-               pfree(tuple);
 }
 
 static TM_Result