PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/nbtree.h"
#include "access/relscan.h"
#include "access/tableam.h"
#include "catalog/pg_am.h"
#include "executor/executor.h"
#include "executor/nodeIndexscan.h"
#include "lib/pairingheap.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "utils/array.h"
#include "utils/datum.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | ReorderTuple |
|
static |
Definition at line 405 of file nodeIndexscan.c.
References SortSupportData::comparator, i, IndexScanState::iss_NumOrderByKeys, and IndexScanState::iss_SortSupport.
Referenced by IndexNextWithReorder(), and reorderqueue_cmp().
|
static |
Definition at line 360 of file nodeIndexscan.c.
References ExprContext::ecxt_per_tuple_memory, ExecEvalExpr(), i, IndexScanState::indexorderbyorig, IndexScanState::iss_OrderByNulls, IndexScanState::iss_OrderByValues, lfirst, and MemoryContextSwitchTo().
Referenced by IndexNextWithReorder().
void ExecEndIndexScan | ( | IndexScanState * | node | ) |
Definition at line 785 of file nodeIndexscan.c.
References index_close(), index_endscan(), IndexScanState::iss_RelationDesc, IndexScanState::iss_ScanDesc, and NoLock.
Referenced by ExecEndNode().
bool ExecIndexAdvanceArrayKeys | ( | IndexArrayKeyInfo * | arrayKeys, |
int | numArrayKeys | ||
) |
Definition at line 740 of file nodeIndexscan.c.
References IndexArrayKeyInfo::elem_nulls, IndexArrayKeyInfo::elem_values, j, IndexArrayKeyInfo::next_elem, IndexArrayKeyInfo::num_elems, IndexArrayKeyInfo::scan_key, ScanKeyData::sk_argument, ScanKeyData::sk_flags, and SK_ISNULL.
Referenced by MultiExecBitmapIndexScan().
void ExecIndexBuildScanKeys | ( | PlanState * | planstate, |
Relation | index, | ||
List * | quals, | ||
bool | isorderby, | ||
ScanKey * | scanKeys, | ||
int * | numScanKeys, | ||
IndexRuntimeKeyInfo ** | runtimeKeys, | ||
int * | numRuntimeKeys, | ||
IndexArrayKeyInfo ** | arrayKeys, | ||
int * | numArrayKeys | ||
) |
Definition at line 1135 of file nodeIndexscan.c.
References arg, NullTest::arg, ScalarArrayOpExpr::args, IndexArrayKeyInfo::array_expr, Assert, BTORDER_PROC, elog, ERROR, ExecInitExpr(), forfour, get_leftop(), get_op_opfamily_properties(), get_opfamily_proc(), get_rightop(), INDEX_VAR, IndexRelationGetNumberOfKeyAttributes, InvalidOid, InvalidStrategy, IS_NOT_NULL, IS_NULL, IsA, j, IndexRuntimeKeyInfo::key_expr, IndexRuntimeKeyInfo::key_toastable, RowCompareExpr::largs, lfirst, lfirst_oid, linitial, list_length(), lsecond, MemSet, nodeTag, NullTest::nulltesttype, ScalarArrayOpExpr::opno, palloc(), palloc0(), pfree(), PointerGetDatum(), RowCompareExpr::rargs, RowCompareExpr::rctype, RegProcedureIsValid, repalloc(), IndexRuntimeKeyInfo::scan_key, IndexArrayKeyInfo::scan_key, ScanKeyEntryInitialize(), ScanKeyData::sk_argument, ScanKeyData::sk_attno, ScanKeyData::sk_flags, SK_ISNULL, SK_ORDER_BY, SK_ROW_END, SK_ROW_HEADER, SK_ROW_MEMBER, SK_SEARCHARRAY, SK_SEARCHNOTNULL, SK_SEARCHNULL, ScanKeyData::sk_strategy, TypeIsToastable, and ScalarArrayOpExpr::useOr.
Referenced by ExecInitBitmapIndexScan(), ExecInitIndexOnlyScan(), and ExecInitIndexScan().
bool ExecIndexEvalArrayKeys | ( | ExprContext * | econtext, |
IndexArrayKeyInfo * | arrayKeys, | ||
int | numArrayKeys | ||
) |
Definition at line 661 of file nodeIndexscan.c.
References ARR_ELEMTYPE, IndexArrayKeyInfo::array_expr, DatumGetArrayTypeP, deconstruct_array(), ExprContext::ecxt_per_tuple_memory, IndexArrayKeyInfo::elem_nulls, IndexArrayKeyInfo::elem_values, ExecEvalExpr(), get_typlenbyvalalign(), j, MemoryContextSwitchTo(), IndexArrayKeyInfo::next_elem, IndexArrayKeyInfo::num_elems, IndexArrayKeyInfo::scan_key, ScanKeyData::sk_argument, ScanKeyData::sk_flags, and SK_ISNULL.
Referenced by ExecReScanBitmapIndexScan().
void ExecIndexEvalRuntimeKeys | ( | ExprContext * | econtext, |
IndexRuntimeKeyInfo * | runtimeKeys, | ||
int | numRuntimeKeys | ||
) |
Definition at line 599 of file nodeIndexscan.c.
References ExprContext::ecxt_per_tuple_memory, ExecEvalExpr(), j, IndexRuntimeKeyInfo::key_expr, MemoryContextSwitchTo(), PG_DETOAST_DATUM, PointerGetDatum(), IndexRuntimeKeyInfo::scan_key, ScanKeyData::sk_argument, ScanKeyData::sk_flags, and SK_ISNULL.
Referenced by ExecReScanBitmapIndexScan(), ExecReScanIndexOnlyScan(), and ExecReScanIndexScan().
void ExecIndexMarkPos | ( | IndexScanState * | node | ) |
Definition at line 813 of file nodeIndexscan.c.
References Assert, elog, ERROR, EState::es_epq_active, index_markpos(), IndexScanState::iss_ScanDesc, PlanState::plan, ScanState::ps, EPQState::relsubs_done, EPQState::relsubs_rowmark, EPQState::relsubs_slot, IndexScanState::ss, and PlanState::state.
Referenced by ExecMarkPos().
void ExecIndexRestrPos | ( | IndexScanState * | node | ) |
Definition at line 850 of file nodeIndexscan.c.
References Assert, elog, ERROR, EState::es_epq_active, index_restrpos(), IndexScanState::iss_ScanDesc, PlanState::plan, ScanState::ps, EPQState::relsubs_done, EPQState::relsubs_rowmark, EPQState::relsubs_slot, IndexScanState::ss, and PlanState::state.
Referenced by ExecRestrPos().
|
static |
Definition at line 519 of file nodeIndexscan.c.
References castNode, ExecReScan(), ExecScan(), IndexNext(), IndexNextWithReorder(), IndexRecheck(), IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_RuntimeKeysReady, and IndexScanState::ss.
Referenced by ExecInitIndexScan().
void ExecIndexScanEstimate | ( | IndexScanState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 1641 of file nodeIndexscan.c.
References EState::es_snapshot, ParallelContext::estimator, index_parallelscan_estimate(), IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_PscanLen, IndexScanState::iss_RelationDesc, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, IndexScanState::ss, and PlanState::state.
Referenced by ExecParallelEstimate().
void ExecIndexScanInitializeDSM | ( | IndexScanState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 1661 of file nodeIndexscan.c.
References EState::es_snapshot, index_beginscan_parallel(), index_parallelscan_initialize(), index_rescan(), IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_OrderByKeys, IndexScanState::iss_PscanLen, IndexScanState::iss_RelationDesc, IndexScanState::iss_RuntimeKeysReady, IndexScanState::iss_ScanDesc, IndexScanState::iss_ScanKeys, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_allocate(), shm_toc_insert(), IndexScanState::ss, ScanState::ss_currentRelation, PlanState::state, and ParallelContext::toc.
Referenced by ExecParallelInitializeDSM().
void ExecIndexScanInitializeWorker | ( | IndexScanState * | node, |
ParallelWorkerContext * | pwcxt | ||
) |
Definition at line 1710 of file nodeIndexscan.c.
References index_beginscan_parallel(), index_rescan(), IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_OrderByKeys, IndexScanState::iss_RelationDesc, IndexScanState::iss_RuntimeKeysReady, IndexScanState::iss_ScanDesc, IndexScanState::iss_ScanKeys, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_lookup(), IndexScanState::ss, ScanState::ss_currentRelation, and ParallelWorkerContext::toc.
Referenced by ExecParallelInitializeWorker().
void ExecIndexScanReInitializeDSM | ( | IndexScanState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 1697 of file nodeIndexscan.c.
References index_parallelrescan(), and IndexScanState::iss_ScanDesc.
Referenced by ExecParallelReInitializeDSM().
IndexScanState* ExecInitIndexScan | ( | IndexScan * | node, |
EState * | estate, | ||
int | eflags | ||
) |
Definition at line 886 of file nodeIndexscan.c.
References SortSupportData::abbreviate, Assert, CurrentMemoryContext, EXEC_FLAG_EXPLAIN_ONLY, exec_rt_fetch(), ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecIndexBuildScanKeys(), ExecIndexScan(), ExecInitExprList(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), PlanState::ExecProcNode, exprCollation(), exprType(), forboth, get_typlenbyval(), i, index_open(), IndexScan::indexid, IndexScan::indexorderby, IndexScan::indexorderbyops, IndexScanState::indexorderbyorig, IndexScan::indexorderbyorig, IndexScan::indexqual, IndexScanState::indexqualorig, IndexScan::indexqualorig, IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_OrderByKeys, IndexScanState::iss_OrderByNulls, IndexScanState::iss_OrderByTypByVals, IndexScanState::iss_OrderByTypLens, IndexScanState::iss_OrderByValues, IndexScanState::iss_RelationDesc, IndexScanState::iss_ReorderQueue, IndexScanState::iss_RuntimeContext, IndexScanState::iss_RuntimeKeys, IndexScanState::iss_RuntimeKeysReady, IndexScanState::iss_ScanKeys, IndexScanState::iss_SortSupport, lfirst, lfirst_oid, list_length(), makeNode, pairingheap_allocate(), palloc(), palloc0(), PlanState::plan, PrepareSortSupportFromOrderingOp(), ScanState::ps, PlanState::ps_ExprContext, PlanState::qual, RelationGetDescr, reorderqueue_cmp(), IndexScan::scan, Scan::scanrelid, IndexScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, SortSupportData::ssup_attno, SortSupportData::ssup_collation, SortSupportData::ssup_cxt, SortSupportData::ssup_nulls_first, PlanState::state, and table_slot_callbacks().
Referenced by ExecInitNode().
void ExecReScanIndexScan | ( | IndexScanState * | node | ) |
Definition at line 551 of file nodeIndexscan.c.
References ExecIndexEvalRuntimeKeys(), ExecScanReScan(), heap_freetuple(), index_rescan(), IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_OrderByKeys, IndexScanState::iss_ReachedEnd, IndexScanState::iss_ReorderQueue, IndexScanState::iss_RuntimeContext, IndexScanState::iss_RuntimeKeys, IndexScanState::iss_RuntimeKeysReady, IndexScanState::iss_ScanDesc, IndexScanState::iss_ScanKeys, pairingheap_is_empty, reorderqueue_pop(), ResetExprContext, and IndexScanState::ss.
Referenced by ExecReScan().
|
static |
Definition at line 80 of file nodeIndexscan.c.
References CHECK_FOR_INTERRUPTS, ExprContext::ecxt_scantuple, EState::es_direction, EState::es_snapshot, ExecClearTuple(), ExecQualAndReset(), index_beginscan(), index_getnext_slot(), index_rescan(), IndexScanState::indexqualorig, InstrCountFiltered2, IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_OrderByKeys, IndexScanState::iss_ReachedEnd, IndexScanState::iss_RelationDesc, IndexScanState::iss_RuntimeKeysReady, IndexScanState::iss_ScanDesc, IndexScanState::iss_ScanKeys, PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, ScanDirectionCombine, IndexScanState::ss, ScanState::ss_currentRelation, ScanState::ss_ScanTupleSlot, PlanState::state, and IndexScanDescData::xs_recheck.
Referenced by ExecIndexScan().
|
static |
Definition at line 168 of file nodeIndexscan.c.
References Assert, CHECK_FOR_INTERRUPTS, cmp(), cmp_orderbyvals(), ExprContext::ecxt_scantuple, elog, ERROR, EState::es_direction, EState::es_snapshot, EvalOrderByExpressions(), ExecClearTuple(), ExecForceStoreHeapTuple(), ExecQualAndReset(), ForwardScanDirection, index_beginscan(), index_getnext_slot(), index_rescan(), IndexScanState::indexqualorig, InstrCountFiltered2, IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_NumRuntimeKeys, IndexScanState::iss_NumScanKeys, IndexScanState::iss_OrderByKeys, IndexScanState::iss_OrderByNulls, IndexScanState::iss_OrderByValues, IndexScanState::iss_ReachedEnd, IndexScanState::iss_RelationDesc, IndexScanState::iss_ReorderQueue, IndexScanState::iss_RuntimeKeysReady, IndexScanState::iss_ScanDesc, IndexScanState::iss_ScanKeys, ReorderTuple::orderbynulls, ReorderTuple::orderbyvals, pairingheap_first(), pairingheap_is_empty, PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, reorderqueue_pop(), reorderqueue_push(), ResetExprContext, ScanDirectionIsBackward, ScanDirectionIsForward, IndexScanState::ss, ScanState::ss_currentRelation, ScanState::ss_ScanTupleSlot, PlanState::state, IndexScanDescData::xs_orderbynulls, IndexScanDescData::xs_orderbyvals, IndexScanDescData::xs_recheck, and IndexScanDescData::xs_recheckorderby.
Referenced by ExecIndexScan().
|
static |
Definition at line 386 of file nodeIndexscan.c.
References ExprContext::ecxt_scantuple, ExecQualAndReset(), IndexScanState::indexqualorig, ScanState::ps, PlanState::ps_ExprContext, and IndexScanState::ss.
Referenced by ExecIndexScan().
|
static |
Definition at line 441 of file nodeIndexscan.c.
References a, arg, b, cmp_orderbyvals(), ReorderTuple::orderbynulls, and ReorderTuple::orderbyvals.
Referenced by ExecInitIndexScan().
|
static |
Definition at line 492 of file nodeIndexscan.c.
References DatumGetPointer(), ReorderTuple::htup, i, IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_OrderByTypByVals, IndexScanState::iss_ReorderQueue, ReorderTuple::orderbynulls, ReorderTuple::orderbyvals, pairingheap_remove_first(), and pfree().
Referenced by ExecReScanIndexScan(), and IndexNextWithReorder().
|
static |
Definition at line 458 of file nodeIndexscan.c.
References datumCopy(), EState::es_query_cxt, ExecCopySlotHeapTuple(), ReorderTuple::htup, i, IndexScanState::iss_NumOrderByKeys, IndexScanState::iss_OrderByTypByVals, IndexScanState::iss_OrderByTypLens, IndexScanState::iss_ReorderQueue, IndexScanState::iss_ScanDesc, MemoryContextSwitchTo(), IndexScanDescData::numberOfOrderBys, ReorderTuple::orderbynulls, ReorderTuple::orderbyvals, pairingheap_add(), palloc(), ReorderTuple::ph_node, ScanState::ps, IndexScanState::ss, and PlanState::state.
Referenced by IndexNextWithReorder().