PostgreSQL Source Code  git master
nodeIndexonlyscan.h File Reference
#include "access/parallel.h"
#include "nodes/execnodes.h"
Include dependency graph for nodeIndexonlyscan.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

IndexOnlyScanStateExecInitIndexOnlyScan (IndexOnlyScan *node, EState *estate, int eflags)
 
void ExecEndIndexOnlyScan (IndexOnlyScanState *node)
 
void ExecIndexOnlyMarkPos (IndexOnlyScanState *node)
 
void ExecIndexOnlyRestrPos (IndexOnlyScanState *node)
 
void ExecReScanIndexOnlyScan (IndexOnlyScanState *node)
 
void ExecIndexOnlyScanEstimate (IndexOnlyScanState *node, ParallelContext *pcxt)
 
void ExecIndexOnlyScanInitializeDSM (IndexOnlyScanState *node, ParallelContext *pcxt)
 
void ExecIndexOnlyScanReInitializeDSM (IndexOnlyScanState *node, ParallelContext *pcxt)
 
void ExecIndexOnlyScanInitializeWorker (IndexOnlyScanState *node, ParallelWorkerContext *pwcxt)
 

Function Documentation

◆ ExecEndIndexOnlyScan()

void ExecEndIndexOnlyScan ( IndexOnlyScanState node)

Definition at line 398 of file nodeIndexonlyscan.c.

399 {
400  Relation indexRelationDesc;
401  IndexScanDesc indexScanDesc;
402 
403  /*
404  * extract information from the node
405  */
406  indexRelationDesc = node->ioss_RelationDesc;
407  indexScanDesc = node->ioss_ScanDesc;
408 
409  /* Release VM buffer pin, if any. */
410  if (node->ioss_VMBuffer != InvalidBuffer)
411  {
414  }
415 
416  /*
417  * close the index relation (no-op if we didn't open it)
418  */
419  if (indexScanDesc)
420  index_endscan(indexScanDesc);
421  if (indexRelationDesc)
422  index_close(indexRelationDesc, NoLock);
423 }
#define InvalidBuffer
Definition: buf.h:25
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:4936
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:177
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:378
#define NoLock
Definition: lockdefs.h:34
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1709
Relation ioss_RelationDesc
Definition: execnodes.h:1708

References index_close(), index_endscan(), InvalidBuffer, IndexOnlyScanState::ioss_RelationDesc, IndexOnlyScanState::ioss_ScanDesc, IndexOnlyScanState::ioss_VMBuffer, NoLock, and ReleaseBuffer().

Referenced by ExecEndNode().

◆ ExecIndexOnlyMarkPos()

void ExecIndexOnlyMarkPos ( IndexOnlyScanState node)

Definition at line 433 of file nodeIndexonlyscan.c.

434 {
435  EState *estate = node->ss.ps.state;
436  EPQState *epqstate = estate->es_epq_active;
437 
438  if (epqstate != NULL)
439  {
440  /*
441  * We are inside an EvalPlanQual recheck. If a test tuple exists for
442  * this relation, then we shouldn't access the index at all. We would
443  * instead need to save, and later restore, the state of the
444  * relsubs_done flag, so that re-fetching the test tuple is possible.
445  * However, given the assumption that no caller sets a mark at the
446  * start of the scan, we can only get here with relsubs_done[i]
447  * already set, and so no state need be saved.
448  */
449  Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
450 
451  Assert(scanrelid > 0);
452  if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
453  epqstate->relsubs_rowmark[scanrelid - 1] != NULL)
454  {
455  /* Verify the claim above */
456  if (!epqstate->relsubs_done[scanrelid - 1])
457  elog(ERROR, "unexpected ExecIndexOnlyMarkPos call in EPQ recheck");
458  return;
459  }
460  }
461 
463 }
#define Assert(condition)
Definition: c.h:858
unsigned int Index
Definition: c.h:614
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:224
void index_markpos(IndexScanDesc scan)
Definition: indexam.c:408
ExecAuxRowMark ** relsubs_rowmark
Definition: execnodes.h:1291
TupleTableSlot ** relsubs_slot
Definition: execnodes.h:1263
bool * relsubs_done
Definition: execnodes.h:1298
struct EPQState * es_epq_active
Definition: execnodes.h:699
Plan * plan
Definition: execnodes.h:1116
EState * state
Definition: execnodes.h:1118
PlanState ps
Definition: execnodes.h:1563

