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 372 of file nodeIndexonlyscan.c.

References ExecClearTuple(), ExecCloseScanRelation(), 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, ScanState::ss_currentRelation, and ScanState::ss_ScanTupleSlot.

Referenced by ExecEndNode().

373 {
374  Relation indexRelationDesc;
375  IndexScanDesc indexScanDesc;
376  Relation relation;
377 
378  /*
379  * extract information from the node
380  */
381  indexRelationDesc = node->ioss_RelationDesc;
382  indexScanDesc = node->ioss_ScanDesc;
383  relation = node->ss.ss_currentRelation;
384 
385  /* Release VM buffer pin, if any. */
386  if (node->ioss_VMBuffer != InvalidBuffer)
387  {
390  }
391 
392  /*
393  * Free the exprcontext(s) ... now dead code, see ExecFreeExprContext
394  */
395 #ifdef NOT_USED
396  ExecFreeExprContext(&node->ss.ps);
397  if (node->ioss_RuntimeContext)
399 #endif
400 
401  /*
402  * clear out tuple table slots
403  */
406 
407  /*
408  * close the index relation (no-op if we didn't open it)
409  */
410  if (indexScanDesc)
411  index_endscan(indexScanDesc);
412  if (indexRelationDesc)
413  index_close(indexRelationDesc, NoLock);
414 
415  /*
416  * close the heap relation.
417  */
418  ExecCloseScanRelation(relation);
419 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
#define InvalidBuffer
Definition: buf.h:25
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1195
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
Relation ss_currentRelation
Definition: execnodes.h:1193
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:566
PlanState ps
Definition: execnodes.h:1192
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1330
#define NoLock
Definition: lockdefs.h:34
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:340
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:359
Relation ioss_RelationDesc
Definition: execnodes.h:1331
void ExecCloseScanRelation(Relation scanrel)
Definition: execUtils.c:701
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:176

◆ ExecIndexOnlyMarkPos()

void ExecIndexOnlyMarkPos ( IndexOnlyScanState node)

Definition at line 429 of file nodeIndexonlyscan.c.

References Assert, elog, ERROR, EState::es_epqScanDone, EState::es_epqTuple, EState::es_epqTupleSet, index_markpos(), IndexOnlyScanState::ioss_ScanDesc, PlanState::plan, ScanState::ps, IndexOnlyScanState::ss, and PlanState::state.

Referenced by ExecMarkPos().

430 {
431  EState *estate = node->ss.ps.state;
432 
433  if (estate->es_epqTuple != NULL)
434  {
435  /*
436  * We are inside an EvalPlanQual recheck. If a test tuple exists for
437  * this relation, then we shouldn't access the index at all. We would
438  * instead need to save, and later restore, the state of the
439  * es_epqScanDone flag, so that re-fetching the test tuple is
440  * possible. However, given the assumption that no caller sets a mark
441  * at the start of the scan, we can only get here with es_epqScanDone
442  * already set, and so no state need be saved.
443  */
444  Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
445 
446  Assert(scanrelid > 0);
447  if (estate->es_epqTupleSet[scanrelid - 1])
448  {
449  /* Verify the claim above */
450  if (!estate->es_epqScanDone[scanrelid - 1])
451  elog(ERROR, "unexpected ExecIndexOnlyMarkPos call in EPQ recheck");
452  return;
453  }
454  }
455 
457 }
HeapTuple * es_epqTuple
Definition: execnodes.h:558
void index_markpos(IndexScanDesc scan)
Definition: indexam.c:370
EState * state
Definition: execnodes.h:914
PlanState ps
Definition: execnodes.h:1192
#define ERROR
Definition: elog.h:43
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332
unsigned int Index
Definition: c.h:442
Plan * plan
Definition: execnodes.h:912
#define Assert(condition)
Definition: c.h:699
bool * es_epqTupleSet
Definition: execnodes.h:559
bool * es_epqScanDone
Definition: execnodes.h:560
#define elog
Definition: elog.h:219

◆ ExecIndexOnlyRestrPos()

void ExecIndexOnlyRestrPos ( IndexOnlyScanState node)

Definition at line 464 of file nodeIndexonlyscan.c.

References Assert, elog, ERROR, EState::es_epqScanDone, EState::es_epqTuple, EState::es_epqTupleSet, index_restrpos(), IndexOnlyScanState::ioss_ScanDesc, PlanState::plan, ScanState::ps, IndexOnlyScanState::ss, and PlanState::state.

Referenced by ExecRestrPos().

465 {
466  EState *estate = node->ss.ps.state;
467 
468  if (estate->es_epqTuple != NULL)
469  {
470  /* See comments in ExecIndexOnlyMarkPos */
471  Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
472 
473  Assert(scanrelid > 0);
474  if (estate->es_epqTupleSet[scanrelid - 1])
475  {
476  /* Verify the claim above */
477  if (!estate->es_epqScanDone[scanrelid - 1])
478  elog(ERROR, "unexpected ExecIndexOnlyRestrPos call in EPQ recheck");
479  return;
480  }
481  }
482 
484 }
HeapTuple * es_epqTuple
Definition: execnodes.h:558
EState * state
Definition: execnodes.h:914
void index_restrpos(IndexScanDesc scan)
Definition: indexam.c:395
PlanState ps
Definition: execnodes.h:1192
#define ERROR
Definition: elog.h:43
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332
unsigned int Index
Definition: c.h:442
Plan * plan
Definition: execnodes.h:912
#define Assert(condition)
Definition: c.h:699
bool * es_epqTupleSet
Definition: execnodes.h:559
bool * es_epqScanDone
Definition: execnodes.h:560
#define elog
Definition: elog.h:219

◆ ExecIndexOnlyScanEstimate()

void ExecIndexOnlyScanEstimate ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 649 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().

651 {
652  EState *estate = node->ss.ps.state;
653 
655  estate->es_snapshot);
657  shm_toc_estimate_keys(&pcxt->estimator, 1);
658 }
shm_toc_estimator estimator
Definition: parallel.h:41
Snapshot es_snapshot
Definition: execnodes.h:478
EState * state
Definition: execnodes.h:914
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:51
Size index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
Definition: indexam.c:417
PlanState ps
Definition: execnodes.h:1192
Relation ioss_RelationDesc
Definition: execnodes.h:1331
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:53

