From a3f56e8f5877bb4c8a636c13cdf9f6cc1baecdfb Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 4 Dec 2018 11:11:09 -0800 Subject: [PATCH] WIP: ForceStore HeapTupleDatum Author: Reviewed-By: Discussion: https://postgr.es/m/ Backpatch: --- src/backend/executor/execTuples.c | 23 +++++++++++++++++++++++ src/include/executor/tuptable.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index ac5d76bd41..472a5f39cf 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -1459,6 +1459,29 @@ ExecForceStoreMinimalTuple(MinimalTuple mtup, } } +void +ExecForceStoreHeapTupleDatum(Datum data, TupleTableSlot *slot) +{ + HeapTuple tuple; + HeapTupleHeader td; + + td = DatumGetHeapTupleHeader(data); + + tuple = (HeapTuple) palloc(HEAPTUPLESIZE + HeapTupleHeaderGetDatumLength(td)); + tuple->t_len = HeapTupleHeaderGetDatumLength(td); + tuple->t_self = td->t_ctid; + tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE); + memcpy((char *) tuple->t_data, (char *) td, tuple->t_len); + + ExecClearTuple(slot); + + heap_deform_tuple(tuple, slot->tts_tupleDescriptor, + slot->tts_values, slot->tts_isnull); + ExecStoreVirtualTuple(slot); + + ExecMaterializeSlot(slot); +} + /* -------------------------------- * ExecStoreVirtualTuple * Mark a slot as containing a virtual tuple. diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h index db5031f574..5c390a9669 100644 --- a/src/include/executor/tuptable.h +++ b/src/include/executor/tuptable.h @@ -302,6 +302,8 @@ extern TupleTableSlot *ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree); extern void ExecForceStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot); +/* FIXME: Remove */ +extern void ExecForceStoreHeapTupleDatum(Datum data, TupleTableSlot *slot); extern TupleTableSlot *ExecStoreBufferHeapTuple(HeapTuple tuple, TupleTableSlot *slot, Buffer buffer); -- 2.39.5