References Assert, elog, ERROR, EState::es_epq_active, index_markpos(), IndexOnlyScanState::ioss_ScanDesc, PlanState::plan, ScanState::ps, EPQState::relsubs_done, EPQState::relsubs_rowmark, EPQState::relsubs_slot, IndexOnlyScanState::ss, and PlanState::state.

Referenced by ExecMarkPos().

◆ ExecIndexOnlyRestrPos()

void ExecIndexOnlyRestrPos ( IndexOnlyScanState node)

Definition at line 470 of file nodeIndexonlyscan.c.

471 {
472  EState *estate = node->ss.ps.state;
473  EPQState *epqstate = estate->es_epq_active;
474 
475  if (estate->es_epq_active != NULL)
476  {
477  /* See comments in ExecIndexMarkPos */
478  Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
479 
480  Assert(scanrelid > 0);
481  if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
482  epqstate->relsubs_rowmark[scanrelid - 1] != NULL)
483  {
484  /* Verify the claim above */
485  if (!epqstate->relsubs_done[scanrelid - 1])
486  elog(ERROR, "unexpected ExecIndexOnlyRestrPos call in EPQ recheck");
487  return;
488  }
489  }
490 
492 }
void index_restrpos(IndexScanDesc scan)
Definition: indexam.c:432

References Assert, elog, ERROR, EState::es_epq_active, index_restrpos(), IndexOnlyScanState::ioss_ScanDesc, PlanState::plan, ScanState::ps, EPQState::relsubs_done, EPQState::relsubs_rowmark, EPQState::relsubs_slot, IndexOnlyScanState::ss, and PlanState::state.

Referenced by ExecRestrPos().

◆ ExecIndexOnlyScanEstimate()

void ExecIndexOnlyScanEstimate ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 706 of file nodeIndexonlyscan.c.

708 {
709  EState *estate = node->ss.ps.state;
710 
712  node->ioss_NumScanKeys,
713  node->ioss_NumOrderByKeys,
714  estate->es_snapshot);
716  shm_toc_estimate_keys(&pcxt->estimator, 1);
717 }
Size index_parallelscan_estimate(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot)
Definition: indexam.c:453
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:51
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:53
Snapshot es_snapshot
Definition: execnodes.h:624
shm_toc_estimator estimator
Definition: parallel.h:41

References EState::es_snapshot, ParallelContext::estimator, index_parallelscan_estimate(), IndexOnlyScanState::ioss_NumOrderByKeys, IndexOnlyScanState::ioss_NumScanKeys, IndexOnlyScanState::ioss_PscanLen, IndexOnlyScanState::ioss_RelationDesc, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, IndexOnlyScanState::ss, and PlanState::state.

Referenced by ExecParallelEstimate().

◆ ExecIndexOnlyScanInitializeDSM()

void ExecIndexOnlyScanInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 726 of file nodeIndexonlyscan.c.

728 {
729  EState *estate = node->ss.ps.state;
730  ParallelIndexScanDesc piscan;
731 
732  piscan = shm_toc_allocate(pcxt->toc, node->ioss_PscanLen);
734  node->ioss_RelationDesc,
735  estate->es_snapshot,
736  piscan);
737  shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, piscan);
738  node->ioss_ScanDesc =
740  node->ioss_RelationDesc,
741  node->ioss_NumScanKeys,
742  node->ioss_NumOrderByKeys,
743  piscan);
744  node->ioss_ScanDesc->xs_want_itup = true;
746 
747  /*
748  * If no run-time keys to calculate or they are ready, go ahead and pass
749  * the scankeys to the index AM.
750  */
751  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
753  node->ioss_ScanKeys, node->ioss_NumScanKeys,
755 }
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition: indexam.c:541
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, ParallelIndexScanDesc target)
Definition: indexam.c:490
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:352
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:171
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:88
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1706
struct ScanKeyData * ioss_ScanKeys
Definition: execnodes.h:1700
struct ScanKeyData * ioss_OrderByKeys
Definition: execnodes.h:1702
shm_toc * toc
Definition: parallel.h:44
int plan_node_id
Definition: plannodes.h:151
Relation ss_currentRelation
Definition: execnodes.h:1564

