PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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)
 
TupleTableSlotExecIndexOnlyScan (IndexOnlyScanState *node)
 
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 ExecIndexOnlyScanInitializeWorker (IndexOnlyScanState *node, shm_toc *toc)
 

Function Documentation

void ExecEndIndexOnlyScan ( IndexOnlyScanState node)

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

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 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
#define InvalidBuffer
Definition: buf.h:25
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1061
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
Relation ss_currentRelation
Definition: execnodes.h:1059
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:516
PlanState ps
Definition: execnodes.h:1058
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:842
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1197
#define NoLock
Definition: lockdefs.h:34
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1199
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:340
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:349
Relation ioss_RelationDesc
Definition: execnodes.h:1198
void ExecCloseScanRelation(Relation scanrel)
Definition: execUtils.c:661
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:176
void ExecIndexOnlyMarkPos ( IndexOnlyScanState node)

Definition at line 436 of file nodeIndexonlyscan.c.

References index_markpos(), and IndexOnlyScanState::ioss_ScanDesc.

Referenced by ExecMarkPos().

437 {
439 }
void index_markpos(IndexScanDesc scan)
Definition: indexam.c:370
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1199
void ExecIndexOnlyRestrPos ( IndexOnlyScanState node)

Definition at line 446 of file nodeIndexonlyscan.c.

References index_restrpos(), and IndexOnlyScanState::ioss_ScanDesc.

Referenced by ExecRestrPos().

447 {
449 }
void index_restrpos(IndexScanDesc scan)
Definition: indexam.c:395
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1199
TupleTableSlot* ExecIndexOnlyScan ( IndexOnlyScanState node)

Definition at line 307 of file nodeIndexonlyscan.c.

References ExecReScan(), ExecScan(), IndexOnlyNext(), IndexOnlyRecheck(), IndexOnlyScanState::ioss_NumRuntimeKeys, IndexOnlyScanState::ioss_RuntimeKeysReady, and IndexOnlyScanState::ss.

Referenced by ExecProcNode().

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 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1196
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:121
void ExecReScan(PlanState *node)
Definition: execAmi.c:75
static bool IndexOnlyRecheck(IndexOnlyScanState *node, TupleTableSlot *slot)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:389
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:390
static TupleTableSlot * IndexOnlyNext(IndexOnlyScanState *node)
void ExecIndexOnlyScanEstimate ( IndexOnlyScanState node,
ParallelContext pcxt 
)

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

621 {
622  EState *estate = node->ss.ps.state;
623 
625  estate->es_snapshot);
627  shm_toc_estimate_keys(&pcxt->estimator, 1);
628 }
shm_toc_estimator estimator
Definition: parallel.h:41
Snapshot es_snapshot
Definition: execnodes.h:409
EState * state
Definition: execnodes.h:815
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:49
Size index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
Definition: indexam.c:417
PlanState ps
Definition: execnodes.h:1058
Relation ioss_RelationDesc
Definition: execnodes.h:1198
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:52
void ExecIndexOnlyScanInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)

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

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 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1196
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:143
#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:409
Relation ss_currentRelation
Definition: execnodes.h:1059
EState * state
Definition: execnodes.h:815
PlanState ps
Definition: execnodes.h:1058
ScanKey ioss_ScanKeys
Definition: execnodes.h:1190
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1199
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1192
Plan * plan
Definition: execnodes.h:813
Relation ioss_RelationDesc
Definition: execnodes.h:1198
bool xs_want_itup
Definition: relscan.h:95
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:83
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:161
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, ParallelIndexScanDesc target)
Definition: indexam.c:450
shm_toc * toc
Definition: parallel.h:44
void ExecIndexOnlyScanInitializeWorker ( IndexOnlyScanState node,
shm_toc toc 
)

Definition at line 675 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, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeWorker().

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:1196
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:143
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:310
Relation ss_currentRelation
Definition: execnodes.h:1059
PlanState ps
Definition: execnodes.h:1058
ScanKey ioss_ScanKeys
Definition: execnodes.h:1190
void * shm_toc_lookup(shm_toc *toc, uint64 key)
Definition: shm_toc.c:218
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1199
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1192
Plan * plan
Definition: execnodes.h:813
Relation ioss_RelationDesc
Definition: execnodes.h:1198
bool xs_want_itup
Definition: relscan.h:95
IndexOnlyScanState* ExecInitIndexOnlyScan ( IndexOnlyScan node,
EState estate,
int  eflags 
)

Definition at line 463 of file nodeIndexonlyscan.c.

References AccessShareLock, EXEC_FLAG_EXPLAIN_ONLY, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfoWithVarno(), ExecAssignScanType(), ExecIndexBuildScanKeys(), ExecInitQual(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), ExecRelationIsTargetRelation(), ExecTypeFromTL(), index_open(), INDEX_VAR, IndexOnlyScan::indexid, IndexOnlyScan::indexorderby, IndexOnlyScan::indexqual, IndexOnlyScanState::indexqual, IndexOnlyScan::indextlist, IndexOnlyScanState::ioss_HeapFetches, 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, makeNode, NoLock, NULL, 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().

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 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1196
List * qual
Definition: plannodes.h:145
Plan plan
Definition: plannodes.h:328
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
Index scanrelid
Definition: plannodes.h:329
ExprContext * ps_ExprContext
Definition: execnodes.h:843
#define AccessShareLock
Definition: lockdefs.h:36
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1194
Relation ss_currentRelation
Definition: execnodes.h:1059
EState * state
Definition: execnodes.h:815
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:160
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:440
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno)
Definition: execScan.c:247
PlanState ps
Definition: execnodes.h:1058
ScanKey ioss_ScanKeys
Definition: execnodes.h:1190
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:603
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1197
#define NoLock
Definition: lockdefs.h:34
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1192
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:888
Plan * plan
Definition: execnodes.h:813
Relation ioss_RelationDesc
Definition: execnodes.h:1198
List * indextlist
Definition: plannodes.h:421
List * indexorderby
Definition: plannodes.h:420
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:418
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:419
ExprState * indexqual
Definition: execnodes.h:1189
ExprState * qual
Definition: execnodes.h:827
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1060
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:540
#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:577
void ExecReScanIndexOnlyScan ( IndexOnlyScanState node)

Definition at line 332 of file nodeIndexonlyscan.c.

References ExecIndexEvalRuntimeKeys(), ExecScanReScan(), index_parallelrescan(), 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, IndexScanDescData::parallel_scan, ResetExprContext, and IndexOnlyScanState::ss.

Referenced by ExecReScan().

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 }
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1196
ParallelIndexScanDesc parallel_scan
Definition: relscan.h:139
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:310
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1194
void index_parallelrescan(IndexScanDesc scan)
Definition: indexam.c:481
ScanKey ioss_ScanKeys
Definition: execnodes.h:1190
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1197
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1199
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1192
void ExecIndexEvalRuntimeKeys(ExprContext *econtext, IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)
void ExecScanReScan(ScanState *node)
Definition: execScan.c:327
#define ResetExprContext(econtext)
Definition: executor.h:450