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 ExecIndexOnlyScanRetrieveInstrumentation (IndexOnlyScanState *node)
 

Function Documentation

◆ ExecEndIndexOnlyScan()

void ExecEndIndexOnlyScan ( IndexOnlyScanState node)
extern

Definition at line 400 of file nodeIndexonlyscan.c.

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

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

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

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

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

731{
732 EState *estate = node->ss.ps.state;
733 bool instrument = (node->ss.ps.instrument != NULL);
734 bool parallel_aware = node->ss.ps.plan->parallel_aware;
735
736 if (!instrument && !parallel_aware)
737 {
738 /* No DSM required by the scan */
739 return;
740 }
741
743 node->ioss_NumScanKeys,
745 estate->es_snapshot,
746 instrument, parallel_aware,
747 pcxt->nworkers);
750}
Size index_parallelscan_estimate(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot, bool instrument, bool parallel_aware, int nworkers)
Definition indexam.c:471
#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:672
shm_toc_estimator estimator
Definition parallel.h:43
Instrumentation * instrument
Definition execnodes.h:1187
bool parallel_aware
Definition plannodes.h:217

References EState::es_snapshot, ParallelContext::estimator, fb(), index_parallelscan_estimate(), PlanState::instrument, IndexOnlyScanState::ioss_NumOrderByKeys, IndexOnlyScanState::ioss_NumScanKeys, IndexOnlyScanState::ioss_PscanLen, IndexOnlyScanState::ioss_RelationDesc, ParallelContext::nworkers, Plan::parallel_aware, PlanState::plan, 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 759 of file nodeIndexonlyscan.c.

761{
762 EState *estate = node->ss.ps.state;
764 bool instrument = node->ss.ps.instrument != NULL;
765 bool parallel_aware = node->ss.ps.plan->parallel_aware;
766
767 if (!instrument && !parallel_aware)
768 {
769 /* No DSM required by the scan */
770 return;
771 }
772
775 node->ioss_RelationDesc,
776 estate->es_snapshot,
777 instrument, parallel_aware, pcxt->nworkers,
778 &node->ioss_SharedInfo, piscan);
780
781 if (!parallel_aware)
782 {
783 /* Only here to initialize SharedInfo in DSM */
784 return;
785 }
786
787 node->ioss_ScanDesc =
789 node->ioss_RelationDesc,
790 &node->ioss_Instrument,
791 node->ioss_NumScanKeys,
793 piscan);
794 node->ioss_ScanDesc->xs_want_itup = true;
796
797 /*
798 * If no run-time keys to calculate or they are ready, go ahead and pass
799 * the scankeys to the index AM.
800 */
801 if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
803 node->ioss_ScanKeys, node->ioss_NumScanKeys,
805}
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, bool instrument, bool parallel_aware, int nworkers, SharedIndexScanInstrumentation **sharedinfo, ParallelIndexScanDesc target)
Definition indexam.c:520
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, IndexScanInstrumentation *instrument, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
Definition indexam.c:593
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition indexam.c:366
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:1778
ScanKeyData * ioss_ScanKeys
Definition execnodes.h:1776
shm_toc * toc
Definition parallel.h:46
int plan_node_id
Definition plannodes.h:231
Relation ss_currentRelation
Definition execnodes.h:1634

References EState::es_snapshot, fb(), index_beginscan_parallel(), index_parallelscan_initialize(), index_rescan(), PlanState::instrument, 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_SharedInfo, IndexOnlyScanState::ioss_VMBuffer, ParallelContext::nworkers, Plan::parallel_aware, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_allocate(), shm_toc_insert(), IndexOnlyScanState::ss, ScanState::ss_currentRelation, PlanState::state, ParallelContext::toc, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeDSM().

◆ ExecIndexOnlyScanInitializeWorker()

void ExecIndexOnlyScanInitializeWorker ( IndexOnlyScanState node,
ParallelWorkerContext pwcxt 
)
extern

Definition at line 828 of file nodeIndexonlyscan.c.

830{
832 bool instrument = node->ss.ps.instrument != NULL;
833 bool parallel_aware = node->ss.ps.plan->parallel_aware;
834
835 if (!instrument && !parallel_aware)
836 {
837 /* No DSM required by the scan */
838 return;
839 }
840
841 piscan = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
842
843 if (instrument)
845 OffsetToPointer(piscan, piscan->ps_offset_ins);
846
847 if (!parallel_aware)
848 {
849 /* Only here to set up worker node's SharedInfo */
850 return;
851 }
852
853 node->ioss_ScanDesc =
855 node->ioss_RelationDesc,
856 &node->ioss_Instrument,
857 node->ioss_NumScanKeys,
859 piscan);
860 node->ioss_ScanDesc->xs_want_itup = true;
861
862 /*
863 * If no run-time keys to calculate or they are ready, go ahead and pass
864 * the scankeys to the index AM.
865 */
866 if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady)
868 node->ioss_ScanKeys, node->ioss_NumScanKeys,
870}
#define OffsetToPointer(base, offset)
Definition c.h:857
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition shm_toc.c:232

References fb(), index_beginscan_parallel(), index_rescan(), PlanState::instrument, 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, IndexOnlyScanState::ioss_SharedInfo, OffsetToPointer, Plan::parallel_aware, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_lookup(), IndexOnlyScanState::ss, ScanState::ss_currentRelation, and IndexScanDescData::xs_want_itup.

Referenced by ExecParallelInitializeWorker().

◆ ExecIndexOnlyScanReInitializeDSM()

void ExecIndexOnlyScanReInitializeDSM ( IndexOnlyScanState node,
ParallelContext pcxt 
)
extern

◆ ExecIndexOnlyScanRetrieveInstrumentation()

void ExecIndexOnlyScanRetrieveInstrumentation ( IndexOnlyScanState node)
extern

Definition at line 879 of file nodeIndexonlyscan.c.

880{
882 size_t size;
883
884 if (SharedInfo == NULL)
885 return;
886
887 /* Create a copy of SharedInfo in backend-local memory */
888 size = offsetof(SharedIndexScanInstrumentation, winstrument) +
890 node->ioss_SharedInfo = palloc(size);
891 memcpy(node->ioss_SharedInfo, SharedInfo, size);
892}
void * palloc(Size size)
Definition mcxt.c:1387

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

Referenced by ExecParallelRetrieveInstrumentation().

◆ ExecInitIndexOnlyScan()

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

Definition at line 529 of file nodeIndexonlyscan.c.

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

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

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