PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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)
 
void ExecIndexOnlyScanInstrumentEstimate (IndexOnlyScanState *node, ParallelContext *pcxt)
 
void ExecIndexOnlyScanInstrumentInitDSM (IndexOnlyScanState *node, ParallelContext *pcxt)
 
void ExecIndexOnlyScanInstrumentInitWorker (IndexOnlyScanState *node, ParallelWorkerContext *pwcxt)
 
void ExecIndexOnlyScanRetrieveInstrumentation (IndexOnlyScanState *node)
 

Function Documentation

◆ ExecEndIndexOnlyScan()

void ExecEndIndexOnlyScan ( IndexOnlyScanState node)
extern

Definition at line 402 of file nodeIndexonlyscan.c.

403{
406
407 /*
408 * extract information from the node
409 */
412
413 /* Release VM buffer pin, if any. */
414 if (node->ioss_VMBuffer != InvalidBuffer)
415 {
418 }
419
420 /*
421 * When ending a parallel worker, copy the statistics gathered by the
422 * worker back into shared memory so that it can be picked up by the main
423 * process to report in EXPLAIN ANALYZE
424 */
425 if (node->ioss_SharedInfo != NULL && IsParallelWorker())
426 {
427 IndexScanInstrumentation *winstrument;
428
429 Assert(ParallelWorkerNumber < node->ioss_SharedInfo->num_workers);
430 winstrument = &node->ioss_SharedInfo->winstrument[ParallelWorkerNumber];
431
432 /*
433 * We have to accumulate the stats rather than performing a memcpy.
434 * When a Gather/GatherMerge node finishes it will perform planner
435 * shutdown on the workers. On rescan it will spin up new workers
436 * which will have a new IndexOnlyScanState and zeroed stats.
437 */
438 winstrument->nsearches += node->ioss_Instrument->nsearches;
439 }
440
441 /*
442 * close the index relation (no-op if we didn't open it)
443 */
444 if (indexScanDesc)
448}
int ParallelWorkerNumber
Definition parallel.c:117
#define InvalidBuffer
Definition buf.h:25
void ReleaseBuffer(Buffer buffer)
Definition bufmgr.c:5586
#define Assert(condition)
Definition c.h:943
#define IsParallelWorker()
Definition parallel.h:62
void index_close(Relation relation, LOCKMODE lockmode)
Definition indexam.c:178
void index_endscan(IndexScanDesc scan)
Definition indexam.c:394
#define NoLock
Definition lockdefs.h:34
static int fb(int x)
SharedIndexScanInstrumentation * ioss_SharedInfo
Definition execnodes.h:1814
IndexScanInstrumentation * ioss_Instrument
Definition execnodes.h:1813
struct IndexScanDescData * ioss_ScanDesc
Definition execnodes.h:1812
Relation ioss_RelationDesc
Definition execnodes.h:1811
IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER]

References Assert, fb(), index_close(), index_endscan(), InvalidBuffer, IndexOnlyScanState::ioss_Instrument, IndexOnlyScanState::ioss_RelationDesc, IndexOnlyScanState::ioss_ScanDesc, IndexOnlyScanState::ioss_SharedInfo, IndexOnlyScanState::ioss_VMBuffer, IsParallelWorker, NoLock, IndexScanInstrumentation::nsearches, ParallelWorkerNumber, ReleaseBuffer(), and SharedIndexScanInstrumentation::winstrument.

Referenced by ExecEndNode().

◆ ExecIndexOnlyMarkPos()

void ExecIndexOnlyMarkPos ( IndexOnlyScanState node)
extern

Definition at line 458 of file nodeIndexonlyscan.c.

