PostgreSQL Source Code  git master
nodeIndexonlyscan.h File Reference
#include "nodes/execnodes.h"
#include "access/parallel.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 369 of file nodeIndexonlyscan.c.

References ExecClearTuple(), ExecFreeExprContext(), FreeExprContext(), index_close(), index_endscan(), InvalidBuffer, IndexOnlyScanState::ioss_RelationDesc, IndexOnlyScanState::ioss_RuntimeContext, IndexOnlyScanState::ioss_ScanDesc, IndexOnlyScanState::ioss_VMBuffer, NoLock, ScanState::ps, PlanState::ps_ResultTupleSlot, ReleaseBuffer(), IndexOnlyScanState::ss, and ScanState::ss_ScanTupleSlot.

Referenced by ExecEndNode().

370 {
371  Relation indexRelationDesc;
372  IndexScanDesc indexScanDesc;
373 
374  /*
375  * extract information from the node
376  */
377  indexRelationDesc = node->ioss_RelationDesc;
378  indexScanDesc = node->ioss_ScanDesc;
379 
380  /* Release VM buffer pin, if any. */
381  if (node->ioss_VMBuffer != InvalidBuffer)
382  {
385  }
386 
387  /*
388  * Free the exprcontext(s) ... now dead code, see ExecFreeExprContext
389  */
390 #ifdef NOT_USED
391  ExecFreeExprContext(&node->ss.ps);
392  if (node->ioss_RuntimeContext)
394 #endif
395 
396  /*
397  * clear out tuple table slots
398  */
399  if (node->ss.ps.ps_ResultTupleSlot)
402 
403  /*
404  * close the index relation (no-op if we didn't open it)
405  */
406  if (indexScanDesc)
407  index_endscan(indexScanDesc);
408  if (indexRelationDesc)
409  index_close(indexRelationDesc, NoLock);
410 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
#define InvalidBuffer
Definition: buf.h:25
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1334
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3365
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:614
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
PlanState ps
Definition: execnodes.h:1331
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:978
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1473
#define NoLock
Definition: lockdefs.h:34
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:315
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:375
Relation ioss_RelationDesc
Definition: execnodes.h:1474
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:152

◆ ExecIndexOnlyMarkPos()

void ExecIndexOnlyMarkPos ( IndexOnlyScanState node)

Definition at line 420 of file nodeIndexonlyscan.c.

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().

421 {
422  EState *estate = node->ss.ps.state;
423  EPQState *epqstate = estate->es_epq_active;
424 
425  if (epqstate != NULL)
426  {
427  /*
428  * We are inside an EvalPlanQual recheck. If a test tuple exists for
429  * this relation, then we shouldn't access the index at all. We would
430  * instead need to save, and later restore, the state of the
431  * relsubs_done flag, so that re-fetching the test tuple is possible.
432  * However, given the assumption that no caller sets a mark at the
433  * start of the scan, we can only get here with relsubs_done[i]
434  * already set, and so no state need be saved.
435  */
436  Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
437 
438  Assert(scanrelid > 0);
439  if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
440  epqstate->relsubs_rowmark[scanrelid - 1] != NULL)
441  {
442  /* Verify the claim above */
443  if (!epqstate->relsubs_done[scanrelid - 1])
444  elog(ERROR, "unexpected ExecIndexOnlyMarkPos call in EPQ recheck");
445  return;
446  }
447  }
448 
450 }
TupleTableSlot ** relsubs_slot
Definition: execnodes.h:1085
void index_markpos(IndexScanDesc scan)
Definition: indexam.c:345
EState * state
Definition: execnodes.h:942
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
struct EPQState * es_epq_active
Definition: execnodes.h:579
PlanState ps
Definition: execnodes.h:1331
#define ERROR
Definition: elog.h:43
bool * relsubs_done
Definition: execnodes.h:1119
unsigned int Index
Definition: c.h:475
Plan * plan
Definition: execnodes.h:940
#define Assert(condition)
Definition: c.h:732
#define elog(elevel,...)
Definition: elog.h:226
ExecAuxRowMark ** relsubs_rowmark
Definition: execnodes.h:1113

