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 1dce1f8
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;

Check warning on line 725 in tsl/src/hypercore/arrow_tts.c

View check run for this annotation

Codecov / codecov/patch

tsl/src/hypercore/arrow_tts.c#L725

Added line #L725 was not covered by tests
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,

Check warning on line 730 in tsl/src/hypercore/arrow_tts.c

View check run for this annotation

Codecov / codecov/patch

tsl/src/hypercore/arrow_tts.c#L729-L730

Added lines #L729 - L730 were not covered by tests
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 1dce1f8

Please sign in to comment.