Skip to content

Commit

Permalink
Transfer visibility when copying arrow tuple slot
Browse files Browse the repository at this point in the history
When creating a heap tuple from an arrow slot, it is necessary to also
transfer the visibility information from the compressed
tuple. Otherwise, the new tuple, if written into another relation,
might not have the correct visibility.
  • Loading branch information
erimatnor committed Jan 13, 2025
1 parent 62e6235 commit 24a3a31
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tsl/src/hypercore/arrow_tts.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include <postgres.h>
#include <access/attnum.h>
#include <access/htup_details.h>
#include <access/tupdesc.h>
#include <catalog/pg_attribute.h>
#include <executor/execdebug.h>
Expand Down Expand Up @@ -719,9 +720,19 @@ tts_arrow_copy_heap_tuple(TupleTableSlot *slot)
tuple = ExecCopySlotHeapTuple(aslot->noncompressed_slot);
ItemPointerCopy(&slot->tts_tid, &tuple->t_self);

/* Clean up if the non-compressed slot was "borrowed" */
if (aslot->child_slot == aslot->compressed_slot)
{
BufferHeapTupleTableSlot *hslot = (BufferHeapTupleTableSlot *) aslot->compressed_slot;
Assert(TTS_IS_BUFFERTUPLE(aslot->compressed_slot));

/* Copy visibility information from the compressed relation tuple */
memcpy(&tuple->t_data->t_choice,
&hslot->base.tuple->t_data->t_choice,
sizeof(tuple->t_data->t_choice));

/* Clean up the "borrowed" non-compressed slot */
ExecClearTuple(aslot->noncompressed_slot);
}

return tuple;
}
Expand Down

0 comments on commit 24a3a31

Please sign in to comment.