bdr: Don't use hack to avoid copying whole tuples when putting them in slots.
authorCraig Ringer <craig@2ndquadrant.com>
Thu, 8 May 2014 08:37:04 +0000 (16:37 +0800)
committerAndres Freund <andres@anarazel.de>
Thu, 3 Jul 2014 15:55:32 +0000 (17:55 +0200)
The current hack isn't sufficient, instead more widespread changes to the slot
mechanism are required.

This caused errors like:

ERROR: could not access status of transaction 4294967295
DETAIL: Could not open file "pg_clog/0FFF": No such file or directory.

when getting a Datum for a tuple with ExecFetchSlotTupleDatum .

Author: Andres Freund

contrib/bdr/bdr_apply.c

index beec1e3609e1242526c697afae524262fac3cf69..9604c736b25b25f9b916f78ff7f66d9a5f1a1a38 100644 (file)
@@ -1780,17 +1780,10 @@ retry:
 
    if ((scantuple = index_getnext(scan, ForwardScanDirection)) != NULL)
    {
-       HeapTuple ht;
-
        found = true;
-       /*
-        * Ugly trick to track the HeapTupleData pointing into a buffer in the
-        * slot.
-        */
-       ht = MemoryContextAllocZero(slot->tts_mcxt, sizeof(HeapTupleData));
-       memcpy(ht, scantuple, sizeof(HeapTupleData));
-       ExecStoreTuple(ht, slot, scan->xs_cbuf, false);
-       slot->tts_shouldFree = true;
+       /* FIXME: Improve TupleSlot to not require copying the whole tuple */
+       ExecStoreTuple(scantuple, slot, InvalidBuffer, false);
+       ExecMaterializeSlot(slot);
 
        xwait = TransactionIdIsValid(snap.xmin) ?
            snap.xmin : snap.xmax;