459{
460 EState *estate = node->ss.ps.state;
461 EPQState *epqstate = estate->es_epq_active;
462
463 if (epqstate != NULL)
464 {
465 /*
466 * We are inside an EvalPlanQual recheck. If a test tuple exists for
467 * this relation, then we shouldn't access the index at all. We would
468 * instead need to save, and later restore, the state of the
469 * relsubs_done flag, so that re-fetching the test tuple is possible.
470 * However, given the assumption that no caller sets a mark at the
471 * start of the scan, we can only get here with relsubs_done[i]
472 * already set, and so no state need be saved.
473 */
474 Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
475
476 Assert(scanrelid > 0);
477 if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
478 epqstate->relsubs_rowmark[scanrelid - 1] != NULL)
479 {
480 /* Verify the claim above */
481 if (!epqstate->relsubs_done[scanrelid - 1])
482 elog(ERROR, "unexpected ExecIndexOnlyMarkPos call in EPQ recheck");
483 return;
484 }
485 }
486
488}
unsigned int Index
Definition c.h:698
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
void index_markpos(IndexScanDesc scan)
Definition indexam.c:424
ExecAuxRowMark ** relsubs_rowmark
Definition execnodes.h:1378
TupleTableSlot ** relsubs_slot
Definition execnodes.h:1350
bool * relsubs_done
Definition execnodes.h:1385
struct EPQState * es_epq_active
Definition execnodes.h:778
Plan * plan
Definition execnodes.h:1201
EState * state
Definition execnodes.h:1203
PlanState ps
Definition execnodes.h:1659

References Assert, elog, ERROR, EState::es_epq_active, fb(), 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)
extern

Definition at line 495 of file nodeIndexonlyscan.c.

496{
497 EState *estate = node->ss.ps.state;
498 EPQState *epqstate = estate->es_epq_active;
499
500 if (estate->es_epq_active != NULL)
501 {
502 /* See comments in ExecIndexMarkPos */
503 Index scanrelid = ((Scan *) node->ss.ps.plan)->scanrelid;
504
505 Assert(scanrelid > 0);
506 if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
507 epqstate->relsubs_rowmark[scanrelid - 1] != NULL)
508 {
509 /* Verify the claim above */
510 if (!epqstate->relsubs_done[scanrelid - 1])
511 elog(ERROR, "unexpected ExecIndexOnlyRestrPos call in EPQ recheck");
512 return;
513 }
514 }
515
517}
void index_restrpos(IndexScanDesc scan)
Definition indexam.c:448

References Assert, elog, ERROR, EState::es_epq_active, fb(), 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 
)
extern

Definition at line 735 of file nodeIndexonlyscan.c.

737{
738 EState *estate = node->ss.ps.state;
739
741 node->ioss_NumScanKeys,
743 estate->es_snapshot);
746}
Size index_parallelscan_estimate(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot)
Definition indexam.c:470
#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:696
shm_toc_estimator estimator
Definition parallel.h:43

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 
)
extern

Definition at line 755 of file nodeIndexonlyscan.c.

757{
758 EState *estate = node->ss.ps.state;
760
763 node->ioss_RelationDesc,
764 estate->es_snapshot,
765 piscan);
767
768 node->ioss_ScanDesc =
770 node->ioss_RelationDesc,
771 node->ioss_Instrument,
772 node->ioss_NumScanKeys,
774 piscan,
775 ScanRelIsReadOnly(&node->ss) ?
777 node->ioss_ScanDesc->xs_want_itup = true;
779
780 /*
781 * If no run-time keys to calculate or they are ready, go ahead and pass
782 * the scankeys to the index AM.
783 */
784 if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
786 node->ioss_ScanKeys, node->ioss_NumScanKeys,
788}
bool ScanRelIsReadOnly(ScanState *ss)
Definition execUtils.c:751
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, IndexScanInstrumentation *instrument, int nkeys, int norderbys, ParallelIndexScanDesc pscan, uint32 flags)
Definition indexam.c:560
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, ParallelIndexScanDesc target)
Definition indexam.c:505
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition indexam.c:368
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
ScanKeyData * ioss_OrderByKeys
Definition execnodes.h:1805
ScanKeyData * ioss_ScanKeys
Definition execnodes.h:1803
shm_toc * toc
Definition parallel.h:46
int plan_node_id
Definition plannodes.h:233
Relation ss_currentRelation
Definition execnodes.h:1660
@ SO_HINT_REL_READ_ONLY
Definition tableam.h:71
@ SO_NONE
Definition tableam.h:49

References EState::es_snapshot, fb(), index_beginscan_parallel(), index_parallelscan_initialize(), index_rescan(), InvalidBuffer, IndexOnlyScanState::ioss_Instrument, 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, ScanRelIsReadOnly(), shm_toc_allocate(), shm_toc_insert(), SO_HINT_REL_READ_ONLY, SO_NONE, IndexOnlyScanState::ss, ScanState::ss_currentRelation, PlanState::state, ParallelContext::toc, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeDSM().