◆ ExecIndexOnlyScanInitializeDSM()

void ExecIndexOnlyScanInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)

Definition at line 667 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().

669 {
670  EState *estate = node->ss.ps.state;
671  ParallelIndexScanDesc piscan;
672 
673  piscan = shm_toc_allocate(pcxt->toc, node->ioss_PscanLen);
675  node->ioss_RelationDesc,
676  estate->es_snapshot,
677  piscan);
678  shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, piscan);
679  node->ioss_ScanDesc =
681  node->ioss_RelationDesc,
682  node->ioss_NumScanKeys,
683  node->ioss_NumOrderByKeys,
684  piscan);
685  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:1329
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition: indexam.c:496
int plan_node_id
Definition: plannodes.h:145
#define InvalidBuffer
Definition: buf.h:25
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:310
Snapshot es_snapshot
Definition: execnodes.h:478
Relation ss_currentRelation
Definition: execnodes.h:1193
EState * state
Definition: execnodes.h:914
PlanState ps
Definition: execnodes.h:1192
ScanKey ioss_ScanKeys
Definition: execnodes.h:1323
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1325
Plan * plan
Definition: execnodes.h:912
Relation ioss_RelationDesc
Definition: execnodes.h:1331
bool xs_want_itup
Definition: relscan.h:97
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:450
shm_toc * toc
Definition: parallel.h:44

◆ ExecIndexOnlyScanInitializeWorker()

void ExecIndexOnlyScanInitializeWorker ( IndexOnlyScanState node,
ParallelWorkerContext pwcxt 
)

Definition at line 718 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().

720 {
721  ParallelIndexScanDesc piscan;
722 
723  piscan = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
724  node->ioss_ScanDesc =
726  node->ioss_RelationDesc,
727  node->ioss_NumScanKeys,
728  node->ioss_NumOrderByKeys,
729  piscan);
730  node->ioss_ScanDesc->xs_want_itup = true;
731 
732  /*
733  * If no run-time keys to calculate or they are ready, go ahead and pass
734  * the scankeys to the index AM.
735  */
736  if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
738  node->ioss_ScanKeys, node->ioss_NumScanKeys,
740 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1329
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition: indexam.c:496
int plan_node_id
Definition: plannodes.h:145
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:310
Relation ss_currentRelation
Definition: execnodes.h:1193
PlanState ps
Definition: execnodes.h:1192
ScanKey ioss_ScanKeys
Definition: execnodes.h:1323
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1325
Plan * plan
Definition: execnodes.h:912
Relation ioss_RelationDesc
Definition: execnodes.h:1331
bool xs_want_itup
Definition: relscan.h:97
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 705 of file nodeIndexonlyscan.c.

