PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/amapi.h"
#include "access/heapam.h"
#include "access/reloptions.h"
#include "access/relscan.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "catalog/index.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
#include "storage/lmgr.h"
#include "storage/predicate.h"
#include "utils/ruleutils.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Macros | |
#define | RELATION_CHECKS |
#define | SCAN_CHECKS |
#define | CHECK_REL_PROCEDURE(pname) |
#define | CHECK_SCAN_PROCEDURE(pname) |
#define CHECK_REL_PROCEDURE | ( | pname | ) |
Definition at line 93 of file indexam.c.
Referenced by index_beginscan_internal(), index_bulk_delete(), index_insert(), and index_vacuum_cleanup().
#define CHECK_SCAN_PROCEDURE | ( | pname | ) |
Definition at line 100 of file indexam.c.
Referenced by index_endscan(), index_getbitmap(), index_getnext_tid(), index_markpos(), index_rescan(), and index_restrpos().
#define RELATION_CHECKS |
Definition at line 79 of file indexam.c.
Referenced by index_beginscan_internal(), index_bulk_delete(), index_can_return(), index_insert(), index_parallelscan_estimate(), index_parallelscan_initialize(), and index_vacuum_cleanup().
#define SCAN_CHECKS |
Definition at line 86 of file indexam.c.
Referenced by index_endscan(), index_getbitmap(), index_getnext_tid(), index_markpos(), index_parallelrescan(), index_rescan(), and index_restrpos().
IndexScanDesc index_beginscan | ( | Relation | heapRelation, |
Relation | indexRelation, | ||
Snapshot | snapshot, | ||
int | nkeys, | ||
int | norderbys | ||
) |
Definition at line 205 of file indexam.c.
References IndexScanDescData::heapRelation, index_beginscan_internal(), table_index_fetch_begin(), IndexScanDescData::xs_heapfetch, and IndexScanDescData::xs_snapshot.
Referenced by check_exclusion_or_unique_constraint(), get_actual_variable_endpoint(), heapam_relation_copy_for_cluster(), IndexNext(), IndexNextWithReorder(), IndexOnlyNext(), RelationFindReplTupleByIndex(), systable_beginscan(), and systable_beginscan_ordered().
IndexScanDesc index_beginscan_bitmap | ( | Relation | indexRelation, |
Snapshot | snapshot, | ||
int | nkeys | ||
) |
Definition at line 234 of file indexam.c.
References index_beginscan_internal(), and IndexScanDescData::xs_snapshot.
Referenced by ExecInitBitmapIndexScan().
|
static |
Definition at line 255 of file indexam.c.
References IndexAmRoutine::ambeginscan, IndexAmRoutine::ampredlocks, CHECK_REL_PROCEDURE, IndexScanDescData::parallel_scan, PredicateLockRelation(), RelationData::rd_indam, RELATION_CHECKS, RelationIncrementReferenceCount(), and IndexScanDescData::xs_temp_snap.
Referenced by index_beginscan(), index_beginscan_bitmap(), and index_beginscan_parallel().
IndexScanDesc index_beginscan_parallel | ( | Relation | heaprel, |
Relation | indexrel, | ||
int | nkeys, | ||
int | norderbys, | ||
ParallelIndexScanDesc | pscan | ||
) |
Definition at line 484 of file indexam.c.
References Assert, IndexScanDescData::heapRelation, index_beginscan_internal(), ParallelIndexScanDescData::ps_relid, ParallelIndexScanDescData::ps_snapshot_data, RegisterSnapshot(), RelationGetRelid, RestoreSnapshot(), table_index_fetch_begin(), IndexScanDescData::xs_heapfetch, and IndexScanDescData::xs_snapshot.
Referenced by ExecIndexOnlyScanInitializeDSM(), ExecIndexOnlyScanInitializeWorker(), ExecIndexScanInitializeDSM(), and ExecIndexScanInitializeWorker().
IndexBulkDeleteResult* index_bulk_delete | ( | IndexVacuumInfo * | info, |
IndexBulkDeleteResult * | stats, | ||
IndexBulkDeleteCallback | callback, | ||
void * | callback_state | ||
) |
Definition at line 691 of file indexam.c.
References IndexAmRoutine::ambulkdelete, CHECK_REL_PROCEDURE, IndexVacuumInfo::index, RelationData::rd_indam, and RELATION_CHECKS.
Referenced by lazy_vacuum_index(), and validate_index().
Definition at line 731 of file indexam.c.
References IndexAmRoutine::amcanreturn, RelationData::rd_indam, and RELATION_CHECKS.
Referenced by get_relation_info(), and indexam_property().
Definition at line 158 of file indexam.c.
References Assert, LockInfoData::lockRelId, MAX_LOCKMODES, NoLock, RelationData::rd_lockInfo, RelationClose(), and UnlockRelationId().
Referenced by _bt_parallel_build_main(), ATExecAddIndex(), ATExecAddIndexConstraint(), ATExecDetachPartition(), ATExecReplicaIdentity(), ATExecSetStorage(), AttachPartitionEnsureIndexes(), brin_page_items(), brincostestimate(), bt_index_check_internal(), build_indices(), BuildEventTriggerCache(), check_index_is_clusterable(), CheckIndexCompatible(), close_lo_relation(), copy_table_data(), DefineIndex(), DefineRelation(), enum_endpoint(), enum_range_internal(), ExecCloseIndices(), ExecEndBitmapIndexScan(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), ExecRefreshMatView(), expandTableLikeClause(), get_actual_variable_range(), get_relation_info(), gin_clean_pending_list(), gincostestimate(), hash_bitmap_info(), index_concurrently_build(), index_concurrently_create_copy(), index_concurrently_set_dead(), index_create(), index_drop(), indexam_property(), infer_arbiter_indexes(), InitCatCachePhase2(), lookup_ts_config_cache(), pg_nextoid(), pgstathashindex(), plan_create_index_workers(), refresh_by_match_merge(), reindex_index(), ReindexRelationConcurrently(), RelationFindReplTupleByIndex(), RelationGetIndexAttrBitmap(), RelationTruncateIndexes(), systable_endscan(), toast_close_indexes(), TryReuseIndex(), unique_key_recheck(), vac_close_indexes(), vac_open_indexes(), and validate_index().
void index_endscan | ( | IndexScanDesc | scan | ) |
Definition at line 323 of file indexam.c.
References IndexAmRoutine::amendscan, CHECK_SCAN_PROCEDURE, IndexScanDescData::indexRelation, IndexScanEnd(), RelationData::rd_indam, RelationDecrementReferenceCount(), SCAN_CHECKS, table_index_fetch_end(), UnregisterSnapshot(), IndexScanDescData::xs_heapfetch, IndexScanDescData::xs_snapshot, and IndexScanDescData::xs_temp_snap.
Referenced by check_exclusion_or_unique_constraint(), ExecEndBitmapIndexScan(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), get_actual_variable_endpoint(), heapam_relation_copy_for_cluster(), RelationFindReplTupleByIndex(), systable_endscan(), and systable_endscan_ordered().
bool index_fetch_heap | ( | IndexScanDesc | scan, |
TupleTableSlot * | slot | ||
) |
Definition at line 575 of file indexam.c.
References IndexScanDescData::indexRelation, IndexScanDescData::kill_prior_tuple, pgstat_count_heap_fetch, table_index_fetch_tuple(), IndexScanDescData::xactStartedInRecovery, IndexScanDescData::xs_heap_continue, IndexScanDescData::xs_heapfetch, IndexScanDescData::xs_heaptid, and IndexScanDescData::xs_snapshot.
Referenced by get_actual_variable_endpoint(), index_getnext_slot(), and IndexOnlyNext().
int64 index_getbitmap | ( | IndexScanDesc | scan, |
TIDBitmap * | bitmap | ||
) |
Definition at line 661 of file indexam.c.
References IndexAmRoutine::amgetbitmap, CHECK_SCAN_PROCEDURE, IndexScanDescData::indexRelation, IndexScanDescData::kill_prior_tuple, pgstat_count_index_tuples, RelationData::rd_indam, and SCAN_CHECKS.
Referenced by MultiExecBitmapIndexScan().
bool index_getnext_slot | ( | IndexScanDesc | scan, |
ScanDirection | direction, | ||
TupleTableSlot * | slot | ||
) |
Definition at line 616 of file indexam.c.
References Assert, index_fetch_heap(), index_getnext_tid(), ItemPointerEquals(), ItemPointerIsValid, IndexScanDescData::xs_heap_continue, and IndexScanDescData::xs_heaptid.
Referenced by check_exclusion_or_unique_constraint(), heapam_relation_copy_for_cluster(), IndexNext(), IndexNextWithReorder(), RelationFindReplTupleByIndex(), systable_getnext(), and systable_getnext_ordered().
ItemPointer index_getnext_tid | ( | IndexScanDesc | scan, |
ScanDirection | direction | ||
) |
Definition at line 517 of file indexam.c.
References IndexAmRoutine::amgettuple, Assert, CHECK_SCAN_PROCEDURE, IndexScanDescData::indexRelation, ItemPointerIsValid, IndexScanDescData::kill_prior_tuple, pgstat_count_index_tuples, RelationData::rd_indam, RecentXmin, SCAN_CHECKS, table_index_fetch_reset(), TransactionIdIsValid, IndexScanDescData::xs_heap_continue, IndexScanDescData::xs_heapfetch, and IndexScanDescData::xs_heaptid.
Referenced by get_actual_variable_endpoint(), index_getnext_slot(), and IndexOnlyNext().
RegProcedure index_getprocid | ( | Relation | irel, |
AttrNumber | attnum, | ||
uint16 | procnum | ||
) |
Definition at line 769 of file indexam.c.
References IndexAmRoutine::amsupport, Assert, RelationData::rd_indam, and RelationData::rd_support.
Referenced by _hash_init(), gistbuild(), gistcanreturn(), inclusion_get_procinfo(), index_opclass_options(), initGinState(), initGISTstate(), RelationGetIndexRawAttOptions(), spgdoinsert(), and spgGetCache().
FmgrInfo* index_getprocinfo | ( | Relation | irel, |
AttrNumber | attnum, | ||
uint16 | procnum | ||
) |
Definition at line 803 of file indexam.c.
References IndexAmRoutine::amoptsprocnum, IndexAmRoutine::amsupport, Assert, elog, ERROR, fmgr_info_cxt(), FmgrInfo::fn_oid, InvalidOid, MemoryContextSwitchTo(), RelationData::rd_indam, RelationData::rd_indexcxt, RelationData::rd_support, RelationData::rd_supportinfo, RegProcedureIsValid, RelationGetIndexAttOptions(), RelationGetRelationName, and set_fn_opclass_options().
Referenced by _bt_first(), _bt_mkscankey(), _hash_datum2hashkey(), brin_build_desc(), brinbuildCallback(), bringetbitmap(), brininsert(), doPickSplit(), inclusion_get_procinfo(), index_opclass_options(), initBloomState(), initGinState(), initGISTstate(), spgbeginscan(), spgdoinsert(), spgGetCache(), and union_tuples().
bool index_insert | ( | Relation | indexRelation, |
Datum * | values, | ||
bool * | isnull, | ||
ItemPointer | heap_t_ctid, | ||
Relation | heapRelation, | ||
IndexUniqueCheck | checkUnique, | ||
bool | indexUnchanged, | ||
IndexInfo * | indexInfo | ||
) |
Definition at line 176 of file indexam.c.
References IndexAmRoutine::aminsert, IndexAmRoutine::ampredlocks, CHECK_REL_PROCEDURE, CheckForSerializableConflictIn(), InvalidBlockNumber, RelationData::rd_indam, and RELATION_CHECKS.
Referenced by CatalogIndexInsert(), ExecInsertIndexTuples(), heapam_index_validate_scan(), toast_save_datum(), and unique_key_recheck().
void index_markpos | ( | IndexScanDesc | scan | ) |
Definition at line 353 of file indexam.c.
References IndexAmRoutine::ammarkpos, CHECK_SCAN_PROCEDURE, IndexScanDescData::indexRelation, RelationData::rd_indam, and SCAN_CHECKS.
Referenced by ExecIndexMarkPos(), and ExecIndexOnlyMarkPos().
bytea* index_opclass_options | ( | Relation | indrel, |
AttrNumber | attnum, | ||
Datum | attoptions, | ||
bool | validate | ||
) |
Definition at line 939 of file indexam.c.
References IndexAmRoutine::amoptsprocnum, Assert, build_local_reloptions(), DatumGetPointer, ereport, errcode(), errmsg(), ERROR, FunctionCall1, generate_opclass_name(), index_getprocid(), index_getprocinfo(), INDEXRELID, init_local_reloptions(), InvalidOid, OidIsValid, PointerGetDatum, RelationData::rd_indam, RelationData::rd_indextuple, SysCacheGetAttr(), and oidvector::values.
Referenced by index_create(), and RelationGetIndexAttOptions().
Definition at line 132 of file indexam.c.
References ereport, errcode(), errmsg(), ERROR, RelationData::rd_rel, relation_open(), and RelationGetRelationName.
Referenced by _bt_parallel_build_main(), ATExecAddIndex(), ATExecAddIndexConstraint(), ATExecDetachPartition(), ATExecReplicaIdentity(), ATExecSetStorage(), AttachPartitionEnsureIndexes(), brin_desummarize_range(), brin_page_items(), brin_summarize_range(), brincostestimate(), bt_index_check_internal(), build_indices(), BuildEventTriggerCache(), check_index_is_clusterable(), CheckIndexCompatible(), copy_table_data(), DefineIndex(), DefineRelation(), enum_endpoint(), enum_range_internal(), ExecInitBitmapIndexScan(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecOpenIndices(), ExecRefreshMatView(), expandTableLikeClause(), get_actual_variable_range(), get_relation_info(), gin_clean_pending_list(), gincostestimate(), gist_page_items(), hash_bitmap_info(), index_concurrently_build(), index_concurrently_create_copy(), index_concurrently_set_dead(), index_drop(), indexam_property(), infer_arbiter_indexes(), InitCatCachePhase2(), lookup_ts_config_cache(), open_lo_relation(), pg_nextoid(), pgstathashindex(), plan_create_index_workers(), refresh_by_match_merge(), reindex_index(), ReindexRelationConcurrently(), RelationFindReplTupleByIndex(), RelationGetIndexAttrBitmap(), RelationTruncateIndexes(), systable_beginscan(), toast_open_indexes(), transformIndexConstraint(), TryReuseIndex(), unique_key_recheck(), vac_open_indexes(), and validate_index().
void index_parallelrescan | ( | IndexScanDesc | scan | ) |
Definition at line 466 of file indexam.c.
References IndexAmRoutine::amparallelrescan, IndexScanDescData::indexRelation, RelationData::rd_indam, SCAN_CHECKS, table_index_fetch_reset(), and IndexScanDescData::xs_heapfetch.
Referenced by ExecIndexOnlyScanReInitializeDSM(), and ExecIndexScanReInitializeDSM().
Definition at line 402 of file indexam.c.
References add_size(), IndexAmRoutine::amestimateparallelscan, EstimateSnapshotSpace(), MAXALIGN, offsetof, RelationData::rd_indam, and RELATION_CHECKS.
Referenced by ExecIndexOnlyScanEstimate(), and ExecIndexScanEstimate().
void index_parallelscan_initialize | ( | Relation | heapRelation, |
Relation | indexRelation, | ||
Snapshot | snapshot, | ||
ParallelIndexScanDesc | target | ||
) |
Definition at line 435 of file indexam.c.
References add_size(), IndexAmRoutine::aminitparallelscan, EstimateSnapshotSpace(), MAXALIGN, offsetof, OffsetToPointer, ParallelIndexScanDescData::ps_indexid, ParallelIndexScanDescData::ps_offset, ParallelIndexScanDescData::ps_relid, ParallelIndexScanDescData::ps_snapshot_data, RelationData::rd_indam, RELATION_CHECKS, RelationGetRelid, and SerializeSnapshot().
Referenced by ExecIndexOnlyScanInitializeDSM(), and ExecIndexScanInitializeDSM().
void index_rescan | ( | IndexScanDesc | scan, |
ScanKey | keys, | ||
int | nkeys, | ||
ScanKey | orderbys, | ||
int | norderbys | ||
) |
Definition at line 297 of file indexam.c.
References IndexAmRoutine::amrescan, Assert, CHECK_SCAN_PROCEDURE, IndexScanDescData::indexRelation, IndexScanDescData::kill_prior_tuple, IndexScanDescData::numberOfKeys, IndexScanDescData::numberOfOrderBys, RelationData::rd_indam, SCAN_CHECKS, table_index_fetch_reset(), IndexScanDescData::xs_heap_continue, and IndexScanDescData::xs_heapfetch.
Referenced by check_exclusion_or_unique_constraint(), ExecIndexOnlyScanInitializeDSM(), ExecIndexOnlyScanInitializeWorker(), ExecIndexScanInitializeDSM(), ExecIndexScanInitializeWorker(), ExecInitBitmapIndexScan(), ExecReScanBitmapIndexScan(), ExecReScanIndexOnlyScan(), ExecReScanIndexScan(), get_actual_variable_endpoint(), heapam_relation_copy_for_cluster(), IndexNext(), IndexNextWithReorder(), IndexOnlyNext(), MultiExecBitmapIndexScan(), RelationFindReplTupleByIndex(), systable_beginscan(), and systable_beginscan_ordered().
void index_restrpos | ( | IndexScanDesc | scan | ) |
Definition at line 377 of file indexam.c.
References IndexAmRoutine::amrestrpos, Assert, CHECK_SCAN_PROCEDURE, IndexScanDescData::indexRelation, IsMVCCSnapshot, IndexScanDescData::kill_prior_tuple, RelationData::rd_indam, SCAN_CHECKS, table_index_fetch_reset(), IndexScanDescData::xs_heap_continue, IndexScanDescData::xs_heapfetch, and IndexScanDescData::xs_snapshot.
Referenced by ExecIndexOnlyRestrPos(), and ExecIndexRestrPos().
void index_store_float8_orderby_distances | ( | IndexScanDesc | scan, |
Oid * | orderByTypes, | ||
IndexOrderByDistance * | distances, | ||
bool | recheckOrderBy | ||
) |
Definition at line 871 of file indexam.c.
References Assert, DatumGetPointer, elog, ERROR, Float4GetDatum(), Float8GetDatum(), i, IndexScanDescData::numberOfOrderBys, pfree(), value, IndexScanDescData::xs_orderbynulls, IndexScanDescData::xs_orderbyvals, and IndexScanDescData::xs_recheckorderby.
Referenced by getNextNearest(), and spggettuple().
IndexBulkDeleteResult* index_vacuum_cleanup | ( | IndexVacuumInfo * | info, |
IndexBulkDeleteResult * | stats | ||
) |
Definition at line 712 of file indexam.c.
References IndexAmRoutine::amvacuumcleanup, CHECK_REL_PROCEDURE, IndexVacuumInfo::index, RelationData::rd_indam, and RELATION_CHECKS.
Referenced by do_analyze_rel(), and lazy_cleanup_index().