PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
nodeIndexonlyscan.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * nodeIndexonlyscan.c
4  * Routines to support index-only scans
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/executor/nodeIndexonlyscan.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 /*
16  * INTERFACE ROUTINES
17  * ExecIndexOnlyScan scans an index
18  * IndexOnlyNext retrieve next tuple
19  * ExecInitIndexOnlyScan creates and initializes state info.
20  * ExecReScanIndexOnlyScan rescans the indexed relation.
21  * ExecEndIndexOnlyScan releases all storage.
22  * ExecIndexOnlyMarkPos marks scan position.
23  * ExecIndexOnlyRestrPos restores scan position.
24  * ExecIndexOnlyScanEstimate estimates DSM space needed for
25  * parallel index-only scan
26  * ExecIndexOnlyScanInitializeDSM initialize DSM for parallel
27  * index-only scan
28  * ExecIndexOnlyScanInitializeWorker attach to DSM info in parallel worker
29  */
30 #include "postgres.h"
31 
32 #include "access/relscan.h"
33 #include "access/visibilitymap.h"
34 #include "executor/execdebug.h"
36 #include "executor/nodeIndexscan.h"
37 #include "storage/bufmgr.h"
38 #include "storage/predicate.h"
39 #include "utils/memutils.h"
40 #include "utils/rel.h"
41 
42 
44 static void StoreIndexTuple(TupleTableSlot *slot, IndexTuple itup,
45  TupleDesc itupdesc);
46 
47 
48 /* ----------------------------------------------------------------
49  * IndexOnlyNext
50  *
51  * Retrieve a tuple from the IndexOnlyScan node's index.
52  * ----------------------------------------------------------------
53  */
54 static TupleTableSlot *
56 {
57  EState *estate;
58  ExprContext *econtext;
59  ScanDirection direction;
60  IndexScanDesc scandesc;
61  TupleTableSlot *slot;
62  ItemPointer tid;
63 
64  /*
65  * extract necessary information from index scan node
66  */
67  estate = node->ss.ps.state;
68  direction = estate->es_direction;
69  /* flip direction if this is an overall backward scan */
70  if (ScanDirectionIsBackward(((IndexOnlyScan *) node->ss.ps.plan)->indexorderdir))
71  {
72  if (ScanDirectionIsForward(direction))
73  direction = BackwardScanDirection;
74  else if (ScanDirectionIsBackward(direction))
75  direction = ForwardScanDirection;
76  }
77  scandesc = node->ioss_ScanDesc;
78  econtext = node->ss.ps.ps_ExprContext;
79  slot = node->ss.ss_ScanTupleSlot;
80 
81  /*
82  * OK, now that we have what we need, fetch the next tuple.
83  */
84  while ((tid = index_getnext_tid(scandesc, direction)) != NULL)
85  {
86  HeapTuple tuple = NULL;
87 
88  /*
89  * We can skip the heap fetch if the TID references a heap page on
90  * which all tuples are known visible to everybody. In any case,
91  * we'll use the index tuple not the heap tuple as the data source.
92  *
93  * Note on Memory Ordering Effects: visibilitymap_get_status does not
94  * lock the visibility map buffer, and therefore the result we read
95  * here could be slightly stale. However, it can't be stale enough to
96  * matter.
97  *
98  * We need to detect clearing a VM bit due to an insert right away,
99  * because the tuple is present in the index page but not visible. The
100  * reading of the TID by this scan (using a shared lock on the index
101  * buffer) is serialized with the insert of the TID into the index
102  * (using an exclusive lock on the index buffer). Because the VM bit
103  * is cleared before updating the index, and locking/unlocking of the
104  * index page acts as a full memory barrier, we are sure to see the
105  * cleared bit if we see a recently-inserted TID.
106  *
107  * Deletes do not update the index page (only VACUUM will clear out
108  * the TID), so the clearing of the VM bit by a delete is not
109  * serialized with this test below, and we may see a value that is
110  * significantly stale. However, we don't care about the delete right
111  * away, because the tuple is still visible until the deleting
112  * transaction commits or the statement ends (if it's our
113  * transaction). In either case, the lock on the VM buffer will have
114  * been released (acting as a write barrier) after clearing the bit.
115  * And for us to have a snapshot that includes the deleting
116  * transaction (making the tuple invisible), we must have acquired
117  * ProcArrayLock after that time, acting as a read barrier.
118  *
119  * It's worth going through this complexity to avoid needing to lock
120  * the VM buffer, which could cause significant contention.
121  */
122  if (!VM_ALL_VISIBLE(scandesc->heapRelation,
124  &node->ioss_VMBuffer))
125  {
126  /*
127  * Rats, we have to visit the heap to check visibility.
128  */
129  node->ioss_HeapFetches++;
130  tuple = index_fetch_heap(scandesc);
131  if (tuple == NULL)
132  continue; /* no visible tuple, try next index entry */
133 
134  /*
135  * Only MVCC snapshots are supported here, so there should be no
136  * need to keep following the HOT chain once a visible entry has
137  * been found. If we did want to allow that, we'd need to keep
138  * more state to remember not to call index_getnext_tid next time.
139  */
140  if (scandesc->xs_continue_hot)
141  elog(ERROR, "non-MVCC snapshots are not supported in index-only scans");
142 
143  /*
144  * Note: at this point we are holding a pin on the heap page, as
145  * recorded in scandesc->xs_cbuf. We could release that pin now,
146  * but it's not clear whether it's a win to do so. The next index
147  * entry might require a visit to the same heap page.
148  */
149  }
150 
151  /*
152  * Fill the scan tuple slot with data from the index.
153  */
154  StoreIndexTuple(slot, scandesc->xs_itup, scandesc->xs_itupdesc);
155 
156  /*
157  * If the index was lossy, we have to recheck the index quals.
158  * (Currently, this can never happen, but we should support the case
159  * for possible future use, eg with GiST indexes.)
160  */
161  if (scandesc->xs_recheck)
162  {
163  econtext->ecxt_scantuple = slot;
164  ResetExprContext(econtext);
165  if (!ExecQual(node->indexqual, econtext, false))
166  {
167  /* Fails recheck, so drop it and loop back for another */
168  InstrCountFiltered2(node, 1);
169  continue;
170  }
171  }
172 
173  /*
174  * We don't currently support rechecking ORDER BY distances. (In
175  * principle, if the index can support retrieval of the originally
176  * indexed value, it should be able to produce an exact distance
177  * calculation too. So it's not clear that adding code here for
178  * recheck/re-sort would be worth the trouble. But we should at least
179  * throw an error if someone tries it.)
180  */
181  if (scandesc->numberOfOrderBys > 0 && scandesc->xs_recheckorderby)
182  ereport(ERROR,
183  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
184  errmsg("lossy distance functions are not supported in index-only scans")));
185 
186  /*
187  * Predicate locks for index-only scans must be acquired at the page
188  * level when the heap is not accessed, since tuple-level predicate
189  * locks need the tuple's xmin value. If we had to visit the tuple
190  * anyway, then we already have the tuple-level lock and can skip the
191  * page lock.
192  */
193  if (tuple == NULL)
196  estate->es_snapshot);
197 
198  return slot;
199  }
200 
201  /*
202  * if we get here it means the index scan failed so we are at the end of
203  * the scan..
204  */
205  return ExecClearTuple(slot);
206 }
207 
208 /*
209  * StoreIndexTuple
210  * Fill the slot with data from the index tuple.
211  *
212  * At some point this might be generally-useful functionality, but
213  * right now we don't need it elsewhere.
214  */
215 static void
217 {
218  int nindexatts = itupdesc->natts;
219  Datum *values = slot->tts_values;
220  bool *isnull = slot->tts_isnull;
221  int i;
222 
223  /*
224  * Note: we must use the tupdesc supplied by the AM in index_getattr, not
225  * the slot's tupdesc, in case the latter has different datatypes (this
226  * happens for btree name_ops in particular). They'd better have the same
227  * number of columns though, as well as being datatype-compatible which is
228  * something we can't so easily check.
229  */
230  Assert(slot->tts_tupleDescriptor->natts == nindexatts);
231 
232  ExecClearTuple(slot);
233  for (i = 0; i < nindexatts; i++)
234  values[i] = index_getattr(itup, i + 1, itupdesc, &isnull[i]);
235  ExecStoreVirtualTuple(slot);
236 }
237 
238 /*
239  * IndexOnlyRecheck -- access method routine to recheck a tuple in EvalPlanQual
240  *
241  * This can't really happen, since an index can't supply CTID which would
242  * be necessary data for any potential EvalPlanQual target relation. If it
243  * did happen, the EPQ code would pass us the wrong data, namely a heap
244  * tuple not an index tuple. So throw an error.
245  */
246 static bool
248 {
249  elog(ERROR, "EvalPlanQual recheck is not supported in index-only scans");
250  return false; /* keep compiler quiet */
251 }
252 
253 /* ----------------------------------------------------------------
254  * ExecIndexOnlyScan(node)
255  * ----------------------------------------------------------------
256  */
259 {
260  /*
261  * If we have runtime keys and they've not already been set up, do it now.
262  */
263  if (node->ioss_NumRuntimeKeys != 0 && !node->ioss_RuntimeKeysReady)
264  ExecReScan((PlanState *) node);
265 
266  return ExecScan(&node->ss,
269 }
270 
271 /* ----------------------------------------------------------------
272  * ExecReScanIndexOnlyScan(node)
273  *
274  * Recalculates the values of any scan keys whose value depends on
275  * information known at runtime, then rescans the indexed relation.
276  *
277  * Updating the scan key was formerly done separately in
278  * ExecUpdateIndexScanKeys. Integrating it into ReScan makes
279  * rescans of indices and relations/general streams more uniform.
280  * ----------------------------------------------------------------
281  */
282 void
284 {
285  bool reset_parallel_scan = true;
286 
287  /*
288  * If we are here to just update the scan keys, then don't reset parallel
289  * scan. For detailed reason behind this look in the comments for
290  * ExecReScanIndexScan.
291  */
292  if (node->ioss_NumRuntimeKeys != 0 && !node->ioss_RuntimeKeysReady)
293  reset_parallel_scan = false;
294 
295  /*
296  * If we are doing runtime key calculations (ie, any of the index key
297  * values weren't simple Consts), compute the new key values. But first,
298  * reset the context so we don't leak memory as each outer tuple is
299  * scanned. Note this assumes that we will recalculate *all* runtime keys
300  * on each call.
301  */
302  if (node->ioss_NumRuntimeKeys != 0)
303  {
304  ExprContext *econtext = node->ioss_RuntimeContext;
305 
306  ResetExprContext(econtext);
307  ExecIndexEvalRuntimeKeys(econtext,
308  node->ioss_RuntimeKeys,
309  node->ioss_NumRuntimeKeys);
310  }
311  node->ioss_RuntimeKeysReady = true;
312 
313  /* reset index scan */
314  if (node->ioss_ScanDesc)
315  {
316 
318  node->ioss_ScanKeys, node->ioss_NumScanKeys,
320 
321  if (reset_parallel_scan && node->ioss_ScanDesc->parallel_scan)
323  }
324  ExecScanReScan(&node->ss);
325 }
326 
327 
328 /* ----------------------------------------------------------------
329  * ExecEndIndexOnlyScan
330  * ----------------------------------------------------------------
331  */
332 void
334 {
335  Relation indexRelationDesc;
336  IndexScanDesc indexScanDesc;
337  Relation relation;
338 
339  /*
340  * extract information from the node
341  */
342  indexRelationDesc = node->ioss_RelationDesc;
343  indexScanDesc = node->ioss_ScanDesc;
344  relation = node->ss.ss_currentRelation;
345 
346  /* Release VM buffer pin, if any. */
347  if (node->ioss_VMBuffer != InvalidBuffer)
348  {
351  }
352 
353  /*
354  * Free the exprcontext(s) ... now dead code, see ExecFreeExprContext
355  */
356 #ifdef NOT_USED
357  ExecFreeExprContext(&node->ss.ps);
358  if (node->ioss_RuntimeContext)
360 #endif
361 
362  /*
363  * clear out tuple table slots
364  */
367 
368  /*
369  * close the index relation (no-op if we didn't open it)
370  */
371  if (indexScanDesc)
372  index_endscan(indexScanDesc);
373  if (indexRelationDesc)
374  index_close(indexRelationDesc, NoLock);
375 
376  /*
377  * close the heap relation.
378  */
379  ExecCloseScanRelation(relation);
380 }
381 
382 /* ----------------------------------------------------------------
383  * ExecIndexOnlyMarkPos
384  * ----------------------------------------------------------------
385  */
386 void
388 {
390 }
391 
392 /* ----------------------------------------------------------------
393  * ExecIndexOnlyRestrPos
394  * ----------------------------------------------------------------
395  */
396 void
398 {
400 }
401 
402 /* ----------------------------------------------------------------
403  * ExecInitIndexOnlyScan
404  *
405  * Initializes the index scan's state information, creates
406  * scan keys, and opens the base and index relations.
407  *
408  * Note: index scans have 2 sets of state information because
409  * we have to keep track of the base relation and the
410  * index relation.
411  * ----------------------------------------------------------------
412  */
414 ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
415 {
416  IndexOnlyScanState *indexstate;
417  Relation currentRelation;
418  bool relistarget;
419  TupleDesc tupDesc;
420 
421  /*
422  * create state structure
423  */
424  indexstate = makeNode(IndexOnlyScanState);
425  indexstate->ss.ps.plan = (Plan *) node;
426  indexstate->ss.ps.state = estate;
427  indexstate->ioss_HeapFetches = 0;
428 
429  /*
430  * Miscellaneous initialization
431  *
432  * create expression context for node
433  */
434  ExecAssignExprContext(estate, &indexstate->ss.ps);
435 
436  /*
437  * initialize child expressions
438  *
439  * Note: we don't initialize all of the indexorderby expression, only the
440  * sub-parts corresponding to runtime keys (see below).
441  */
442  indexstate->ss.ps.targetlist = (List *)
444  (PlanState *) indexstate);
445  indexstate->ss.ps.qual = (List *)
446  ExecInitExpr((Expr *) node->scan.plan.qual,
447  (PlanState *) indexstate);
448  indexstate->indexqual = (List *)
449  ExecInitExpr((Expr *) node->indexqual,
450  (PlanState *) indexstate);
451 
452  /*
453  * tuple table initialization
454  */
455  ExecInitResultTupleSlot(estate, &indexstate->ss.ps);
456  ExecInitScanTupleSlot(estate, &indexstate->ss);
457 
458  /*
459  * open the base relation and acquire appropriate lock on it.
460  */
461  currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
462 
463  indexstate->ss.ss_currentRelation = currentRelation;
464  indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
465 
466  /*
467  * Build the scan tuple type using the indextlist generated by the
468  * planner. We use this, rather than the index's physical tuple
469  * descriptor, because the latter contains storage column types not the
470  * types of the original datums. (It's the AM's responsibility to return
471  * suitable data anyway.)
472  */
473  tupDesc = ExecTypeFromTL(node->indextlist, false);
474  ExecAssignScanType(&indexstate->ss, tupDesc);
475 
476  /*
477  * Initialize result tuple type and projection info. The node's
478  * targetlist will contain Vars with varno = INDEX_VAR, referencing the
479  * scan tuple.
480  */
481  ExecAssignResultTypeFromTL(&indexstate->ss.ps);
483 
484  /*
485  * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
486  * here. This allows an index-advisor plugin to EXPLAIN a plan containing
487  * references to nonexistent indexes.
488  */
489  if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
490  return indexstate;
491 
492  /*
493  * Open the index relation.
494  *
495  * If the parent table is one of the target relations of the query, then
496  * InitPlan already opened and write-locked the index, so we can avoid
497  * taking another lock here. Otherwise we need a normal reader's lock.
498  */
499  relistarget = ExecRelationIsTargetRelation(estate, node->scan.scanrelid);
500  indexstate->ioss_RelationDesc = index_open(node->indexid,
501  relistarget ? NoLock : AccessShareLock);
502 
503  /*
504  * Initialize index-specific scan state
505  */
506  indexstate->ioss_RuntimeKeysReady = false;
507  indexstate->ioss_RuntimeKeys = NULL;
508  indexstate->ioss_NumRuntimeKeys = 0;
509 
510  /*
511  * build the index scan keys from the index qualification
512  */
513  ExecIndexBuildScanKeys((PlanState *) indexstate,
514  indexstate->ioss_RelationDesc,
515  node->indexqual,
516  false,
517  &indexstate->ioss_ScanKeys,
518  &indexstate->ioss_NumScanKeys,
519  &indexstate->ioss_RuntimeKeys,
520  &indexstate->ioss_NumRuntimeKeys,
521  NULL, /* no ArrayKeys */
522  NULL);
523 
524  /*
525  * any ORDER BY exprs have to be turned into scankeys in the same way
526  */
527  ExecIndexBuildScanKeys((PlanState *) indexstate,
528  indexstate->ioss_RelationDesc,
529  node->indexorderby,
530  true,
531  &indexstate->ioss_OrderByKeys,
532  &indexstate->ioss_NumOrderByKeys,
533  &indexstate->ioss_RuntimeKeys,
534  &indexstate->ioss_NumRuntimeKeys,
535  NULL, /* no ArrayKeys */
536  NULL);
537 
538  /*
539  * If we have runtime keys, we need an ExprContext to evaluate them. The
540  * node's standard context won't do because we want to reset that context
541  * for every tuple. So, build another context just like the other one...
542  * -tgl 7/11/00
543  */
544  if (indexstate->ioss_NumRuntimeKeys != 0)
545  {
546  ExprContext *stdecontext = indexstate->ss.ps.ps_ExprContext;
547 
548  ExecAssignExprContext(estate, &indexstate->ss.ps);
549  indexstate->ioss_RuntimeContext = indexstate->ss.ps.ps_ExprContext;
550  indexstate->ss.ps.ps_ExprContext = stdecontext;
551  }
552  else
553  {
554  indexstate->ioss_RuntimeContext = NULL;
555  }
556 
557  /*
558  * Initialize scan descriptor.
559  */
560  if (!node->scan.plan.parallel_aware)
561  {
562  indexstate->ioss_ScanDesc = index_beginscan(currentRelation,
563  indexstate->ioss_RelationDesc,
564  estate->es_snapshot,
565  indexstate->ioss_NumScanKeys,
566  indexstate->ioss_NumOrderByKeys);
567 
568 
569  /* Set it up for index-only scan */
570  indexstate->ioss_ScanDesc->xs_want_itup = true;
571  indexstate->ioss_VMBuffer = InvalidBuffer;
572 
573  /*
574  * If no run-time keys to calculate, go ahead and pass the scankeys to
575  * the index AM.
576  */
577  if (indexstate->ioss_NumRuntimeKeys == 0)
578  index_rescan(indexstate->ioss_ScanDesc,
579  indexstate->ioss_ScanKeys,
580  indexstate->ioss_NumScanKeys,
581  indexstate->ioss_OrderByKeys,
582  indexstate->ioss_NumOrderByKeys);
583  }
584 
585  /*
586  * all done.
587  */
588  return indexstate;
589 }
590 
591 /* ----------------------------------------------------------------
592  * Parallel Index-only Scan Support
593  * ----------------------------------------------------------------
594  */
595 
596 /* ----------------------------------------------------------------
597  * ExecIndexOnlyScanEstimate
598  *
599  * estimates the space required to serialize index-only scan node.
600  * ----------------------------------------------------------------
601  */
602 void
604  ParallelContext *pcxt)
605 {
606  EState *estate = node->ss.ps.state;
607 
609  estate->es_snapshot);
611  shm_toc_estimate_keys(&pcxt->estimator, 1);
612 }
613 
614 /* ----------------------------------------------------------------
615  * ExecIndexOnlyScanInitializeDSM
616  *
617  * Set up a parallel index-only scan descriptor.
618  * ----------------------------------------------------------------
619  */
620 void
622  ParallelContext *pcxt)
623 {
624  EState *estate = node->ss.ps.state;
625  ParallelIndexScanDesc piscan;
626 
627  piscan = shm_toc_allocate(pcxt->toc, node->ioss_PscanLen);
629  node->ioss_RelationDesc,
630  estate->es_snapshot,
631  piscan);
632  shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, piscan);
633  node->ioss_ScanDesc =
635  node->ioss_RelationDesc,
636  node->ioss_NumScanKeys,
637  node->ioss_NumOrderByKeys,
638  piscan);
639  node->ioss_ScanDesc->xs_want_itup = true;
641 
642  /*
643  * If no run-time keys to calculate, go ahead and pass the scankeys to
644  * the index AM.
645  */
646  if (node->ioss_NumRuntimeKeys == 0)
648  node->ioss_ScanKeys, node->ioss_NumScanKeys,
650 }
651 
652 /* ----------------------------------------------------------------
653  * ExecIndexOnlyScanInitializeWorker
654  *
655  * Copy relevant information from TOC into planstate.
656  * ----------------------------------------------------------------
657  */
658 void
660 {
661  ParallelIndexScanDesc piscan;
662 
663  piscan = shm_toc_lookup(toc, node->ss.ps.plan->plan_node_id);
664  node->ioss_ScanDesc =
666  node->ioss_RelationDesc,
667  node->ioss_NumScanKeys,
668  node->ioss_NumOrderByKeys,
669  piscan);
670  node->ioss_ScanDesc->xs_want_itup = true;
671 
672  /*
673  * If no run-time keys to calculate, go ahead and pass the scankeys to the
674  * index AM.
675  */
676  if (node->ioss_NumRuntimeKeys == 0)
678  node->ioss_ScanKeys, node->ioss_NumScanKeys,
680 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1426
ParallelIndexScanDesc parallel_scan
Definition: relscan.h:132
List * qual
Definition: plannodes.h:130
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
Definition: predicate.c:2438
Plan plan
Definition: plannodes.h:305
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
Index scanrelid
Definition: plannodes.h:306
void ExecIndexOnlyScanInitializeWorker(IndexOnlyScanState *node, shm_toc *toc)
#define ScanDirectionIsForward(direction)
Definition: sdir.h:55
IndexTuple xs_itup
Definition: relscan.h:108
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition: indexam.c:496
void ExecIndexOnlyRestrPos(IndexOnlyScanState *node)
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:121
void index_markpos(IndexScanDesc scan)
Definition: indexam.c:370
ExprContext * ps_ExprContext
Definition: execnodes.h:1078
shm_toc_estimator estimator
Definition: parallel.h:42
void ExecReScan(PlanState *node)
Definition: execAmi.c:73
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
int plan_node_id
Definition: plannodes.h:128
#define AccessShareLock
Definition: lockdefs.h:36
List * qual
Definition: execnodes.h:1062
#define InvalidBuffer
Definition: buf.h:25
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:310
int errcode(int sqlerrcode)
Definition: elog.c:575
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1424
bool xs_recheckorderby
Definition: relscan.h:126
List * targetlist
Definition: execnodes.h:1061
Snapshot es_snapshot
Definition: execnodes.h:370
Datum * tts_values
Definition: tuptable.h:125
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1291
void ExecReScanIndexOnlyScan(IndexOnlyScanState *node)
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3292
TupleDesc xs_itupdesc
Definition: relscan.h:109
Relation ss_currentRelation
Definition: execnodes.h:1289
EState * state
Definition: execnodes.h:1049
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:49
static bool IndexOnlyRecheck(IndexOnlyScanState *node, TupleTableSlot *slot)
int natts
Definition: tupdesc.h:73
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:685
ScanDirection es_direction
Definition: execnodes.h:369
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:430
Size index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
Definition: indexam.c:417
void index_parallelrescan(IndexScanDesc scan)
Definition: indexam.c:481
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:271
TupleTableSlot * ExecIndexOnlyScan(IndexOnlyScanState *node)
Relation heapRelation
Definition: relscan.h:88
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno)
Definition: execScan.c:247
void index_restrpos(IndexScanDesc scan)
Definition: indexam.c:395
PlanState ps
Definition: execnodes.h:1288
ScanKey ioss_ScanKeys
Definition: execnodes.h:1420
#define ScanDirectionIsBackward(direction)
Definition: sdir.h:41
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:272
ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
Definition: indexam.c:526
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1077
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execQual.c:4266
void ExecIndexOnlyMarkPos(IndexOnlyScanState *node)
#define ERROR
Definition: elog.h:43
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:772
void ExecIndexOnlyScanEstimate(IndexOnlyScanState *node, ParallelContext *pcxt)
void * shm_toc_lookup(shm_toc *toc, uint64 key)
Definition: shm_toc.c:218
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1427
#define NoLock
Definition: lockdefs.h:34
bool * tts_isnull
Definition: tuptable.h:126
HeapTuple index_fetch_heap(IndexScanDesc scan)
Definition: indexam.c:583
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1429
ScanDirection
Definition: sdir.h:22
bool xs_continue_hot
Definition: relscan.h:129
bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
Definition: execQual.c:5055
bool parallel_aware
Definition: plannodes.h:123
void ExecEndIndexOnlyScan(IndexOnlyScanState *node)
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:340
#define ereport(elevel, rest)
Definition: elog.h:122
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1422
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:888
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
uintptr_t Datum
Definition: postgres.h:374
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:339
Plan * plan
Definition: execnodes.h:1047
Relation ioss_RelationDesc
Definition: execnodes.h:1428
List * indextlist
Definition: plannodes.h:398
bool xs_want_itup
Definition: relscan.h:95
List * indexorderby
Definition: plannodes.h:397
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:226
IndexOnlyScanState * ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
#define Assert(condition)
Definition: c.h:671
static void StoreIndexTuple(TupleTableSlot *slot, IndexTuple itup, TupleDesc itupdesc)
static TupleTableSlot * IndexOnlyNext(IndexOnlyScanState *node)
#define InstrCountFiltered2(node, delta)
Definition: execnodes.h:1098
#define VM_ALL_VISIBLE(r, b, v)
Definition: visibilitymap.h:32
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:408
void ExecIndexBuildScanKeys(PlanState *planstate, Relation index, List *quals, bool isorderby, ScanKey *scanKeys, int *numScanKeys, IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys, IndexArrayKeyInfo **arrayKeys, int *numArrayKeys)
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:52
void ExecCloseScanRelation(Relation scanrel)
Definition: execUtils.c:830
List * indexqual
Definition: plannodes.h:396
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:128
#define index_getattr(tup, attnum, tupleDesc, isnull)
Definition: itup.h:100
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:83
void ExecIndexEvalRuntimeKeys(ExprContext *econtext, IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)
List * targetlist
Definition: plannodes.h:129
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:176
static Datum values[MAXATTR]
Definition: bootstrap.c:162
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:161
int errmsg(const char *fmt,...)
Definition: elog.c:797
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, ParallelIndexScanDesc target)
Definition: indexam.c:450
int i
void ExecScanReScan(ScanState *node)
Definition: execScan.c:327
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:709
void ExecIndexOnlyScanInitializeDSM(IndexOnlyScanState *node, ParallelContext *pcxt)
int numberOfOrderBys
Definition: relscan.h:92
#define elog
Definition: elog.h:219
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:66
#define INDEX_VAR
Definition: primnodes.h:133
Definition: pg_list.h:45
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:58
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:151
bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid)
Definition: execUtils.c:746
#define ResetExprContext(econtext)
Definition: executor.h:332
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:488
shm_toc * toc
Definition: parallel.h:45
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, int norderbys)
Definition: indexam.c:221