References index_parallelrescan(), and IndexOnlyScanState::ioss_ScanDesc.

Referenced by ExecParallelReInitializeDSM().

707 {
709 }
void index_parallelrescan(IndexScanDesc scan)
Definition: indexam.c:481
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332

◆ ExecInitIndexOnlyScan()

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

Definition at line 498 of file nodeIndexonlyscan.c.

References AccessShareLock, EXEC_FLAG_EXPLAIN_ONLY, ExecAssignExprContext(), ExecAssignScanProjectionInfoWithVarno(), ExecIndexBuildScanKeys(), ExecIndexOnlyScan(), ExecInitQual(), ExecInitResultTupleSlotTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), PlanState::ExecProcNode, ExecRelationIsTargetRelation(), ExecTypeFromTL(), index_open(), INDEX_VAR, IndexOnlyScan::indexid, IndexOnlyScan::indexorderby, IndexOnlyScan::indexqual, IndexOnlyScan::indextlist, makeNode, NoLock, Scan::plan, PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, Plan::qual, PlanState::qual, IndexOnlyScan::scan, Scan::scanrelid, IndexOnlyScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, and PlanState::state.

Referenced by ExecInitNode().

499 {
500  IndexOnlyScanState *indexstate;
501  Relation currentRelation;
502  bool relistarget;
503  TupleDesc tupDesc;
504 
505  /*
506  * create state structure
507  */
508  indexstate = makeNode(IndexOnlyScanState);
509  indexstate->ss.ps.plan = (Plan *) node;
510  indexstate->ss.ps.state = estate;
511  indexstate->ss.ps.ExecProcNode = ExecIndexOnlyScan;
512 
513  /*
514  * Miscellaneous initialization
515  *
516  * create expression context for node
517  */
518  ExecAssignExprContext(estate, &indexstate->ss.ps);
519 
520  /*
521  * open the base relation and acquire appropriate lock on it.
522  */
523  currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
524 
525  indexstate->ss.ss_currentRelation = currentRelation;
526  indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
527 
528  /*
529  * Build the scan tuple type using the indextlist generated by the
530  * planner. We use this, rather than the index's physical tuple
531  * descriptor, because the latter contains storage column types not the
532  * types of the original datums. (It's the AM's responsibility to return
533  * suitable data anyway.)
534  */
535  tupDesc = ExecTypeFromTL(node->indextlist, false);
536  ExecInitScanTupleSlot(estate, &indexstate->ss, tupDesc);
537 
538  /*
539  * Initialize result slot, type and projection info. The node's
540  * targetlist will contain Vars with varno = INDEX_VAR, referencing the
541  * scan tuple.
542  */
543  ExecInitResultTupleSlotTL(estate, &indexstate->ss.ps);
545 
546  /*
547  * initialize child expressions
548  *
549  * Note: we don't initialize all of the indexorderby expression, only the
550  * sub-parts corresponding to runtime keys (see below).
551  */
552  indexstate->ss.ps.qual =
553  ExecInitQual(node->scan.plan.qual, (PlanState *) indexstate);
554  indexstate->indexqual =
555  ExecInitQual(node->indexqual, (PlanState *) indexstate);
556 
557  /*
558  * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
559  * here. This allows an index-advisor plugin to EXPLAIN a plan containing
560  * references to nonexistent indexes.
561  */
562  if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
563  return indexstate;
564 
565  /*
566  * Open the index relation.
567  *
568  * If the parent table is one of the target relations of the query, then
569  * InitPlan already opened and write-locked the index, so we can avoid
570  * taking another lock here. Otherwise we need a normal reader's lock.
571  */
572  relistarget = ExecRelationIsTargetRelation(estate, node->scan.scanrelid);
573  indexstate->ioss_RelationDesc = index_open(node->indexid,
574  relistarget ? NoLock : AccessShareLock);
575 
576  /*
577  * Initialize index-specific scan state
578  */
579  indexstate->ioss_RuntimeKeysReady = false;
580  indexstate->ioss_RuntimeKeys = NULL;
581  indexstate->ioss_NumRuntimeKeys = 0;
582 
583  /*
584  * build the index scan keys from the index qualification
585  */
586  ExecIndexBuildScanKeys((PlanState *) indexstate,
587  indexstate->ioss_RelationDesc,
588  node->indexqual,
589  false,
590  &indexstate->ioss_ScanKeys,
591  &indexstate->ioss_NumScanKeys,
592  &indexstate->ioss_RuntimeKeys,
593  &indexstate->ioss_NumRuntimeKeys,
594  NULL, /* no ArrayKeys */
595  NULL);
596 
597  /*
598  * any ORDER BY exprs have to be turned into scankeys in the same way
599  */
600  ExecIndexBuildScanKeys((PlanState *) indexstate,
601  indexstate->ioss_RelationDesc,
602  node->indexorderby,
603  true,
604  &indexstate->ioss_OrderByKeys,
605  &indexstate->ioss_NumOrderByKeys,
606  &indexstate->ioss_RuntimeKeys,
607  &indexstate->ioss_NumRuntimeKeys,
608  NULL, /* no ArrayKeys */
609  NULL);
610 
611  /*
612  * If we have runtime keys, we need an ExprContext to evaluate them. The
613  * node's standard context won't do because we want to reset that context
614  * for every tuple. So, build another context just like the other one...
615  * -tgl 7/11/00
616  */
617  if (indexstate->ioss_NumRuntimeKeys != 0)
618  {
619  ExprContext *stdecontext = indexstate->ss.ps.ps_ExprContext;
620 
621  ExecAssignExprContext(estate, &indexstate->ss.ps);
622  indexstate->ioss_RuntimeContext = indexstate->ss.ps.ps_ExprContext;
623  indexstate->ss.ps.ps_ExprContext = stdecontext;
624  }
625  else
626  {
627  indexstate->ioss_RuntimeContext = NULL;
628  }
629 
630  /*
631  * all done.
632  */
633  return indexstate;
634 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1329
List * qual
Definition: plannodes.h:147
Plan plan
Definition: plannodes.h:342
Index scanrelid
Definition: plannodes.h:343
ExprContext * ps_ExprContext
Definition: execnodes.h:947
#define AccessShareLock
Definition: lockdefs.h:36
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1327
Relation ss_currentRelation
Definition: execnodes.h:1193
EState * state
Definition: execnodes.h:914
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:205
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno)
Definition: execScan.c:248
PlanState ps
Definition: execnodes.h:1192
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:643
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1330
#define NoLock
Definition: lockdefs.h:34
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:965
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:918
void ExecInitResultTupleSlotTL(EState *estate, PlanState *planstate)
Definition: execTuples.c:890
Plan * plan
Definition: execnodes.h:912
Relation ioss_RelationDesc
Definition: execnodes.h:1331
List * indextlist
Definition: plannodes.h:435
List * indexorderby
Definition: plannodes.h:434
#define makeNode(_type_)
Definition: nodes.h:565
static TupleTableSlot * ExecIndexOnlyScan(PlanState *pstate)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:428
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:433
ExprState * indexqual
Definition: execnodes.h:1322
ExprState * qual
Definition: execnodes.h:930
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1194
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc)
Definition: execTuples.c:915
#define INDEX_VAR
Definition: primnodes.h:156
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:58
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:150
bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid)
Definition: execUtils.c:617

