PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <time.h>
#include "access/nbtree.h"
#include "access/reloptions.h"
#include "access/relscan.h"
#include "miscadmin.h"
#include "utils/array.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | BTSortArrayContext |
struct | BTOneVacInfo |
struct | BTVacInfo |
Typedefs | |
typedef struct BTSortArrayContext | BTSortArrayContext |
typedef struct BTOneVacInfo | BTOneVacInfo |
typedef struct BTVacInfo | BTVacInfo |
Variables | |
static BTVacInfo * | btvacinfo |
typedef struct BTOneVacInfo BTOneVacInfo |
bool _bt_advance_array_keys | ( | IndexScanDesc | scan, |
ScanDirection | dir | ||
) |
Definition at line 558 of file nbtutils.c.
References _bt_parallel_advance_array_keys(), BTScanOpaqueData::arrayKeyData, BTScanOpaqueData::arrayKeys, BTArrayKeyInfo::cur_elem, BTArrayKeyInfo::elem_values, i, BTArrayKeyInfo::num_elems, BTScanOpaqueData::numArrayKeys, IndexScanDescData::opaque, IndexScanDescData::parallel_scan, BTArrayKeyInfo::scan_key, ScanDirectionIsBackward, and ScanKeyData::sk_argument.
Referenced by btgetbitmap(), and btgettuple().
bool _bt_check_natts | ( | Relation | rel, |
Page | page, | ||
OffsetNumber | offnum | ||
) |
Definition at line 2134 of file nbtutils.c.
References Assert, BT_N_KEYS_OFFSET_MASK, BTreeTupleGetNAtts, FirstOffsetNumber, INDEX_ALT_TID_MASK, INDEX_MAX_KEYS, IndexRelationGetNumberOfAttributes, IndexRelationGetNumberOfKeyAttributes, ItemPointerGetOffsetNumber, P_FIRSTDATAKEY, P_HIKEY, P_IGNORE, P_ISLEAF, P_RIGHTMOST, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetSpecialPointer, StaticAssertStmt, IndexTupleData::t_info, and IndexTupleData::t_tid.
Referenced by _bt_compare(), and bt_target_page_check().
|
static |
Definition at line 1565 of file nbtutils.c.
References Assert, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, DatumGetInt32, DatumGetPointer, elog, ERROR, FunctionCall2Coll(), index_getattr, ScanDirectionIsBackward, ScanDirectionIsForward, ScanKeyData::sk_argument, ScanKeyData::sk_attno, SK_BT_DESC, SK_BT_NULLS_FIRST, SK_BT_REQBKWD, SK_BT_REQFWD, ScanKeyData::sk_collation, ScanKeyData::sk_flags, ScanKeyData::sk_func, SK_ISNULL, SK_ROW_END, SK_ROW_MEMBER, and ScanKeyData::sk_strategy.
Referenced by _bt_checkkeys().
IndexTuple _bt_checkkeys | ( | IndexScanDesc | scan, |
Page | page, | ||
OffsetNumber | offnum, | ||
ScanDirection | dir, | ||
bool * | continuescan | ||
) |
Definition at line 1370 of file nbtutils.c.
References _bt_check_rowcompare(), Assert, BTreeTupleGetNAtts, DatumGetBool, FunctionCall2Coll(), IndexScanDescData::ignore_killed_tuples, index_getattr, IndexScanDescData::indexRelation, ItemIdIsDead, BTScanOpaqueData::keyData, BTScanOpaqueData::numberOfKeys, IndexScanDescData::opaque, P_FIRSTDATAKEY, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetSpecialPointer, RelationGetDescr, ScanDirectionIsBackward, ScanDirectionIsForward, ScanKeyData::sk_argument, ScanKeyData::sk_attno, SK_BT_NULLS_FIRST, SK_BT_REQBKWD, SK_BT_REQFWD, ScanKeyData::sk_collation, ScanKeyData::sk_flags, ScanKeyData::sk_func, SK_ISNULL, SK_ROW_HEADER, SK_SEARCHNOTNULL, SK_SEARCHNULL, and test().
Referenced by _bt_readpage().
|
static |
Definition at line 510 of file nbtutils.c.
References BTSortArrayContext::collation, compare(), DatumGetInt32, BTSortArrayContext::flinfo, FunctionCall2Coll(), and BTSortArrayContext::reverse.
Referenced by _bt_sort_array_elements().
|
static |
Definition at line 1046 of file nbtutils.c.
References Assert, BTCommuteStrategyNumber, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, DatumGetBool, elog, ERROR, FunctionCall2Coll(), get_opcode(), get_opfamily_member(), IndexScanDescData::indexRelation, InvalidOid, OidFunctionCall2Coll(), OidIsValid, RelationData::rd_opcintype, RelationData::rd_opfamily, RegProcedureIsValid, ScanKeyData::sk_argument, ScanKeyData::sk_attno, SK_BT_DESC, SK_BT_NULLS_FIRST, ScanKeyData::sk_collation, ScanKeyData::sk_flags, ScanKeyData::sk_func, SK_ISNULL, SK_SEARCHNOTNULL, SK_SEARCHNULL, ScanKeyData::sk_strategy, and ScanKeyData::sk_subtype.
Referenced by _bt_preprocess_keys().
void _bt_end_vacuum | ( | Relation | rel | ) |
Definition at line 1976 of file nbtutils.c.
References LockRelId::dbId, i, LockInfoData::lockRelId, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), BTVacInfo::num_vacuums, RelationData::rd_lockInfo, LockRelId::relId, BTOneVacInfo::relid, and BTVacInfo::vacuums.
Referenced by _bt_end_vacuum_callback(), and btbulkdelete().
void _bt_end_vacuum_callback | ( | int | code, |
Datum | arg | ||
) |
Definition at line 2004 of file nbtutils.c.
References _bt_end_vacuum(), and DatumGetPointer.
Referenced by btbulkdelete().
|
static |
Definition at line 375 of file nbtutils.c.
References Assert, DatumGetBool, elog, ERROR, BTSortArrayContext::flinfo, fmgr_info(), FunctionCall2Coll(), get_opcode(), get_opfamily_member(), i, IndexScanDescData::indexRelation, InvalidOid, OidIsValid, RelationData::rd_opcintype, RelationData::rd_opfamily, RegProcedureIsValid, ScanKeyData::sk_attno, ScanKeyData::sk_collation, and ScanKeyData::sk_subtype.
Referenced by _bt_preprocess_array_keys().
Definition at line 1210 of file nbtutils.c.
References Assert, BTCommuteStrategyNumber, BTEqualStrategyNumber, BTGreaterStrategyNumber, BTLessStrategyNumber, DatumGetPointer, InvalidOid, ScanKeyData::sk_argument, ScanKeyData::sk_attno, SK_BT_DESC, SK_BT_INDOPTION_SHIFT, SK_BT_NULLS_FIRST, ScanKeyData::sk_collation, ScanKeyData::sk_flags, SK_ISNULL, SK_ROW_END, SK_ROW_HEADER, SK_ROW_MEMBER, SK_SEARCHNOTNULL, SK_SEARCHNULL, ScanKeyData::sk_strategy, and ScanKeyData::sk_subtype.
Referenced by _bt_preprocess_keys().
void _bt_freeskey | ( | ScanKey | skey | ) |
Definition at line 166 of file nbtutils.c.
References pfree().
Referenced by _bt_doinsert(), _bt_load(), tuplesort_begin_cluster(), and tuplesort_begin_index_btree().
void _bt_freestack | ( | BTStack | stack | ) |
Definition at line 175 of file nbtutils.c.
References BTStackData::bts_parent, and pfree().
Referenced by _bt_doinsert(), and _bt_first().
void _bt_killitems | ( | IndexScanDesc | scan | ) |
Definition at line 1744 of file nbtutils.c.
References _bt_getbuf(), _bt_relbuf(), Assert, BT_READ, BTP_HAS_GARBAGE, BTScanPosIsPinned, BTScanPosIsValid, buf, BTScanPosData::buf, BUFFER_LOCK_UNLOCK, BufferGetLSNAtomic(), BufferGetPage, BufferIsValid, BTScanPosData::currPage, BTScanOpaqueData::currPos, BTScanPosData::firstItem, BTScanPosItem::heapTid, i, BTScanPosItem::indexOffset, IndexScanDescData::indexRelation, ItemIdMarkDead, ItemPointerEquals(), BTScanPosData::items, BTScanOpaqueData::killedItems, LockBuffer(), BTScanPosData::lsn, MarkBufferDirtyHint(), BTScanOpaqueData::numKilled, OffsetNumberNext, IndexScanDescData::opaque, P_FIRSTDATAKEY, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetSpecialPointer, and IndexTupleData::t_tid.
Referenced by _bt_steppage(), btendscan(), btrescan(), and btrestrpos().
void _bt_mark_array_keys | ( | IndexScanDesc | scan | ) |
Definition at line 617 of file nbtutils.c.
References BTScanOpaqueData::arrayKeys, BTArrayKeyInfo::cur_elem, i, BTArrayKeyInfo::mark_elem, BTScanOpaqueData::numArrayKeys, and IndexScanDescData::opaque.
Referenced by btmarkpos().
|
static |
Definition at line 1312 of file nbtutils.c.
References Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, DatumGetPointer, elog, ERROR, ScanKeyData::sk_argument, ScanKeyData::sk_attno, SK_BT_REQBKWD, SK_BT_REQFWD, ScanKeyData::sk_flags, SK_ROW_HEADER, SK_ROW_MEMBER, and ScanKeyData::sk_strategy.
Referenced by _bt_preprocess_keys().
ScanKey _bt_mkscankey | ( | Relation | rel, |
IndexTuple | itup | ||
) |
Definition at line 62 of file nbtutils.c.
References arg, Assert, BTORDER_PROC, BTreeTupleGetNAtts, i, index_getattr, index_getprocinfo(), IndexRelationGetNumberOfAttributes, IndexRelationGetNumberOfKeyAttributes, InvalidOid, InvalidStrategy, palloc(), PG_USED_FOR_ASSERTS_ONLY, RelationData::rd_indcollation, RelationData::rd_indoption, RelationGetDescr, ScanKeyEntryInitializeWithInfo(), SK_BT_INDOPTION_SHIFT, and SK_ISNULL.
Referenced by _bt_doinsert(), _bt_pagedel(), bt_right_page_check_scankey(), and bt_target_page_check().
Definition at line 126 of file nbtutils.c.
References BTORDER_PROC, i, index_getprocinfo(), IndexRelationGetNumberOfKeyAttributes, InvalidOid, InvalidStrategy, palloc(), RelationData::rd_indcollation, RelationData::rd_indoption, ScanKeyEntryInitializeWithInfo(), SK_BT_INDOPTION_SHIFT, and SK_ISNULL.
Referenced by _bt_load(), tuplesort_begin_cluster(), and tuplesort_begin_index_btree().
IndexTuple _bt_nonkey_truncate | ( | Relation | rel, |
IndexTuple | itup | ||
) |
Definition at line 2102 of file nbtutils.c.
References Assert, BTreeTupleGetNAtts, BTreeTupleSetNAtts, index_truncate_tuple(), IndexRelationGetNumberOfAttributes, IndexRelationGetNumberOfKeyAttributes, and RelationGetDescr.
Referenced by _bt_buildadd(), and _bt_split().
void _bt_preprocess_array_keys | ( | IndexScanDesc | scan | ) |
Definition at line 203 of file nbtutils.c.
References _bt_find_extreme_element(), _bt_sort_array_elements(), ALLOCSET_SMALL_SIZES, AllocSetContextCreate, ARR_ELEMTYPE, BTScanOpaqueData::arrayContext, BTScanOpaqueData::arrayKeyData, BTScanOpaqueData::arrayKeys, Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, cur, CurrentMemoryContext, DatumGetArrayTypeP, deconstruct_array(), BTArrayKeyInfo::elem_values, elog, ERROR, get_typlenbyvalalign(), i, IndexScanDescData::indexRelation, IndexScanDescData::keyData, MemoryContextReset(), MemoryContextSwitchTo(), BTArrayKeyInfo::num_elems, BTScanOpaqueData::numArrayKeys, IndexScanDescData::numberOfKeys, IndexScanDescData::opaque, palloc(), palloc0(), RelationData::rd_indoption, BTArrayKeyInfo::scan_key, SK_ISNULL, SK_ROW_HEADER, SK_SEARCHARRAY, SK_SEARCHNOTNULL, and SK_SEARCHNULL.
Referenced by btrescan().
void _bt_preprocess_keys | ( | IndexScanDesc | scan | ) |
Definition at line 756 of file nbtutils.c.
References _bt_compare_scankey_args(), _bt_fix_scankey_strategy(), _bt_mark_scankey_required(), BTScanOpaqueData::arrayKeyData, Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, BTMaxStrategyNumber, cur, elog, ERROR, i, IndexScanDescData::indexRelation, IndexScanDescData::keyData, BTScanOpaqueData::keyData, IndexScanDescData::numberOfKeys, BTScanOpaqueData::numberOfKeys, IndexScanDescData::opaque, BTScanOpaqueData::qual_ok, RelationData::rd_indoption, ScanKeyData::sk_flags, SK_ROW_HEADER, and SK_SEARCHNULL.
Referenced by _bt_first(), and _bt_restore_array_keys().
void _bt_restore_array_keys | ( | IndexScanDesc | scan | ) |
Definition at line 636 of file nbtutils.c.
References _bt_preprocess_keys(), BTScanOpaqueData::arrayKeyData, BTScanOpaqueData::arrayKeys, Assert, BTArrayKeyInfo::cur_elem, BTArrayKeyInfo::elem_values, i, BTArrayKeyInfo::mark_elem, BTScanOpaqueData::numArrayKeys, IndexScanDescData::opaque, BTScanOpaqueData::qual_ok, BTArrayKeyInfo::scan_key, and ScanKeyData::sk_argument.
Referenced by btrestrpos().
|
static |
Definition at line 442 of file nbtutils.c.
References _bt_compare_array_elements(), BTORDER_PROC, BTSortArrayContext::collation, compare(), DatumGetInt32, elog, ERROR, BTSortArrayContext::flinfo, fmgr_info(), FunctionCall2Coll(), get_opfamily_proc(), i, IndexScanDescData::indexRelation, InvalidOid, qsort_arg(), RelationData::rd_opcintype, RelationData::rd_opfamily, RegProcedureIsValid, BTSortArrayContext::reverse, ScanKeyData::sk_attno, ScanKeyData::sk_collation, and ScanKeyData::sk_subtype.
Referenced by _bt_preprocess_array_keys().
void _bt_start_array_keys | ( | IndexScanDesc | scan, |
ScanDirection | dir | ||
) |
Definition at line 532 of file nbtutils.c.
References BTScanOpaqueData::arrayKeyData, BTScanOpaqueData::arrayKeys, Assert, BTArrayKeyInfo::cur_elem, BTArrayKeyInfo::elem_values, i, BTArrayKeyInfo::num_elems, BTScanOpaqueData::numArrayKeys, IndexScanDescData::opaque, BTArrayKeyInfo::scan_key, ScanDirectionIsBackward, and ScanKeyData::sk_argument.
Referenced by btgetbitmap(), and btgettuple().
Definition at line 1919 of file nbtutils.c.
References BTVacInfo::cycle_ctr, BTOneVacInfo::cycleid, LockRelId::dbId, elog, ERROR, i, LockInfoData::lockRelId, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAX_BT_CYCLE_ID, BTVacInfo::max_vacuums, BTVacInfo::num_vacuums, RelationData::rd_lockInfo, RelationGetRelationName, LockRelId::relId, BTOneVacInfo::relid, and BTVacInfo::vacuums.
Referenced by btbulkdelete().
Definition at line 1885 of file nbtutils.c.
References BTOneVacInfo::cycleid, LockRelId::dbId, i, LockInfoData::lockRelId, LW_SHARED, LWLockAcquire(), LWLockRelease(), BTVacInfo::num_vacuums, RelationData::rd_lockInfo, LockRelId::relId, BTOneVacInfo::relid, and BTVacInfo::vacuums.
Referenced by _bt_split().
Definition at line 2054 of file nbtutils.c.
References default_reloptions(), and RELOPT_KIND_BTREE.
Referenced by bthandler().
bool btproperty | ( | Oid | index_oid, |
int | attno, | ||
IndexAMProperty | prop, | ||
const char * | propname, | ||
bool * | res, | ||
bool * | isnull | ||
) |
Definition at line 2066 of file nbtutils.c.
References AMPROP_RETURNABLE.
Referenced by bthandler().
void BTreeShmemInit | ( | void | ) |
Definition at line 2026 of file nbtutils.c.
References Assert, BTreeShmemSize(), BTVacInfo::cycle_ctr, IsUnderPostmaster, BTVacInfo::max_vacuums, MaxBackends, BTVacInfo::num_vacuums, and ShmemInitStruct().
Referenced by CreateSharedMemoryAndSemaphores().
Size BTreeShmemSize | ( | void | ) |
Definition at line 2013 of file nbtutils.c.
References add_size(), MaxBackends, mul_size(), and offsetof.
Referenced by BTreeShmemInit(), and CreateSharedMemoryAndSemaphores().
|
static |
Definition at line 1872 of file nbtutils.c.