References EState::es_snapshot, index_beginscan_parallel(), index_parallelscan_initialize(), index_rescan(), InvalidBuffer, IndexOnlyScanState::ioss_NumOrderByKeys, IndexOnlyScanState::ioss_NumRuntimeKeys, IndexOnlyScanState::ioss_NumScanKeys, IndexOnlyScanState::ioss_OrderByKeys, IndexOnlyScanState::ioss_PscanLen, IndexOnlyScanState::ioss_RelationDesc, IndexOnlyScanState::ioss_RuntimeKeysReady, IndexOnlyScanState::ioss_ScanDesc, IndexOnlyScanState::ioss_ScanKeys, IndexOnlyScanState::ioss_VMBuffer, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_allocate(), shm_toc_insert(), IndexOnlyScanState::ss, ScanState::ss_currentRelation, PlanState::state, ParallelContext::toc, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeDSM().

◆ ExecIndexOnlyScanInitializeWorker()

void ExecIndexOnlyScanInitializeWorker ( IndexOnlyScanState node,
ParallelWorkerContext pwcxt 
)

Definition at line 777 of file nodeIndexonlyscan.c.

779 {
780  ParallelIndexScanDesc piscan;
781 
782  piscan = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
783  node->ioss_ScanDesc =
785  node->ioss_RelationDesc,
786  node->ioss_NumScanKeys,
787  node->ioss_NumOrderByKeys,
788  piscan);
789  node->ioss_ScanDesc->xs_want_itup = true;
790 
791  /*
792  * If no run-time keys to calculate or they are ready, go ahead and pass
793  * the scankeys to the index AM.
794  */
795  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
797  node->ioss_ScanKeys, node->ioss_NumScanKeys,
799 }
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition: shm_toc.c:232

References index_beginscan_parallel(), index_rescan(), IndexOnlyScanState::ioss_NumOrderByKeys, IndexOnlyScanState::ioss_NumRuntimeKeys, IndexOnlyScanState::ioss_NumScanKeys, IndexOnlyScanState::ioss_OrderByKeys, IndexOnlyScanState::ioss_RelationDesc, IndexOnlyScanState::ioss_RuntimeKeysReady, IndexOnlyScanState::ioss_ScanDesc, IndexOnlyScanState::ioss_ScanKeys, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_lookup(), IndexOnlyScanState::ss, ScanState::ss_currentRelation, ParallelWorkerContext::toc, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeWorker().

◆ ExecIndexOnlyScanReInitializeDSM()

void ExecIndexOnlyScanReInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 764 of file nodeIndexonlyscan.c.

766 {
768 }
void index_parallelrescan(IndexScanDesc scan)
Definition: indexam.c:523

References index_parallelrescan(), and IndexOnlyScanState::ioss_ScanDesc.

Referenced by ExecParallelReInitializeDSM().

◆ ExecInitIndexOnlyScan()

IndexOnlyScanState* ExecInitIndexOnlyScan ( IndexOnlyScan node,
EState estate,
int  eflags 
)

Definition at line 506 of file nodeIndexonlyscan.c.