◆ ExecReScanIndexOnlyScan()

void ExecReScanIndexOnlyScan ( IndexOnlyScanState node)

Definition at line 337 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().

338 {
339  /*
340  * If we are doing runtime key calculations (ie, any of the index key
341  * values weren't simple Consts), compute the new key values. But first,
342  * reset the context so we don't leak memory as each outer tuple is
343  * scanned. Note this assumes that we will recalculate *all* runtime keys
344  * on each call.
345  */
346  if (node->ioss_NumRuntimeKeys != 0)
347  {
348  ExprContext *econtext = node->ioss_RuntimeContext;
349 
350  ResetExprContext(econtext);
351  ExecIndexEvalRuntimeKeys(econtext,
352  node->ioss_RuntimeKeys,
353  node->ioss_NumRuntimeKeys);
354  }
355  node->ioss_RuntimeKeysReady = true;
356 
357  /* reset index scan */
358  if (node->ioss_ScanDesc)
360  node->ioss_ScanKeys, node->ioss_NumScanKeys,
362 
363  ExecScanReScan(&node->ss);
364 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1329
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:310
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1327
ScanKey ioss_ScanKeys
Definition: execnodes.h:1323
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1330
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1332
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1325
void ExecIndexEvalRuntimeKeys(ExprContext *econtext, IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)
void ExecScanReScan(ScanState *node)
Definition: execScan.c:262
#define ResetExprContext(econtext)
Definition: executor.h:483