From 1dce1f8ef44a461e25a455931cdcc2c23632b8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Nordstr=C3=B6m?= Date: Mon, 13 Jan 2025 10:55:24 +0100 Subject: [PATCH] Transfer visibility when copying arrow tuple slot 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. --- tsl/src/hypercore/arrow_tts.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tsl/src/hypercore/arrow_tts.c b/tsl/src/hypercore/arrow_tts.c index 7628e8b4240..b6e91e874e9 100644 --- a/tsl/src/hypercore/arrow_tts.c +++ b/tsl/src/hypercore/arrow_tts.c @@ -5,6 +5,7 @@ */ #include #include +#include #include #include #include @@ -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; }