◆ ExecIndexOnlyRestrPos()

void ExecIndexOnlyRestrPos ( IndexOnlyScanState node)

Definition at line 457 of file nodeIndexonlyscan.c.

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().

458 {
459  EState *estate = node->ss.ps.state;
460  EPQState *epqstate = estate->es_epq_active;
461 
462  if (estate->es_epq_active != NULL)
463  {
464  /* See comments in ExecIndexMarkPos */
465  Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
466 
467  Assert(scanrelid > 0);
468  if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
469  epqstate->relsubs_rowmark[scanrelid - 1] != NULL)
470  {
471  /* Verify the claim above */
472  if (!epqstate->relsubs_done[scanrelid - 1])
473  elog(ERROR, "unexpected ExecIndexOnlyRestrPos call in EPQ recheck");
474  return;
475  }
476  }
477 
479 }
TupleTableSlot ** relsubs_slot
Definition: execnodes.h:1085
EState * state
Definition: execnodes.h:942
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
struct EPQState * es_epq_active
Definition: execnodes.h:579
void index_restrpos(IndexScanDesc scan)
Definition: indexam.c:369
PlanState ps
Definition: execnodes.h:1331
#define ERROR
Definition: elog.h:43
bool * relsubs_done
Definition: execnodes.h:1119
unsigned int Index
Definition: c.h:475
Plan * plan
Definition: execnodes.h:940
#define Assert(condition)
Definition: c.h:732
#define elog(elevel,...)
Definition: elog.h:226
ExecAuxRowMark ** relsubs_rowmark
Definition: execnodes.h:1113

◆ ExecIndexOnlyScanEstimate()

void ExecIndexOnlyScanEstimate ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 646 of file nodeIndexonlyscan.c.

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

Referenced by ExecParallelEstimate().

648 {
649  EState *estate = node->ss.ps.state;
650 
652  estate->es_snapshot);
654  shm_toc_estimate_keys(&pcxt->estimator, 1);
655 }
shm_toc_estimator estimator
Definition: parallel.h:41
Snapshot es_snapshot
Definition: execnodes.h:503
EState * state
Definition: execnodes.h:942
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:51
Size index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
Definition: indexam.c:394
PlanState ps
Definition: execnodes.h:1331
Relation ioss_RelationDesc
Definition: execnodes.h:1474
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:53

◆ ExecIndexOnlyScanInitializeDSM()

void ExecIndexOnlyScanInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 664 of file nodeIndexonlyscan.c.

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().

666 {
667  EState *estate = node->ss.ps.state;
668  ParallelIndexScanDesc piscan;
669 
670  piscan = shm_toc_allocate(pcxt->toc, node->ioss_PscanLen);
672  node->ioss_RelationDesc,
673  estate->es_snapshot,
674  piscan);
675  shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, piscan);
676  node->ioss_ScanDesc =
678  node->ioss_RelationDesc,
679  node->ioss_NumScanKeys,
680  node->ioss_NumOrderByKeys,
681  piscan);
682  node->ioss_ScanDesc->xs_want_itup = true;
684 
685  /*
686  * If no run-time keys to calculate or they are ready, go ahead and pass
687  * the scankeys to the index AM.
688  */
689  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
691  node->ioss_ScanKeys, node->ioss_NumScanKeys,
693 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1472
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition: indexam.c:476
int plan_node_id
Definition: plannodes.h:139
#define InvalidBuffer
Definition: buf.h:25
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:289
Snapshot es_snapshot
Definition: execnodes.h:503
Relation ss_currentRelation
Definition: execnodes.h:1332
EState * state
Definition: execnodes.h:942
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
PlanState ps
Definition: execnodes.h:1331
struct ScanKeyData * ioss_ScanKeys
Definition: execnodes.h:1466
struct ScanKeyData * ioss_OrderByKeys
Definition: execnodes.h:1468
Plan * plan
Definition: execnodes.h:940
Relation ioss_RelationDesc
Definition: execnodes.h:1474
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:88
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:171
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, ParallelIndexScanDesc target)
Definition: indexam.c:427
shm_toc * toc
Definition: parallel.h:44

