The 'succeeded' argument seems backwards here:
> static void
> heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
> uint32 spekToken, 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);
> }
According to the comments, if "succeeded = true", the insertion is
completed, and otherwise it's killed. It works, because the only caller
is also passing the argument wrong.
Barring objections, I'll push the attached patch to fix that.
- Heikki