@@ -113,14 +113,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
113
113
IvfflatScanOpaque so = (IvfflatScanOpaque ) scan -> opaque ;
114
114
TupleDesc tupdesc = RelationGetDescr (scan -> indexRelation );
115
115
double tuples = 0 ;
116
- TupleTableSlot * slot = MakeSingleTupleTableSlot (so -> tupdesc , & TTSOpsVirtual );
117
-
118
- /*
119
- * Reuse same set of shared buffers for scan
120
- *
121
- * See postgres/src/backend/storage/buffer/README for description
122
- */
123
- BufferAccessStrategy bas = GetAccessStrategy (BAS_BULKREAD );
116
+ TupleTableSlot * slot = so -> vslot ;
124
117
125
118
/* Search closest probes lists */
126
119
while (!pairingheap_is_empty (so -> listQueue ))
@@ -134,7 +127,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
134
127
Page page ;
135
128
OffsetNumber maxoffno ;
136
129
137
- buf = ReadBufferExtended (scan -> indexRelation , MAIN_FORKNUM , searchPage , RBM_NORMAL , bas );
130
+ buf = ReadBufferExtended (scan -> indexRelation , MAIN_FORKNUM , searchPage , RBM_NORMAL , so -> bas );
138
131
LockBuffer (buf , BUFFER_LOCK_SHARE );
139
132
page = BufferGetPage (buf );
140
133
maxoffno = PageGetMaxOffsetNumber (page );
@@ -173,8 +166,6 @@ GetScanItems(IndexScanDesc scan, Datum value)
173
166
}
174
167
}
175
168
176
- FreeAccessStrategy (bas );
177
-
178
169
if (tuples < 100 )
179
170
ereport (DEBUG1 ,
180
171
(errmsg ("index scan found few tuples" ),
@@ -277,7 +268,16 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
277
268
/* Prep sort */
278
269
so -> sortstate = InitScanSortState (so -> tupdesc );
279
270
280
- so -> slot = MakeSingleTupleTableSlot (so -> tupdesc , & TTSOpsMinimalTuple );
271
+ /* Need separate slots for puttuple and gettuple */
272
+ so -> vslot = MakeSingleTupleTableSlot (so -> tupdesc , & TTSOpsVirtual );
273
+ so -> mslot = MakeSingleTupleTableSlot (so -> tupdesc , & TTSOpsMinimalTuple );
274
+
275
+ /*
276
+ * Reuse same set of shared buffers for scan
277
+ *
278
+ * See postgres/src/backend/storage/buffer/README for description
279
+ */
280
+ so -> bas = GetAccessStrategy (BAS_BULKREAD );
281
281
282
282
so -> listQueue = pairingheap_allocate (CompareLists , scan );
283
283
@@ -351,9 +351,10 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
351
351
pfree (DatumGetPointer (value ));
352
352
}
353
353
354
- if (tuplesort_gettupleslot (so -> sortstate , true, false, so -> slot , NULL ))
354
+ if (tuplesort_gettupleslot (so -> sortstate , true, false, so -> mslot , NULL ))
355
355
{
356
- ItemPointer heaptid = (ItemPointer ) DatumGetPointer (slot_getattr (so -> slot , 2 , & so -> isnull ));
356
+ bool isnull ;
357
+ ItemPointer heaptid = (ItemPointer ) DatumGetPointer (slot_getattr (so -> mslot , 2 , & isnull ));
357
358
358
359
scan -> xs_heaptid = * heaptid ;
359
360
scan -> xs_recheck = false;
@@ -374,6 +375,7 @@ ivfflatendscan(IndexScanDesc scan)
374
375
375
376
pairingheap_free (so -> listQueue );
376
377
tuplesort_end (so -> sortstate );
378
+ FreeAccessStrategy (so -> bas );
377
379
378
380
pfree (so );
379
381
scan -> opaque = NULL ;
0 commit comments