◆ ExecIndexOnlyScanInitializeWorker()

void ExecIndexOnlyScanInitializeWorker ( IndexOnlyScanState node,
ParallelWorkerContext pwcxt 
)

Definition at line 715 of file nodeIndexonlyscan.c.

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().

717 {
718  ParallelIndexScanDesc piscan;
719 
720  piscan = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
721  node->ioss_ScanDesc =
723  node->ioss_RelationDesc,
724  node->ioss_NumScanKeys,
725  node->ioss_NumOrderByKeys,
726  piscan);
727  node->ioss_ScanDesc->xs_want_itup = true;
728 
729  /*
730  * If no run-time keys to calculate or they are ready, go ahead and pass
731  * the scankeys to the index AM.
732  */
733  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
735  node->ioss_ScanKeys, node->ioss_NumScanKeys,
737 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1472
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition: indexam.c:476
int plan_node_id
Definition: plannodes.h:139
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:289
Relation ss_currentRelation
Definition: execnodes.h:1332
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
PlanState ps
Definition: execnodes.h:1331
struct ScanKeyData * ioss_ScanKeys
Definition: execnodes.h:1466
struct ScanKeyData * ioss_OrderByKeys
Definition: execnodes.h:1468
Plan * plan
Definition: execnodes.h:940
Relation ioss_RelationDesc
Definition: execnodes.h:1474
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition: shm_toc.c:232

◆ ExecIndexOnlyScanReInitializeDSM()

void ExecIndexOnlyScanReInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 702 of file nodeIndexonlyscan.c.

References index_parallelrescan(), and IndexOnlyScanState::ioss_ScanDesc.

Referenced by ExecParallelReInitializeDSM().

704 {
706 }
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
void index_parallelrescan(IndexScanDesc scan)
Definition: indexam.c:458

◆ ExecInitIndexOnlyScan()

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

Definition at line 493 of file nodeIndexonlyscan.c.

References EState::es_tupleTable, EXEC_FLAG_EXPLAIN_ONLY, exec_rt_fetch(), ExecAllocTableSlot(), ExecAssignExprContext(), ExecAssignScanProjectionInfoWithVarno(), ExecIndexBuildScanKeys(), ExecIndexOnlyScan(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), PlanState::ExecProcNode, ExecTypeFromTL(), index_open(), INDEX_VAR, IndexOnlyScan::indexid, IndexOnlyScan::indexorderby, IndexOnlyScan::indexqual, IndexOnlyScan::indextlist, IndexOnlyScanState::ioss_TableSlot, makeNode, Scan::plan, PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, Plan::qual, PlanState::qual, RelationGetDescr, RangeTblEntry::rellockmode, IndexOnlyScan::scan, Scan::scanrelid, IndexOnlyScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, PlanState::state, table_slot_callbacks(), and TTSOpsVirtual.

Referenced by ExecInitNode().

