From: Heikki Linnakangas Date: Tue, 7 Jul 2026 22:16:24 +0000 (+0300) Subject: Remove unused tuple fetch in speculative completion X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7258c891d4cabd366e4529484f2ad6e99234db48;p=thirdparty%2Fpostgresql.git Remove unused tuple fetch in speculative completion 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 Reviewed-by: Japin Li Reviewed-by: Xuneng Zhou Reviewed-by: Surya Poondla Discussion: https://www.postgresql.org/message-id/FCB61654-575D-4F08-AA7E-ED462EDE48A7@gmail.com --- diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2268cc277bc..bf87430cf01 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -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