507 {
508  IndexOnlyScanState *indexstate;
509  Relation currentRelation;
510  Relation indexRelation;
511  LOCKMODE lockmode;
512  TupleDesc tupDesc;
513  int indnkeyatts;
514  int namecount;
515 
516  /*
517  * create state structure
518  */
519  indexstate = makeNode(IndexOnlyScanState);
520  indexstate->ss.ps.plan = (Plan *) node;
521  indexstate->ss.ps.state = estate;
522  indexstate->ss.ps.ExecProcNode = ExecIndexOnlyScan;
523 
524  /*
525  * Miscellaneous initialization
526  *
527  * create expression context for node
528  */
529  ExecAssignExprContext(estate, &indexstate->ss.ps);
530 
531  /*
532  * open the scan relation
533  */
534  currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
535 
536  indexstate->ss.ss_currentRelation = currentRelation;
537  indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
538 
539  /*
540  * Build the scan tuple type using the indextlist generated by the
541  * planner. We use this, rather than the index's physical tuple
542  * descriptor, because the latter contains storage column types not the
543  * types of the original datums. (It's the AM's responsibility to return
544  * suitable data anyway.)
545  */
546  tupDesc = ExecTypeFromTL(node->indextlist);
547  ExecInitScanTupleSlot(estate, &indexstate->ss, tupDesc,
548  &TTSOpsVirtual);
549 
550  /*
551  * We need another slot, in a format that's suitable for the table AM, for
552  * when we need to fetch a tuple from the table for rechecking visibility.
553  */
554  indexstate->ioss_TableSlot =
556  RelationGetDescr(currentRelation),
557  table_slot_callbacks(currentRelation));
558 
559  /*
560  * Initialize result type and projection info. The node's targetlist will
561  * contain Vars with varno = INDEX_VAR, referencing the scan tuple.
562  */
563  ExecInitResultTypeTL(&indexstate->ss.ps);
565 
566  /*
567  * initialize child expressions
568  *
569  * Note: we don't initialize all of the indexorderby expression, only the
570  * sub-parts corresponding to runtime keys (see below).
571  */
572  indexstate->ss.ps.qual =
573  ExecInitQual(node->scan.plan.qual, (PlanState *) indexstate);
574  indexstate->recheckqual =
575  ExecInitQual(node->recheckqual, (PlanState *) indexstate);
576 
577  /*
578  * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
579  * here. This allows an index-advisor plugin to EXPLAIN a plan containing
580  * references to nonexistent indexes.
581  */
582  if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
583  return indexstate;
584 
585  /* Open the index relation. */
586  lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
587  indexRelation = index_open(node->indexid, lockmode);
588  indexstate->ioss_RelationDesc = indexRelation;
589 
590  /*
591  * Initialize index-specific scan state
592  */
593  indexstate->ioss_RuntimeKeysReady = false;
594  indexstate->ioss_RuntimeKeys = NULL;
595  indexstate->ioss_NumRuntimeKeys = 0;
596 
597  /*
598  * build the index scan keys from the index qualification
599  */
600  ExecIndexBuildScanKeys((PlanState *) indexstate,
601  indexRelation,
602  node->indexqual,
603  false,
604  &indexstate->ioss_ScanKeys,
605  &indexstate->ioss_NumScanKeys,
606  &indexstate->ioss_RuntimeKeys,
607  &indexstate->ioss_NumRuntimeKeys,
608  NULL, /* no ArrayKeys */
609  NULL);
610 
611  /*
612  * any ORDER BY exprs have to be turned into scankeys in the same way
613  */
614  ExecIndexBuildScanKeys((PlanState *) indexstate,
615  indexRelation,
616  node->indexorderby,
617  true,
618  &indexstate->ioss_OrderByKeys,
619  &indexstate->ioss_NumOrderByKeys,
620  &indexstate->ioss_RuntimeKeys,
621  &indexstate->ioss_NumRuntimeKeys,
622  NULL, /* no ArrayKeys */
623  NULL);
624 
625  /*
626  * If we have runtime keys, we need an ExprContext to evaluate them. The
627  * node's standard context won't do because we want to reset that context
628  * for every tuple. So, build another context just like the other one...
629  * -tgl 7/11/00
630  */
631  if (indexstate->ioss_NumRuntimeKeys != 0)
632  {
633  ExprContext *stdecontext = indexstate->ss.ps.ps_ExprContext;
634 
635  ExecAssignExprContext(estate, &indexstate->ss.ps);
636  indexstate->ioss_RuntimeContext = indexstate->ss.ps.ps_ExprContext;
637  indexstate->ss.ps.ps_ExprContext = stdecontext;
638  }
639  else
640  {
641  indexstate->ioss_RuntimeContext = NULL;
642  }
643 
644  indexstate->ioss_NameCStringAttNums = NULL;
645  indnkeyatts = indexRelation->rd_index->indnkeyatts;
646  namecount = 0;
647 
648  /*
649  * The "name" type for btree uses text_ops which results in storing
650  * cstrings in the indexed keys rather than names. Here we detect that in
651  * a generic way in case other index AMs want to do the same optimization.
652  * Check for opclasses with an opcintype of NAMEOID and an index tuple
653  * descriptor with CSTRINGOID. If any of these are found, create an array
654  * marking the index attribute number of each of them. StoreIndexTuple()
655  * handles copying the name Datums into a NAMEDATALEN-byte allocation.
656  */
657 
658  /* First, count the number of such index keys */
659  for (int attnum = 0; attnum < indnkeyatts; attnum++)
660  {
661  if (TupleDescAttr(indexRelation->rd_att, attnum)->atttypid == CSTRINGOID &&
662  indexRelation->rd_opcintype[attnum] == NAMEOID)
663  namecount++;
664  }
665 
666  if (namecount > 0)
667  {
668  int idx = 0;
669 
670  /*
671  * Now create an array to mark the attribute numbers of the keys that
672  * need to be converted from cstring to name.
673  */
674  indexstate->ioss_NameCStringAttNums = (AttrNumber *)
675  palloc(sizeof(AttrNumber) * namecount);
676 
677  for (int attnum = 0; attnum < indnkeyatts; attnum++)
678  {
679  if (TupleDescAttr(indexRelation->rd_att, attnum)->atttypid == CSTRINGOID &&
680  indexRelation->rd_opcintype[attnum] == NAMEOID)
681  indexstate->ioss_NameCStringAttNums[idx++] = (AttrNumber) attnum;
682  }
683  }
684 
685  indexstate->ioss_NameCStringCount = namecount;
686 
687  /*
688  * all done.
689  */
690  return indexstate;
691 }
Datum idx(PG_FUNCTION_ARGS)
Definition: _int_op.c:259
int16 AttrNumber
Definition: attnum.h:21
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:220
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno)
Definition: execScan.c:283
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1898
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1842
TupleDesc ExecTypeFromTL(List *targetList)
Definition: execTuples.c:2025
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1258
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:483
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:697
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition: executor.h:587
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:65
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:133
int LOCKMODE
Definition: lockdefs.h:26
void * palloc(Size size)
Definition: mcxt.c:1317
static TupleTableSlot * ExecIndexOnlyScan(PlanState *pstate)
void ExecIndexBuildScanKeys(PlanState *planstate, Relation index, List *quals, bool isorderby, ScanKey *scanKeys, int *numScanKeys, IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys, IndexArrayKeyInfo **arrayKeys, int *numArrayKeys)
#define makeNode(_type_)
Definition: nodes.h:155
int16 attnum
Definition: pg_attribute.h:74
#define INDEX_VAR
Definition: primnodes.h:238
#define RelationGetDescr(relation)
Definition: rel.h:531
List * es_tupleTable
Definition: execnodes.h:669
TupleTableSlot * ioss_TableSlot
Definition: execnodes.h:1710
ExprState * recheckqual
Definition: execnodes.h:1699
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1707
AttrNumber * ioss_NameCStringAttNums
Definition: execnodes.h:1713
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1704
List * indexqual
Definition: plannodes.h:496
List * recheckqual
Definition: plannodes.h:497
List * indextlist
Definition: plannodes.h:499
List * indexorderby
Definition: plannodes.h:498
ExprState * qual
Definition: execnodes.h:1137
ExprContext * ps_ExprContext
Definition: execnodes.h:1155
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1122
Oid * rd_opcintype
Definition: rel.h:208
TupleDesc rd_att
Definition: rel.h:112
Form_pg_index rd_index
Definition: rel.h:192
struct TableScanDescData * ss_currentScanDesc
Definition: execnodes.h:1565
Index scanrelid
Definition: plannodes.h:389
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition: tableam.c:58
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92