494 {
495  IndexOnlyScanState *indexstate;
496  Relation currentRelation;
497  LOCKMODE lockmode;
498  TupleDesc tupDesc;
499 
500  /*
501  * create state structure
502  */
503  indexstate = makeNode(IndexOnlyScanState);
504  indexstate->ss.ps.plan = (Plan *) node;
505  indexstate->ss.ps.state = estate;
506  indexstate->ss.ps.ExecProcNode = ExecIndexOnlyScan;
507 
508  /*
509  * Miscellaneous initialization
510  *
511  * create expression context for node
512  */
513  ExecAssignExprContext(estate, &indexstate->ss.ps);
514 
515  /*
516  * open the scan relation
517  */
518  currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
519 
520  indexstate->ss.ss_currentRelation = currentRelation;
521  indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
522 
523  /*
524  * Build the scan tuple type using the indextlist generated by the
525  * planner. We use this, rather than the index's physical tuple
526  * descriptor, because the latter contains storage column types not the
527  * types of the original datums. (It's the AM's responsibility to return
528  * suitable data anyway.)
529  */
530  tupDesc = ExecTypeFromTL(node->indextlist);
531  ExecInitScanTupleSlot(estate, &indexstate->ss, tupDesc,
532  &TTSOpsVirtual);
533 
534  /*
535  * We need another slot, in a format that's suitable for the table AM, for
536  * when we need to fetch a tuple from the table for rechecking visibility.
537  */
538  indexstate->ioss_TableSlot =
540  RelationGetDescr(currentRelation),
541  table_slot_callbacks(currentRelation));
542 
543  /*
544  * Initialize result type and projection info. The node's targetlist will
545  * contain Vars with varno = INDEX_VAR, referencing the scan tuple.
546  */
547  ExecInitResultTypeTL(&indexstate->ss.ps);
549 
550  /*
551  * initialize child expressions
552  *
553  * Note: we don't initialize all of the indexorderby expression, only the
554  * sub-parts corresponding to runtime keys (see below).
555  */
556  indexstate->ss.ps.qual =
557  ExecInitQual(node->scan.plan.qual, (PlanState *) indexstate);
558  indexstate->indexqual =
559  ExecInitQual(node->indexqual, (PlanState *) indexstate);
560 
561  /*
562  * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
563  * here. This allows an index-advisor plugin to EXPLAIN a plan containing
564  * references to nonexistent indexes.
565  */
566  if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
567  return indexstate;
568 
569  /* Open the index relation. */
570  lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
571  indexstate->ioss_RelationDesc = index_open(node->indexid, lockmode);
572 
573  /*
574  * Initialize index-specific scan state
575  */
576  indexstate->ioss_RuntimeKeysReady = false;
577  indexstate->ioss_RuntimeKeys = NULL;
578  indexstate->ioss_NumRuntimeKeys = 0;
579 
580  /*
581  * build the index scan keys from the index qualification
582  */
583  ExecIndexBuildScanKeys((PlanState *) indexstate,
584  indexstate->ioss_RelationDesc,
585  node->indexqual,
586  false,
587  &indexstate->ioss_ScanKeys,
588  &indexstate->ioss_NumScanKeys,
589  &indexstate->ioss_RuntimeKeys,
590  &indexstate->ioss_NumRuntimeKeys,
591  NULL, /* no ArrayKeys */
592  NULL);
593 
594  /*
595  * any ORDER BY exprs have to be turned into scankeys in the same way
596  */
597  ExecIndexBuildScanKeys((PlanState *) indexstate,
598  indexstate->ioss_RelationDesc,
599  node->indexorderby,
600  true,
601  &indexstate->ioss_OrderByKeys,
602  &indexstate->ioss_NumOrderByKeys,
603  &indexstate->ioss_RuntimeKeys,
604  &indexstate->ioss_NumRuntimeKeys,
605  NULL, /* no ArrayKeys */
606  NULL);
607 
608  /*
609  * If we have runtime keys, we need an ExprContext to evaluate them. The
610  * node's standard context won't do because we want to reset that context
611  * for every tuple. So, build another context just like the other one...
612  * -tgl 7/11/00
613  */
614  if (indexstate->ioss_NumRuntimeKeys != 0)
615  {
616  ExprContext *stdecontext = indexstate->ss.ps.ps_ExprContext;
617 
618  ExecAssignExprContext(estate, &indexstate->ss.ps);
619  indexstate->ioss_RuntimeContext = indexstate->ss.ps.ps_ExprContext;
620  indexstate->ss.ps.ps_ExprContext = stdecontext;
621  }
622  else
623  {
624  indexstate->ioss_RuntimeContext = NULL;
625  }
626 
627  /*
628  * all done.
629  */
630  return indexstate;
631 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1472
List * qual
Definition: plannodes.h:141
Plan plan
Definition: plannodes.h:340
TupleTableSlot * ioss_TableSlot
Definition: execnodes.h:1476
Index scanrelid
Definition: plannodes.h:341
#define RelationGetDescr(relation)
Definition: rel.h:445
int LOCKMODE
Definition: lockdefs.h:26
ExprContext * ps_ExprContext
Definition: execnodes.h:979
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition: tableam.c:44
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
struct TableScanDescData * ss_currentScanDesc
Definition: execnodes.h:1333
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1470
Relation ss_currentRelation
Definition: execnodes.h:1332
EState * state
Definition: execnodes.h:942
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:207
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno)
Definition: execScan.c:285
PlanState ps
Definition: execnodes.h:1331
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:693
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1776
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1473
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1720
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition: executor.h:537
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1136
List * es_tupleTable
Definition: execnodes.h:552
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:946
Plan * plan
Definition: execnodes.h:940
Relation ioss_RelationDesc
Definition: execnodes.h:1474
List * indextlist
Definition: plannodes.h:433
List * indexorderby
Definition: plannodes.h:432
#define makeNode(_type_)
Definition: nodes.h:573
static TupleTableSlot * ExecIndexOnlyScan(PlanState *pstate)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:444
void ExecIndexBuildScanKeys(PlanState *planstate, Relation index, List *quals, bool isorderby, ScanKey *scanKeys, int *numScanKeys, IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys, IndexArrayKeyInfo **arrayKeys, int *numArrayKeys)
List * indexqual
Definition: plannodes.h:431
TupleDesc ExecTypeFromTL(List *targetList)
Definition: execTuples.c:1904
ExprState * indexqual
Definition: execnodes.h:1465
ExprState * qual
Definition: execnodes.h:961
#define INDEX_VAR
Definition: primnodes.h:159
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:56
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:126

