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  if (scandesc == NULL)
82  {
83  /*
84  * We reach here if the index only scan is not parallel, or if we're
85  * executing a index only scan that was intended to be parallel
86  * serially.
87  */
88  scandesc = index_beginscan(node->ss.ss_currentRelation,
89  node->ioss_RelationDesc,
90  estate->es_snapshot,
91  node->ioss_NumScanKeys,
92  node->ioss_NumOrderByKeys);
93 
94  node->ioss_ScanDesc = scandesc;
95 
96 
97  /* Set it up for index-only scan */
98  node->ioss_ScanDesc->xs_want_itup = true;
100 
101  /*
102  * If no run-time keys to calculate or they are ready, go ahead and
103  * pass the scankeys to the index AM.
104  */
105  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
106  index_rescan(scandesc,
107  node->ioss_ScanKeys,
108  node->ioss_NumScanKeys,
109  node->ioss_OrderByKeys,
110  node->ioss_NumOrderByKeys);
111  }
112 
113  /*
114  * OK, now that we have what we need, fetch the next tuple.
115  */
116  while ((tid = index_getnext_tid(scandesc, direction)) != NULL)
117  {
118  HeapTuple tuple = NULL;
119 
120  /*
121  * We can skip the heap fetch if the TID references a heap page on
122  * which all tuples are known visible to everybody. In any case,
123  * we'll use the index tuple not the heap tuple as the data source.
124  *
125  * Note on Memory Ordering Effects: visibilitymap_get_status does not
126  * lock the visibility map buffer, and therefore the result we read
127  * here could be slightly stale. However, it can't be stale enough to
128  * matter.
129  *
130  * We need to detect clearing a VM bit due to an insert right away,
131  * because the tuple is present in the index page but not visible. The
132  * reading of the TID by this scan (using a shared lock on the index
133  * buffer) is serialized with the insert of the TID into the index
134  * (using an exclusive lock on the index buffer). Because the VM bit
135  * is cleared before updating the index, and locking/unlocking of the
136  * index page acts as a full memory barrier, we are sure to see the
137  * cleared bit if we see a recently-inserted TID.
138  *
139  * Deletes do not update the index page (only VACUUM will clear out
140  * the TID), so the clearing of the VM bit by a delete is not
141  * serialized with this test below, and we may see a value that is
142  * significantly stale. However, we don't care about the delete right
143  * away, because the tuple is still visible until the deleting
144  * transaction commits or the statement ends (if it's our
145  * transaction). In either case, the lock on the VM buffer will have
146  * been released (acting as a write barrier) after clearing the bit.
147  * And for us to have a snapshot that includes the deleting
148  * transaction (making the tuple invisible), we must have acquired
149  * ProcArrayLock after that time, acting as a read barrier.
150  *
151  * It's worth going through this complexity to avoid needing to lock
152  * the VM buffer, which could cause significant contention.
153  */
154  if (!VM_ALL_VISIBLE(scandesc->heapRelation,
156  &node->ioss_VMBuffer))
157  {
158  /*
159  * Rats, we have to visit the heap to check visibility.
160  */
161  node->ioss_HeapFetches++;
162  tuple = index_fetch_heap(scandesc);
163  if (tuple == NULL)
164  continue; /* no visible tuple, try next index entry */
165 
166  /*
167  * Only MVCC snapshots are supported here, so there should be no
168  * need to keep following the HOT chain once a visible entry has
169  * been found. If we did want to allow that, we'd need to keep
170  * more state to remember not to call index_getnext_tid next time.
171  */
172  if (scandesc->xs_continue_hot)
173  elog(ERROR, "non-MVCC snapshots are not supported in index-only scans");
174 
175  /*
176  * Note: at this point we are holding a pin on the heap page, as
177  * recorded in scandesc->xs_cbuf. We could release that pin now,
178  * but it's not clear whether it's a win to do so. The next index
179  * entry might require a visit to the same heap page.
180  */
181  }
182 
183  /*
184  * Fill the scan tuple slot with data from the index. This might be
185  * provided in either HeapTuple or IndexTuple format. Conceivably an
186  * index AM might fill both fields, in which case we prefer the heap
187  * format, since it's probably a bit cheaper to fill a slot from.
188  */
189  if (scandesc->xs_hitup)
190  {
191  /*
192  * We don't take the trouble to verify that the provided tuple has
193  * exactly the slot's format, but it seems worth doing a quick
194  * check on the number of fields.
195  */
197  scandesc->xs_hitupdesc->natts);
198  ExecStoreTuple(scandesc->xs_hitup, slot, InvalidBuffer, false);
199  }
200  else if (scandesc->xs_itup)
201  StoreIndexTuple(slot, scandesc->xs_itup, scandesc->xs_itupdesc);
202  else
203  elog(ERROR, "no data returned for index-only scan");
204 
205  /*
206  * If the index was lossy, we have to recheck the index quals.
207  * (Currently, this can never happen, but we should support the case
208  * for possible future use, eg with GiST indexes.)
209  */
210  if (scandesc->xs_recheck)
211  {
212  econtext->ecxt_scantuple = slot;
213  ResetExprContext(econtext);
214  if (!ExecQual(node->indexqual, econtext))
215  {
216  /* Fails recheck, so drop it and loop back for another */
217  InstrCountFiltered2(node, 1);
218  continue;
219  }
220  }
221 
222  /*
223  * We don't currently support rechecking ORDER BY distances. (In
224  * principle, if the index can support retrieval of the originally
225  * indexed value, it should be able to produce an exact distance
226  * calculation too. So it's not clear that adding code here for
227  * recheck/re-sort would be worth the trouble. But we should at least
228  * throw an error if someone tries it.)
229  */
230  if (scandesc->numberOfOrderBys > 0 && scandesc->xs_recheckorderby)
231  ereport(ERROR,
232  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
233  errmsg("lossy distance functions are not supported in index-only scans")));
234 
235  /*
236  * Predicate locks for index-only scans must be acquired at the page
237  * level when the heap is not accessed, since tuple-level predicate
238  * locks need the tuple's xmin value. If we had to visit the tuple
239  * anyway, then we already have the tuple-level lock and can skip the
240  * page lock.
241  */
242  if (tuple == NULL)
245  estate->es_snapshot);
246 
247  return slot;
248  }
249 
250  /*
251  * if we get here it means the index scan failed so we are at the end of
252  * the scan..
253  */
254  return ExecClearTuple(slot);
255 }
256 
257 /*
258  * StoreIndexTuple
259  * Fill the slot with data from the index tuple.
260  *
261  * At some point this might be generally-useful functionality, but
262  * right now we don't need it elsewhere.
263  */
264 static void
266 {
267  int nindexatts = itupdesc->natts;
268  Datum *values = slot->tts_values;
269  bool *isnull = slot->tts_isnull;
270  int i;
271 
272  /*
273  * Note: we must use the tupdesc supplied by the AM in index_getattr, not
274  * the slot's tupdesc, in case the latter has different datatypes (this
275  * happens for btree name_ops in particular). They'd better have the same
276  * number of columns though, as well as being datatype-compatible which is
277  * something we can't so easily check.
278  */
279  Assert(slot->tts_tupleDescriptor->natts == nindexatts);
280 
281  ExecClearTuple(slot);
282  for (i = 0; i < nindexatts; i++)
283  values[i] = index_getattr(itup, i + 1, itupdesc, &isnull[i]);
284  ExecStoreVirtualTuple(slot);
285 }
286 
287 /*
288  * IndexOnlyRecheck -- access method routine to recheck a tuple in EvalPlanQual
289  *
290  * This can't really happen, since an index can't supply CTID which would
291  * be necessary data for any potential EvalPlanQual target relation. If it
292  * did happen, the EPQ code would pass us the wrong data, namely a heap
293  * tuple not an index tuple. So throw an error.
294  */
295 static bool
297 {
298  elog(ERROR, "EvalPlanQual recheck is not supported in index-only scans");
299  return false; /* keep compiler quiet */
300 }
301 
302 /* ----------------------------------------------------------------
303  * ExecIndexOnlyScan(node)
304  * ----------------------------------------------------------------
305  */
308 {
309  /*
310  * If we have runtime keys and they've not already been set up, do it now.
311  */
312  if (node->ioss_NumRuntimeKeys != 0 && !node->ioss_RuntimeKeysReady)
313  ExecReScan((PlanState *) node);
314 
315  return ExecScan(&node->ss,
318 }
319 
320 /* ----------------------------------------------------------------
321  * ExecReScanIndexOnlyScan(node)
322  *
323  * Recalculates the values of any scan keys whose value depends on
324  * information known at runtime, then rescans the indexed relation.
325  *
326  * Updating the scan key was formerly done separately in
327  * ExecUpdateIndexScanKeys. Integrating it into ReScan makes
328  * rescans of indices and relations/general streams more uniform.
329  * ----------------------------------------------------------------
330  */
331 void
333 {
334  bool reset_parallel_scan = true;
335 
336  /*
337  * If we are here to just update the scan keys, then don't reset parallel
338  * scan. For detailed reason behind this look in the comments for
339  * ExecReScanIndexScan.
340  */
341  if (node->ioss_NumRuntimeKeys != 0 && !node->ioss_RuntimeKeysReady)
342  reset_parallel_scan = false;
343 
344  /*
345  * If we are doing runtime key calculations (ie, any of the index key
346  * values weren't simple Consts), compute the new key values. But first,
347  * reset the context so we don't leak memory as each outer tuple is
348  * scanned. Note this assumes that we will recalculate *all* runtime keys
349  * on each call.
350  */
351  if (node->ioss_NumRuntimeKeys != 0)
352  {
353  ExprContext *econtext = node->ioss_RuntimeContext;
354 
355  ResetExprContext(econtext);
356  ExecIndexEvalRuntimeKeys(econtext,
357  node->ioss_RuntimeKeys,
358  node->ioss_NumRuntimeKeys);
359  }
360  node->ioss_RuntimeKeysReady = true;
361 
362  /* reset index scan */
363  if (node->ioss_ScanDesc)
364  {
365 
367  node->ioss_ScanKeys, node->ioss_NumScanKeys,
369 
370  if (reset_parallel_scan && node->ioss_ScanDesc->parallel_scan)
372  }
373  ExecScanReScan(&node->ss);
374 }
375 
376 
377 /* ----------------------------------------------------------------
378  * ExecEndIndexOnlyScan
379  * ----------------------------------------------------------------
380  */
381 void
383 {
384  Relation indexRelationDesc;
385  IndexScanDesc indexScanDesc;
386  Relation relation;
387 
388  /*
389  * extract information from the node
390  */
391  indexRelationDesc = node->ioss_RelationDesc;
392  indexScanDesc = node->ioss_ScanDesc;
393  relation = node->ss.ss_currentRelation;
394 
395  /* Release VM buffer pin, if any. */
396  if (node->ioss_VMBuffer != InvalidBuffer)
397  {
400  }
401 
402  /*
403  * Free the exprcontext(s) ... now dead code, see ExecFreeExprContext
404  */
405 #ifdef NOT_USED
406  ExecFreeExprContext(&node->ss.ps);
407  if (node->ioss_RuntimeContext)
409 #endif
410 
411  /*
412  * clear out tuple table slots
413  */
416 
417  /*
418  * close the index relation (no-op if we didn't open it)
419  */
420  if (indexScanDesc)
421  index_endscan(indexScanDesc);
422  if (indexRelationDesc)
423  index_close(indexRelationDesc, NoLock);
424 
425  /*
426  * close the heap relation.
427  */
428  ExecCloseScanRelation(relation);
429 }
430 
431 /* ----------------------------------------------------------------
432  * ExecIndexOnlyMarkPos
433  * ----------------------------------------------------------------
434  */
435 void
437 {
439 }
440 
441 /* ----------------------------------------------------------------
442  * ExecIndexOnlyRestrPos
443  * ----------------------------------------------------------------
444  */
445 void
447 {
449 }
450 
451 /* ----------------------------------------------------------------
452  * ExecInitIndexOnlyScan
453  *
454  * Initializes the index scan's state information, creates
455  * scan keys, and opens the base and index relations.
456  *
457  * Note: index scans have 2 sets of state information because
458  * we have to keep track of the base relation and the
459  * index relation.
460  * ----------------------------------------------------------------
461  */
463 ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
464 {
465  IndexOnlyScanState *indexstate;
466  Relation currentRelation;
467  bool relistarget;
468  TupleDesc tupDesc;
469 
470  /*
471  * create state structure
472  */
473  indexstate = makeNode(IndexOnlyScanState);
474  indexstate->ss.ps.plan = (Plan *) node;
475  indexstate->ss.ps.state = estate;
476  indexstate->ioss_HeapFetches = 0;
477 
478  /*
479  * Miscellaneous initialization
480  *
481  * create expression context for node
482  */
483  ExecAssignExprContext(estate, &indexstate->ss.ps);
484 
485  /*
486  * initialize child expressions
487  *
488  * Note: we don't initialize all of the indexorderby expression, only the
489  * sub-parts corresponding to runtime keys (see below).
490  */
491  indexstate->ss.ps.qual =
492  ExecInitQual(node->scan.plan.qual, (PlanState *) indexstate);
493  indexstate->indexqual =
494  ExecInitQual(node->indexqual, (PlanState *) indexstate);
495 
496  /*
497  * tuple table initialization
498  */
499  ExecInitResultTupleSlot(estate, &indexstate->ss.ps);
500  ExecInitScanTupleSlot(estate, &indexstate->ss);
501 
502  /*
503  * open the base relation and acquire appropriate lock on it.
504  */
505  currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
506 
507  indexstate->ss.ss_currentRelation = currentRelation;
508  indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
509 
510  /*
511  * Build the scan tuple type using the indextlist generated by the
512  * planner. We use this, rather than the index's physical tuple
513  * descriptor, because the latter contains storage column types not the
514  * types of the original datums. (It's the AM's responsibility to return
515  * suitable data anyway.)
516  */
517  tupDesc = ExecTypeFromTL(node->indextlist, false);
518  ExecAssignScanType(&indexstate->ss, tupDesc);
519 
520  /*
521  * Initialize result tuple type and projection info. The node's
522  * targetlist will contain Vars with varno = INDEX_VAR, referencing the
523  * scan tuple.
524  */
525  ExecAssignResultTypeFromTL(&indexstate->ss.ps);
527 
528  /*
529  * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
530  * here. This allows an index-advisor plugin to EXPLAIN a plan containing
531  * references to nonexistent indexes.
532  */
533  if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
534  return indexstate;
535 
536  /*
537  * Open the index relation.
538  *
539  * If the parent table is one of the target relations of the query, then
540  * InitPlan already opened and write-locked the index, so we can avoid
541  * taking another lock here. Otherwise we need a normal reader's lock.
542  */
543  relistarget = ExecRelationIsTargetRelation(estate, node->scan.scanrelid);
544  indexstate->ioss_RelationDesc = index_open(node->indexid,
545  relistarget ? NoLock : AccessShareLock);
546 
547  /*
548  * Initialize index-specific scan state
549  */
550  indexstate->ioss_RuntimeKeysReady = false;
551  indexstate->ioss_RuntimeKeys = NULL;
552  indexstate->ioss_NumRuntimeKeys = 0;
553 
554  /*
555  * build the index scan keys from the index qualification
556  */
557  ExecIndexBuildScanKeys((PlanState *) indexstate,
558  indexstate->ioss_RelationDesc,
559  node->indexqual,
560  false,
561  &indexstate->ioss_ScanKeys,
562  &indexstate->ioss_NumScanKeys,
563  &indexstate->ioss_RuntimeKeys,
564  &indexstate->ioss_NumRuntimeKeys,
565  NULL, /* no ArrayKeys */
566  NULL);
567 
568  /*
569  * any ORDER BY exprs have to be turned into scankeys in the same way
570  */
571  ExecIndexBuildScanKeys((PlanState *) indexstate,
572  indexstate->ioss_RelationDesc,
573  node->indexorderby,
574  true,
575  &indexstate->ioss_OrderByKeys,
576  &indexstate->ioss_NumOrderByKeys,
577  &indexstate->ioss_RuntimeKeys,
578  &indexstate->ioss_NumRuntimeKeys,
579  NULL, /* no ArrayKeys */
580  NULL);
581 
582  /*
583  * If we have runtime keys, we need an ExprContext to evaluate them. The
584  * node's standard context won't do because we want to reset that context
585  * for every tuple. So, build another context just like the other one...
586  * -tgl 7/11/00
587  */
588  if (indexstate->ioss_NumRuntimeKeys != 0)
589  {
590  ExprContext *stdecontext = indexstate->ss.ps.ps_ExprContext;
591 
592  ExecAssignExprContext(estate, &indexstate->ss.ps);
593  indexstate->ioss_RuntimeContext = indexstate->ss.ps.ps_ExprContext;
594  indexstate->ss.ps.ps_ExprContext = stdecontext;
595  }
596  else
597  {
598  indexstate->ioss_RuntimeContext = NULL;
599  }
600 
601  /*
602  * all done.
603  */
604  return indexstate;
605 }
606 
607 /* ----------------------------------------------------------------
608  * Parallel Index-only Scan Support
609  * ----------------------------------------------------------------
610  */
611 
612 /* ----------------------------------------------------------------
613  * ExecIndexOnlyScanEstimate
614  *
615  * estimates the space required to serialize index-only scan node.
616  * ----------------------------------------------------------------
617  */
618 void
620  ParallelContext *pcxt)
621 {
622  EState *estate = node->ss.ps.state;
623 
625  estate->es_snapshot);
627  shm_toc_estimate_keys(&pcxt->estimator, 1);
628 }
629 
630 /* ----------------------------------------------------------------
631  * ExecIndexOnlyScanInitializeDSM
632  *
633  * Set up a parallel index-only scan descriptor.
634  * ----------------------------------------------------------------
635  */
636 void
638  ParallelContext *pcxt)
639 {
640  EState *estate = node->ss.ps.state;
641  ParallelIndexScanDesc piscan;
642 
643  piscan = shm_toc_allocate(pcxt->toc, node->ioss_PscanLen);
645  node->ioss_RelationDesc,
646  estate->es_snapshot,
647  piscan);
648  shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, piscan);
649  node->ioss_ScanDesc =
651  node->ioss_RelationDesc,
652  node->ioss_NumScanKeys,
653  node->ioss_NumOrderByKeys,
654  piscan);
655  node->ioss_ScanDesc->xs_want_itup = true;
657 
658  /*
659  * If no run-time keys to calculate or they are ready, go ahead and pass
660  * the scankeys to the index AM.
661  */
662  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
664  node->ioss_ScanKeys, node->ioss_NumScanKeys,
666 }
667 
668 /* ----------------------------------------------------------------
669  * ExecIndexOnlyScanInitializeWorker
670  *
671  * Copy relevant information from TOC into planstate.
672  * ----------------------------------------------------------------
673  */
674 void
676 {
677  ParallelIndexScanDesc piscan;
678 
679  piscan = shm_toc_lookup(toc, node->ss.ps.plan->plan_node_id);
680  node->ioss_ScanDesc =
682  node->ioss_RelationDesc,
683  node->ioss_NumScanKeys,
684  node->ioss_NumOrderByKeys,
685  piscan);
686  node->ioss_ScanDesc->xs_want_itup = true;
687 
688  /*
689  * If no run-time keys to calculate or they are ready, go ahead and pass
690  * the scankeys to the index AM.
691  */
692  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
694  node->ioss_ScanKeys, node->ioss_NumScanKeys,
696 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1182
ParallelIndexScanDesc parallel_scan
Definition: relscan.h:139
TupleTableSlot * ExecStoreTuple(HeapTuple tuple, TupleTableSlot *slot, Buffer buffer, bool shouldFree)
Definition: execTuples.c:320
List * qual
Definition: plannodes.h:133
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
Definition: predicate.c:2438
Plan plan
Definition: plannodes.h:315
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
Index scanrelid
Definition: plannodes.h:316
void ExecIndexOnlyScanInitializeWorker(IndexOnlyScanState *node, shm_toc *toc)
#define ScanDirectionIsForward(direction)
Definition: sdir.h:55
IndexTuple xs_itup
Definition: relscan.h:113
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:830
shm_toc_estimator estimator
Definition: parallel.h:42
void ExecReScan(PlanState *node)
Definition: execAmi.c:74
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
int plan_node_id
Definition: plannodes.h:131
#define AccessShareLock
Definition: lockdefs.h:36
#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:1180
bool xs_recheckorderby
Definition: relscan.h:133
Snapshot es_snapshot
Definition: execnodes.h:408
Datum * tts_values
Definition: tuptable.h:125
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1047
void ExecReScanIndexOnlyScan(IndexOnlyScanState *node)
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
TupleDesc xs_itupdesc
Definition: relscan.h:114
Relation ss_currentRelation
Definition: execnodes.h:1045
EState * state
Definition: execnodes.h:802
static bool ExecQual(ExprState *state, ExprContext *econtext)
Definition: executor.h:346
#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:511
TupleDesc xs_hitupdesc
Definition: relscan.h:116
ScanDirection es_direction
Definition: execnodes.h:407
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:160
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:435
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:389
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:1044
ScanKey ioss_ScanKeys
Definition: execnodes.h:1176
#define ScanDirectionIsBackward(direction)
Definition: sdir.h:41
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:390
ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
Definition: indexam.c:526
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:829
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:598
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:1183
#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:1185
ScanDirection
Definition: sdir.h:22
bool xs_continue_hot
Definition: relscan.h:136
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:1178
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:888
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
uintptr_t Datum
Definition: postgres.h:372
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:344
Plan * plan
Definition: execnodes.h:800
Relation ioss_RelationDesc
Definition: execnodes.h:1184
List * indextlist
Definition: plannodes.h:408
bool xs_want_itup
Definition: relscan.h:95
List * indexorderby
Definition: plannodes.h:407
#define makeNode(_type_)
Definition: nodes.h:554
#define NULL
Definition: c.h:229
IndexOnlyScanState * ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
#define Assert(condition)
Definition: c.h:675
static void StoreIndexTuple(TupleTableSlot *slot, IndexTuple itup, TupleDesc itupdesc)
static TupleTableSlot * IndexOnlyNext(IndexOnlyScanState *node)
#define InstrCountFiltered2(node, delta)
Definition: execnodes.h:850
#define VM_ALL_VISIBLE(r, b, v)
Definition: visibilitymap.h:32
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:413
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:656
List * indexqual
Definition: plannodes.h:406
ExprState * indexqual
Definition: execnodes.h:1175
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:196
#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)
ExprState * qual
Definition: execnodes.h:814
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:1046
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
HeapTuple xs_hitup
Definition: relscan.h:115
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:535
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:155
#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:572
#define ResetExprContext(econtext)
Definition: executor.h:450
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