References attnum, EState::es_tupleTable, EXEC_FLAG_EXPLAIN_ONLY, exec_rt_fetch(), ExecAllocTableSlot(), ExecAssignExprContext(), ExecAssignScanProjectionInfoWithVarno(), ExecIndexBuildScanKeys(), ExecIndexOnlyScan(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), PlanState::ExecProcNode, ExecTypeFromTL(), idx(), index_open(), INDEX_VAR, IndexOnlyScan::indexid, IndexOnlyScan::indexorderby, IndexOnlyScan::indexqual, IndexOnlyScan::indextlist, IndexOnlyScanState::ioss_NameCStringAttNums, IndexOnlyScanState::ioss_NameCStringCount, IndexOnlyScanState::ioss_NumOrderByKeys, IndexOnlyScanState::ioss_NumRuntimeKeys, IndexOnlyScanState::ioss_NumScanKeys, IndexOnlyScanState::ioss_OrderByKeys, IndexOnlyScanState::ioss_RelationDesc, IndexOnlyScanState::ioss_RuntimeContext, IndexOnlyScanState::ioss_RuntimeKeys, IndexOnlyScanState::ioss_RuntimeKeysReady, IndexOnlyScanState::ioss_ScanKeys, IndexOnlyScanState::ioss_TableSlot, makeNode, palloc(), PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, PlanState::qual, RelationData::rd_att, RelationData::rd_index, RelationData::rd_opcintype, IndexOnlyScanState::recheckqual, IndexOnlyScan::recheckqual, RelationGetDescr, IndexOnlyScan::scan, Scan::scanrelid, IndexOnlyScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, PlanState::state, table_slot_callbacks(), TTSOpsVirtual, and TupleDescAttr.