◆ ExecReScanIndexOnlyScan()

void ExecReScanIndexOnlyScan ( IndexOnlyScanState node)

Definition at line 334 of file nodeIndexonlyscan.c.

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().

335 {
336  /*
337  * If we are doing runtime key calculations (ie, any of the index key
338  * values weren't simple Consts), compute the new key values. But first,
339  * reset the context so we don't leak memory as each outer tuple is
340  * scanned. Note this assumes that we will recalculate *all* runtime keys
341  * on each call.
342  */
343  if (node->ioss_NumRuntimeKeys != 0)
344  {
345  ExprContext *econtext = node->ioss_RuntimeContext;
346 
347  ResetExprContext(econtext);
348  ExecIndexEvalRuntimeKeys(econtext,
349  node->ioss_RuntimeKeys,
350  node->ioss_NumRuntimeKeys);
351  }
352  node->ioss_RuntimeKeysReady = true;
353 
354  /* reset index scan */
355  if (node->ioss_ScanDesc)
357  node->ioss_ScanKeys, node->ioss_NumScanKeys,
359 
360  ExecScanReScan(&node->ss);
361 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1472
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:289
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1470
struct IndexScanDescData * ioss_ScanDesc
Definition: execnodes.h:1475
struct ScanKeyData * ioss_ScanKeys
Definition: execnodes.h:1466
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1473
struct ScanKeyData * ioss_OrderByKeys
Definition: execnodes.h:1468
void ExecIndexEvalRuntimeKeys(ExprContext *econtext, IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)
void ExecScanReScan(ScanState *node)
Definition: execScan.c:299
#define ResetExprContext(econtext)
Definition: executor.h:495