WIP: ForceStore HeapTupleDatum
authorAndres Freund <[email protected]>
Tue, 4 Dec 2018 19:11:09 +0000 (11:11 -0800)
committerAndres Freund <[email protected]>
Tue, 11 Dec 2018 00:48:56 +0000 (16:48 -0800)
Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:

src/backend/executor/execTuples.c
src/include/executor/tuptable.h

index ac5d76bd417b0563972274a6d6a9e71bb0b97216..472a5f39cfc682aa5cad0f6d83317856f091db9d 100644 (file)
@@ -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.
index db5031f57465cebee1fd8fea9e7359446a0bd87a..5c390a9669675c4d01f6016c9f3841968e389077 100644 (file)
@@ -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);