◆ ExecIndexOnlyScanInitializeWorker()

void ExecIndexOnlyScanInitializeWorker ( IndexOnlyScanState node,
ParallelWorkerContext pwcxt 
)
extern

Definition at line 811 of file nodeIndexonlyscan.c.

813{
815
816 piscan = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
817
818 node->ioss_ScanDesc =
820 node->ioss_RelationDesc,
821 node->ioss_Instrument,
822 node->ioss_NumScanKeys,
824 piscan,
825 ScanRelIsReadOnly(&node->ss) ?
827 node->ioss_ScanDesc->xs_want_itup = true;
828
829 /*
830 * If no run-time keys to calculate or they are ready, go ahead and pass
831 * the scankeys to the index AM.
832 */
833 if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
835 node->ioss_ScanKeys, node->ioss_NumScanKeys,
837}
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition shm_toc.c:239

References fb(), index_beginscan_parallel(), index_rescan(), IndexOnlyScanState::ioss_Instrument, 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, ScanRelIsReadOnly(), shm_toc_lookup(), SO_HINT_REL_READ_ONLY, SO_NONE, IndexOnlyScanState::ss, ScanState::ss_currentRelation, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeWorker().

◆ ExecIndexOnlyScanInstrumentEstimate()

void ExecIndexOnlyScanInstrumentEstimate ( IndexOnlyScanState node,
ParallelContext pcxt 
)
extern

Definition at line 844 of file nodeIndexonlyscan.c.

846{
847 Size size;
848
849 if (!node->ss.ps.instrument || pcxt->nworkers == 0)
850 return;
851
852 /*
853 * This size calculation is trivial enough that we don't bother saving it
854 * in the IndexOnlyScanState. We'll recalculate the needed size in
855 * ExecIndexOnlyScanInstrumentInitDSM().
856 */
859 shm_toc_estimate_chunk(&pcxt->estimator, size);
861}
size_t Size
Definition c.h:689
Size add_size(Size s1, Size s2)
Definition shmem.c:1048
Size mul_size(Size s1, Size s2)
Definition shmem.c:1063
NodeInstrumentation * instrument
Definition execnodes.h:1211

References add_size(), ParallelContext::estimator, fb(), PlanState::instrument, mul_size(), ParallelContext::nworkers, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, and IndexOnlyScanState::ss.

Referenced by ExecParallelEstimate().

◆ ExecIndexOnlyScanInstrumentInitDSM()

void ExecIndexOnlyScanInstrumentInitDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)
extern

◆ ExecIndexOnlyScanInstrumentInitWorker()

◆ ExecIndexOnlyScanReInitializeDSM()

void ExecIndexOnlyScanReInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)
extern

◆ ExecIndexOnlyScanRetrieveInstrumentation()

void ExecIndexOnlyScanRetrieveInstrumentation ( IndexOnlyScanState node)
extern

Definition at line 913 of file nodeIndexonlyscan.c.

914{
916 size_t size;
917
918 if (SharedInfo == NULL)
919 return;
920
921 /* Create a copy of SharedInfo in backend-local memory */
922 size = offsetof(SharedIndexScanInstrumentation, winstrument) +
924 node->ioss_SharedInfo = palloc(size);
925 memcpy(node->ioss_SharedInfo, SharedInfo, size);
926}
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void * palloc(Size size)
Definition mcxt.c:1387

References fb(), IndexOnlyScanState::ioss_SharedInfo, memcpy(), SharedIndexScanInstrumentation::num_workers, and palloc().

Referenced by ExecParallelRetrieveInstrumentation().

◆ ExecInitIndexOnlyScan()

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

Definition at line 531 of file nodeIndexonlyscan.c.