Referenced by ExecInitNode().

◆ ExecReScanIndexOnlyScan()

void ExecReScanIndexOnlyScan ( IndexOnlyScanState node)

Definition at line 363 of file nodeIndexonlyscan.c.

364 {
365  /*
366  * If we are doing runtime key calculations (ie, any of the index key
367  * values weren't simple Consts), compute the new key values. But first,
368  * reset the context so we don't leak memory as each outer tuple is
369  * scanned. Note this assumes that we will recalculate *all* runtime keys
370  * on each call.
371  */
372  if (node->ioss_NumRuntimeKeys != 0)
373  {
374  ExprContext *econtext = node->ioss_RuntimeContext;
375 
376  ResetExprContext(econtext);
377  ExecIndexEvalRuntimeKeys(econtext,
378  node->ioss_RuntimeKeys,
379  node->ioss_NumRuntimeKeys);
380  }
381  node->ioss_RuntimeKeysReady = true;
382 
383  /* reset index scan */
384  if (node->ioss_ScanDesc)
386  node->ioss_ScanKeys, node->ioss_NumScanKeys,
388 
389  ExecScanReScan(&node->ss);
390 }
void ExecScanReScan(ScanState *node)
Definition: execScan.c:297
#define ResetExprContext(econtext)
Definition: executor.h:544
void ExecIndexEvalRuntimeKeys(ExprContext *econtext, IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)

References ExecIndexEvalRuntimeKeys(), ExecScanReScan(), index_rescan(), IndexOnlyScanState::ioss_NumOrderByKeys, IndexOnlyScanState::ioss_NumRuntimeKeys, IndexOnlyScanState::ioss_NumScanKeys, IndexOnlyScanState::ioss_OrderByKeys, IndexOnlyScanState::ioss_RuntimeContext, IndexOnlyScanState::ioss_RuntimeKeys, IndexOnlyScanState::ioss_RuntimeKeysReady, IndexOnlyScanState::ioss_ScanDesc, IndexOnlyScanState::ioss_ScanKeys, ResetExprContext, and IndexOnlyScanState::ss.

Referenced by ExecReScan().