Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b8b94ea

Browse files
committed
Fix slot type issue for fuzzy distance index scan over out-of-core table AM.
For amcanreorderby scans the nodeIndexscan.c's reorder queue holds heap tuples, but the underlying table likely does not. Before this fix we'd return different types of slots, depending on whether the tuple came from the reorder queue, or from the index + table. While that could be fixed by signalling that the node doesn't return a fixed type of slot, it seems better to instead remove the separate slot for the reorder queue, and use ExecForceStoreHeapTuple() to store tuples from the queue. It's not particularly common to need reordering, after all. This reverts most of the iss_ReorderQueueSlot related changes to nodeIndexscan.c made in 1a0586d, except that now ExecForceStoreHeapTuple() is used instead of ExecStoreHeapTuple(). Noticed when testing zheap against the in-core version of tableam. Author: Andres Freund
1 parent 88e6ad3 commit b8b94ea

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/backend/executor/nodeIndexscan.c

+6-14
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ IndexNextWithReorder(IndexScanState *node)
196196

197197
scandesc = node->iss_ScanDesc;
198198
econtext = node->ss.ps.ps_ExprContext;
199+
slot = node->ss.ss_ScanTupleSlot;
200+
199201
if (scandesc == NULL)
200202
{
201203
/*
@@ -231,7 +233,6 @@ IndexNextWithReorder(IndexScanState *node)
231233
*/
232234
if (!pairingheap_is_empty(node->iss_ReorderQueue))
233235
{
234-
slot = node->iss_ReorderQueueSlot;
235236
topmost = (ReorderTuple *) pairingheap_first(node->iss_ReorderQueue);
236237

237238
if (node->iss_ReachedEnd ||
@@ -246,22 +247,20 @@ IndexNextWithReorder(IndexScanState *node)
246247
tuple = reorderqueue_pop(node);
247248

248249
/* Pass 'true', as the tuple in the queue is a palloc'd copy */
249-
ExecStoreHeapTuple(tuple, slot, true);
250+
ExecForceStoreHeapTuple(tuple, slot, true);
250251
return slot;
251252
}
252253
}
253254
else if (node->iss_ReachedEnd)
254255
{
255256
/* Queue is empty, and no more tuples from index. We're done. */
256-
ExecClearTuple(node->iss_ReorderQueueSlot);
257-
return ExecClearTuple(node->ss.ss_ScanTupleSlot);
257+
return ExecClearTuple(slot);
258258
}
259259

260260
/*
261261
* Fetch next tuple from the index.
262262
*/
263263
next_indextuple:
264-
slot = node->ss.ss_ScanTupleSlot;
265264
if (!index_getnext_slot(scandesc, ForwardScanDirection, slot))
266265
{
267266
/*
@@ -354,8 +353,7 @@ IndexNextWithReorder(IndexScanState *node)
354353
* if we get here it means the index scan failed so we are at the end of
355354
* the scan..
356355
*/
357-
ExecClearTuple(node->iss_ReorderQueueSlot);
358-
return ExecClearTuple(node->ss.ss_ScanTupleSlot);
356+
return ExecClearTuple(slot);
359357
}
360358

361359
/*
@@ -807,8 +805,6 @@ ExecEndIndexScan(IndexScanState *node)
807805
*/
808806
if (node->ss.ps.ps_ResultTupleSlot)
809807
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
810-
if (node->iss_ReorderQueueSlot)
811-
ExecClearTuple(node->iss_ReorderQueueSlot);
812808
ExecClearTuple(node->ss.ss_ScanTupleSlot);
813809

814810
/*
@@ -1055,13 +1051,9 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
10551051
indexstate->iss_OrderByNulls = (bool *)
10561052
palloc(numOrderByKeys * sizeof(bool));
10571053

1058-
/* and initialize the reorder queue and the corresponding slot */
1054+
/* and initialize the reorder queue */
10591055
indexstate->iss_ReorderQueue = pairingheap_allocate(reorderqueue_cmp,
10601056
indexstate);
1061-
indexstate->iss_ReorderQueueSlot =
1062-
ExecAllocTableSlot(&estate->es_tupleTable,
1063-
RelationGetDescr(currentRelation),
1064-
&TTSOpsHeapTuple);
10651057
}
10661058

10671059
/*

src/include/nodes/execnodes.h

-1
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,6 @@ typedef struct IndexScanState
13871387
bool *iss_OrderByTypByVals;
13881388
int16 *iss_OrderByTypLens;
13891389
Size iss_PscanLen;
1390-
TupleTableSlot *iss_ReorderQueueSlot;
13911390
} IndexScanState;
13921391

13931392
/* ----------------

0 commit comments

Comments
 (0)