532{
535 Relation indexRelation;
536 LOCKMODE lockmode;
537 TupleDesc tupDesc;
538 int indnkeyatts;
539 int namecount;
540
541 /*
542 * create state structure
543 */
545 indexstate->ss.ps.plan = (Plan *) node;
546 indexstate->ss.ps.state = estate;
547 indexstate->ss.ps.ExecProcNode = ExecIndexOnlyScan;
548
549 /*
550 * Miscellaneous initialization
551 *
552 * create expression context for node
553 */
554 ExecAssignExprContext(estate, &indexstate->ss.ps);
555
556 /*
557 * open the scan relation
558 */
559 currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
560
561 indexstate->ss.ss_currentRelation = currentRelation;
562 indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
563
564 /*
565 * Build the scan tuple type using the indextlist generated by the
566 * planner. We use this, rather than the index's physical tuple
567 * descriptor, because the latter contains storage column types not the
568 * types of the original datums. (It's the AM's responsibility to return
569 * suitable data anyway.)
570 */
571 tupDesc = ExecTypeFromTL(node->indextlist);
572 ExecInitScanTupleSlot(estate, &indexstate->ss, tupDesc,
574 0);
575
576 /*
577 * We need another slot, in a format that's suitable for the table AM, for
578 * when we need to fetch a tuple from the table for rechecking visibility.
579 */
580 indexstate->ioss_TableSlot =
584
585 /*
586 * Initialize result type and projection info. The node's targetlist will
587 * contain Vars with varno = INDEX_VAR, referencing the scan tuple.
588 */
591
592 /*
593 * initialize child expressions
594 *
595 * Note: we don't initialize all of the indexorderby expression, only the
596 * sub-parts corresponding to runtime keys (see below).
597 */
598 indexstate->ss.ps.qual =
599 ExecInitQual(node->scan.plan.qual, (PlanState *) indexstate);
600 indexstate->recheckqual =
602
603 /*
604 * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
605 * here. This allows an index-advisor plugin to EXPLAIN a plan containing
606 * references to nonexistent indexes.
607 */
608 if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
609 return indexstate;
610
611 /* Set up instrumentation of index-only scans if requested */
612 if (estate->es_instrument)
614
615 /* Open the index relation. */
616 lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
617 indexRelation = index_open(node->indexid, lockmode);
618 indexstate->ioss_RelationDesc = indexRelation;
619
620 /*
621 * Initialize index-specific scan state
622 */
623 indexstate->ioss_RuntimeKeysReady = false;
624 indexstate->ioss_RuntimeKeys = NULL;
625 indexstate->ioss_NumRuntimeKeys = 0;
626
627 /*
628 * build the index scan keys from the index qualification
629 */
631 indexRelation,
632 node->indexqual,
633 false,
634 &indexstate->ioss_ScanKeys,
635 &indexstate->ioss_NumScanKeys,
636 &indexstate->ioss_RuntimeKeys,
637 &indexstate->ioss_NumRuntimeKeys,
638 NULL, /* no ArrayKeys */
639 NULL);
640
641 /*
642 * any ORDER BY exprs have to be turned into scankeys in the same way
643 */
645 indexRelation,
646 node->indexorderby,
647 true,
648 &indexstate->ioss_OrderByKeys,
649 &indexstate->ioss_NumOrderByKeys,
650 &indexstate->ioss_RuntimeKeys,
651 &indexstate->ioss_NumRuntimeKeys,
652 NULL, /* no ArrayKeys */
653 NULL);
654
655 /*
656 * If we have runtime keys, we need an ExprContext to evaluate them. The
657 * node's standard context won't do because we want to reset that context
658 * for every tuple. So, build another context just like the other one...
659 * -tgl 7/11/00
660 */
661 if (indexstate->ioss_NumRuntimeKeys != 0)
662 {
663 ExprContext *stdecontext = indexstate->ss.ps.ps_ExprContext;
664
665 ExecAssignExprContext(estate, &indexstate->ss.ps);
666 indexstate->ioss_RuntimeContext = indexstate->ss.ps.ps_ExprContext;
667 indexstate->ss.ps.ps_ExprContext = stdecontext;
668 }
669 else
670 {
671 indexstate->ioss_RuntimeContext = NULL;
672 }
673
674 indexstate->ioss_NameCStringAttNums = NULL;
675 indnkeyatts = indexRelation->rd_index->indnkeyatts;
676 namecount = 0;
677
678 /*
679 * The "name" type for btree uses text_ops which results in storing
680 * cstrings in the indexed keys rather than names. Here we detect that in
681 * a generic way in case other index AMs want to do the same optimization.
682 * Check for opclasses with an opcintype of NAMEOID and an index tuple
683 * descriptor with CSTRINGOID. If any of these are found, create an array
684 * marking the index attribute number of each of them. StoreIndexTuple()
685 * handles copying the name Datums into a NAMEDATALEN-byte allocation.
686 */
687
688 /* First, count the number of such index keys */
689 for (int attnum = 0; attnum < indnkeyatts; attnum++)
690 {
691 if (TupleDescAttr(indexRelation->rd_att, attnum)->atttypid == CSTRINGOID &&
692 indexRelation->rd_opcintype[attnum] == NAMEOID)
693 namecount++;
694 }
695
696 if (namecount > 0)
697 {
698 int idx = 0;
699
700 /*
701 * Now create an array to mark the attribute numbers of the keys that
702 * need to be converted from cstring to name.
703 */
704 indexstate->ioss_NameCStringAttNums = palloc_array(AttrNumber, namecount);
705
706 for (int attnum = 0; attnum < indnkeyatts; attnum++)
707 {
708 if (TupleDescAttr(indexRelation->rd_att, attnum)->atttypid == CSTRINGOID &&
709 indexRelation->rd_opcintype[attnum] == NAMEOID)
710 indexstate->ioss_NameCStringAttNums[idx++] = (AttrNumber) attnum;
711 }
712 }
713
714 indexstate->ioss_NameCStringCount = namecount;
715
716 /*
717 * all done.
718 */
719 return indexstate;
720}
Datum idx(PG_FUNCTION_ARGS)
Definition _int_op.c:262
int16 AttrNumber
Definition attnum.h:21
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition execExpr.c:250
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno)
Definition execScan.c:94
const TupleTableSlotOps TTSOpsVirtual
Definition execTuples.c:84
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops, uint16 flags)
void ExecInitResultTypeTL(PlanState *planstate)
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops, uint16 flags)
TupleDesc ExecTypeFromTL(List *targetList)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition execUtils.c:490
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition execUtils.c:768
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition executor.h:710
#define EXEC_FLAG_EXPLAIN_ONLY
Definition executor.h:67
#define palloc_array(type, count)
Definition fe_memutils.h:76
#define palloc0_object(type)
Definition fe_memutils.h:75
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition indexam.c:134
int LOCKMODE
Definition lockdefs.h:26
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:161
int16 attnum
#define INDEX_VAR
Definition primnodes.h:245
#define RelationGetDescr(relation)
Definition rel.h:542
int es_instrument
Definition execnodes.h:756
List * es_tupleTable
Definition execnodes.h:748
List * indexqual
Definition plannodes.h:660
List * recheckqual
Definition plannodes.h:662
List * indextlist
Definition plannodes.h:666
List * indexorderby
Definition plannodes.h:664
Oid * rd_opcintype
Definition rel.h:208
TupleDesc rd_att
Definition rel.h:112
Form_pg_index rd_index
Definition rel.h:192
Index scanrelid
Definition plannodes.h:544
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition tableam.c:59
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178

References attnum, EState::es_instrument, EState::es_tupleTable, EXEC_FLAG_EXPLAIN_ONLY, exec_rt_fetch(), ExecAllocTableSlot(), ExecAssignExprContext(), ExecAssignScanProjectionInfoWithVarno(), ExecIndexBuildScanKeys(), ExecIndexOnlyScan(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), ExecTypeFromTL(), fb(), idx(), index_open(), INDEX_VAR, IndexOnlyScan::indexid, IndexOnlyScan::indexorderby, IndexOnlyScan::indexqual, IndexOnlyScan::indextlist, makeNode, palloc0_object, palloc_array, RelationData::rd_att, RelationData::rd_index, RelationData::rd_opcintype, IndexOnlyScan::recheckqual, RelationGetDescr, IndexOnlyScan::scan, Scan::scanrelid, table_slot_callbacks(), TTSOpsVirtual, and TupleDescAttr().

Referenced by ExecInitNode().

◆ ExecReScanIndexOnlyScan()

void ExecReScanIndexOnlyScan ( IndexOnlyScanState node)
extern

Definition at line 367 of file nodeIndexonlyscan.c.

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

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