PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/genam.h"
#include "access/heaptoast.h"
#include "access/relscan.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "common/hashfn.h"
#include "common/pg_prng.h"
#include "miscadmin.h"
#include "port/pg_bitutils.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/catcache.h"
#include "utils/datum.h"
#include "utils/fmgroids.h"
#include "utils/injection_point.h"
#include "utils/inval.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/resowner.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | CatCInProgress |
Macros | |
#define | HASH_INDEX(h, sz) ((Index) ((h) & ((sz) - 1))) |
#define | CACHE_elog(...) |
#define | InitCatCache_DEBUG2 |
#define | CatalogCacheInitializeCache_DEBUG1 |
#define | CatalogCacheInitializeCache_DEBUG2 |
Typedefs | |
typedef struct CatCInProgress | CatCInProgress |
Variables | |
static CatCInProgress * | catcache_in_progress_stack = NULL |
static CatCacheHeader * | CacheHdr = NULL |
static const ResourceOwnerDesc | catcache_resowner_desc |
static const ResourceOwnerDesc | catlistref_resowner_desc |
#define CACHE_elog | ( | ... | ) |
Definition at line 80 of file catcache.c.
#define CatalogCacheInitializeCache_DEBUG1 |
Definition at line 1081 of file catcache.c.
#define CatalogCacheInitializeCache_DEBUG2 |
Definition at line 1082 of file catcache.c.
#define HASH_INDEX | ( | h, | |
sz | |||
) | ((Index) ((h) & ((sz) - 1))) |
Definition at line 70 of file catcache.c.
#define InitCatCache_DEBUG2 |
Definition at line 874 of file catcache.c.
typedef struct CatCInProgress CatCInProgress |
|
inlinestatic |
Definition at line 441 of file catcache.c.
References CatCInProgress::cache, catcache::cc_fastequal, and i.
Referenced by SearchCatCacheInternal(), and SearchCatCacheList().
|
static |
Definition at line 344 of file catcache.c.
References CatCInProgress::cache, CACHE_elog, catcache::cc_hashfunc, catcache::cc_relname, DEBUG2, elog, FATAL, and pg_rotate_left32().
Referenced by CatalogCacheComputeTupleHashValue(), GetCatCacheHashValue(), SearchCatCacheInternal(), and SearchCatCacheList().
|
static |
Definition at line 386 of file catcache.c.
References Assert(), CatCInProgress::cache, CatalogCacheComputeHashValue(), catcache::cc_keyno, catcache::cc_tupdesc, elog, fastgetattr(), and FATAL.
Referenced by PrepareToInvalidateCacheTuple(), and SearchCatCacheList().
|
static |
Definition at line 2111 of file catcache.c.
References Assert(), catctup::c_list, CatCInProgress::cache, catctup::cache_elem, CacheHdr, CacheMemoryContext, catcache_in_progress_stack, CatCacheCopyKeys(), catcache::cc_bucket, catcache::cc_keyno, catcache::cc_nbuckets, catcache::cc_nkeys, catcache::cc_ntup, catcache::cc_tupdesc, catcacheheader::ch_ntup, catctup::ct_magic, CT_MAGIC, CatCInProgress::dead, catctup::dead, dlist_push_head(), CatCInProgress::hash_value, catctup::hash_value, heap_freetuple(), heap_getattr(), HeapTupleHasExternal(), i, catctup::keys, CatCInProgress::list, MAXALIGN, MemoryContextSwitchTo(), catctup::my_cache, catctup::negative, CatCInProgress::next, palloc(), PG_END_TRY, PG_FINALLY, pg_global_prng_state, pg_prng_uint32(), PG_TRY, PG_UINT32_MAX, catctup::refcount, RehashCatCache(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, toast_flatten_tuple(), and catctup::tuple.
Referenced by SearchCatCacheList(), and SearchCatCacheMiss().
void CatalogCacheFlushCatalog | ( | Oid | catId | ) |
Definition at line 834 of file catcache.c.
References CatCInProgress::cache, CACHE_elog, CacheHdr, CallSyscacheCallbacks(), catcache::cc_reloid, catcacheheader::ch_caches, slist_iter::cur, DEBUG2, catcache::id, ResetCatalogCache(), slist_container, and slist_foreach.
Referenced by LocalExecuteInvalidationMessage().
|
static |
Definition at line 1086 of file catcache.c.
References AccessShareLock, Assert(), BTEqualStrategyNumber, CatCInProgress::cache, CACHE_elog, CacheMemoryContext, CatalogCacheInitializeCache_DEBUG1, CatalogCacheInitializeCache_DEBUG2, catcache::cc_fastequal, catcache::cc_hashfunc, catcache::cc_keyno, catcache::cc_nkeys, catcache::cc_relisshared, catcache::cc_relname, catcache::cc_reloid, catcache::cc_skey, catcache::cc_tupdesc, CreateTupleDescCopyConstr(), DEBUG2, elog, FATAL, fmgr_info_cxt(), GetCCHashEqFuncs(), i, InvalidOid, MemoryContextSwitchTo(), pstrdup(), RelationGetDescr, RelationGetForm, RelationGetRelationName, ScanKeyData::sk_attno, ScanKeyData::sk_collation, ScanKeyData::sk_func, ScanKeyData::sk_strategy, ScanKeyData::sk_subtype, table_close(), table_open(), and TupleDescAttr().
Referenced by GetCatCacheHashValue(), InitCatCachePhase2(), PrepareToInvalidateCacheTuple(), SearchCatCacheInternal(), and SearchCatCacheList().
|
static |
Definition at line 2284 of file catcache.c.
References attnum, datumCopy(), DatumGetCString(), i, NameGetDatum(), namestrcpy(), and TupleDescAttr().
Referenced by CatalogCacheCreateEntry(), and SearchCatCacheList().
Definition at line 2259 of file catcache.c.
References Assert(), attnum, DatumGetPointer(), i, pfree(), and TupleDescAttr().
Referenced by CatCacheRemoveCList(), and CatCacheRemoveCTup().
Definition at line 625 of file catcache.c.
References Assert(), catctup::c_list, CatCInProgress::cache, CACHE_elog, catcache_in_progress_stack, CatCacheRemoveCList(), CatCacheRemoveCTup(), catcache::cc_bucket, catcache::cc_lbucket, catcache::cc_nbuckets, catcache::cc_nlbuckets, dlist_mutable_iter::cur, catctup::dead, catclist::dead, DEBUG2, dlist_container, dlist_foreach_modify, HASH_INDEX, catctup::hash_value, i, CatCInProgress::next, catctup::refcount, and catclist::refcount.
Referenced by SysCacheInvalidate().
Definition at line 570 of file catcache.c.
References Assert(), catctup::c_list, CatCInProgress::cache, catclist::cache_elem, CatCacheFreeKeys(), CatCacheRemoveCTup(), catcache::cc_keyno, catcache::cc_nlist, catcache::cc_tupdesc, catctup::dead, dlist_delete(), i, catclist::keys, catclist::members, catclist::my_cache, catclist::n_members, catclist::nkeys, pfree(), catctup::refcount, and catclist::refcount.
Referenced by CatCacheInvalidate(), CatCacheRemoveCTup(), ReleaseCatCacheListWithOwner(), and ResetCatalogCache().
Definition at line 528 of file catcache.c.
References Assert(), catctup::c_list, CatCInProgress::cache, catctup::cache_elem, CacheHdr, CatCacheFreeKeys(), CatCacheRemoveCList(), catcache::cc_keyno, catcache::cc_nkeys, catcache::cc_ntup, catcache::cc_tupdesc, catcacheheader::ch_ntup, catctup::dead, dlist_delete(), catctup::keys, catctup::my_cache, catctup::negative, pfree(), and catctup::refcount.
Referenced by CatCacheInvalidate(), CatCacheRemoveCList(), ReleaseCatCacheWithOwner(), ResetCatalogCache(), and SearchCatCacheList().
Definition at line 191 of file catcache.c.
References a, b, and DatumGetChar().
Referenced by GetCCHashEqFuncs().
Definition at line 197 of file catcache.c.
References DatumGetChar(), and murmurhash32().
Referenced by GetCCHashEqFuncs().
void CreateCacheMemoryContext | ( | void | ) |
Definition at line 708 of file catcache.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CacheMemoryContext, and TopMemoryContext.
Referenced by assign_record_type_typmod(), BuildEventTriggerCache(), init_ts_config_cache(), InitCatCache(), InitializeAttoptCache(), InitializeRelfilenumberMap(), InitializeTableSpaceCache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupOpclassInfo(), RelationBuildLocalRelation(), and RelationCacheInitialize().
Definition at line 1662 of file catcache.c.
References CatCInProgress::cache, CatalogCacheComputeHashValue(), CatalogCacheInitializeCache(), catcache::cc_nkeys, and catcache::cc_tupdesc.
Referenced by GetSysCacheHashValue().
|
static |
Definition at line 274 of file catcache.c.
References chareqfast(), charhashfast(), elog, FATAL, int2eqfast(), int2hashfast(), int4eqfast(), int4hashfast(), InvalidOid, nameeqfast(), namehashfast(), oidvectoreqfast(), oidvectorhashfast(), texteqfast(), and texthashfast().
Referenced by CatalogCacheInitializeCache().
|
static |
Definition at line 1247 of file catcache.c.
References CatCInProgress::cache, criticalRelcachesBuilt, criticalSharedRelcachesBuilt, and catcache::id.
Referenced by SearchCatCacheList(), and SearchCatCacheMiss().
CatCache * InitCatCache | ( | int | id, |
Oid | reloid, | ||
Oid | indexoid, | ||
int | nkeys, | ||
const int * | key, | ||
int | nbuckets | ||
) |
Definition at line 878 of file catcache.c.
References Assert(), AttributeNumberIsValid, CacheHdr, CacheMemoryContext, catcache::cc_bucket, catcache::cc_indexoid, catcache::cc_keyno, catcache::cc_lbucket, catcache::cc_nbuckets, catcache::cc_next, catcache::cc_nkeys, catcache::cc_nlbuckets, catcache::cc_nlist, catcache::cc_ntup, catcache::cc_relisshared, catcache::cc_relname, catcache::cc_reloid, catcache::cc_tupdesc, catcacheheader::ch_caches, catcacheheader::ch_ntup, CreateCacheMemoryContext(), i, catcache::id, InitCatCache_DEBUG2, sort-test::key, MCXT_ALLOC_ZERO, MemoryContextSwitchTo(), on_proc_exit(), palloc(), palloc0(), palloc_aligned(), PG_CACHE_LINE_SIZE, slist_init(), and slist_push_head().
Referenced by InitCatalogCache().
void InitCatCachePhase2 | ( | CatCache * | cache, |
bool | touch_index | ||
) |
Definition at line 1195 of file catcache.c.
References AccessShareLock, Assert(), CatCInProgress::cache, CatalogCacheInitializeCache(), catcache::cc_indexoid, catcache::cc_reloid, catcache::cc_tupdesc, catcache::id, index_close(), index_open(), LockRelationOid(), RelationData::rd_index, and UnlockRelationOid().
Referenced by InitCatalogCachePhase2(), and SysCacheGetAttr().
Definition at line 220 of file catcache.c.
References a, b, and DatumGetInt16().
Referenced by GetCCHashEqFuncs().
Definition at line 226 of file catcache.c.
References DatumGetInt16(), and murmurhash32().
Referenced by GetCCHashEqFuncs().
Definition at line 232 of file catcache.c.
References a, b, and DatumGetInt32().
Referenced by GetCCHashEqFuncs().
Definition at line 238 of file catcache.c.
References DatumGetInt32(), and murmurhash32().
Referenced by GetCCHashEqFuncs().
Definition at line 203 of file catcache.c.
References a, b, DatumGetName(), NAMEDATALEN, and NameStr.
Referenced by GetCCHashEqFuncs().
Definition at line 212 of file catcache.c.
References DatumGetName(), hash_any(), sort-test::key, and NameStr.
Referenced by GetCCHashEqFuncs().
Definition at line 261 of file catcache.c.
References a, b, DatumGetBool(), DirectFunctionCall2, and oidvectoreq().
Referenced by GetCCHashEqFuncs().
Definition at line 267 of file catcache.c.
References DatumGetInt32(), DirectFunctionCall1, and hashoidvector().
Referenced by GetCCHashEqFuncs().
void PrepareToInvalidateCacheTuple | ( | Relation | relation, |
HeapTuple | tuple, | ||
HeapTuple | newtuple, | ||
void(*)(int, uint32, Oid, void *) | function, | ||
void * | context | ||
) |
Definition at line 2354 of file catcache.c.
References Assert(), CACHE_elog, CacheHdr, CatalogCacheComputeTupleHashValue(), CatalogCacheInitializeCache(), catcache::cc_nkeys, catcache::cc_relisshared, catcache::cc_reloid, catcache::cc_tupdesc, catcacheheader::ch_caches, slist_iter::cur, DEBUG2, function, HeapTupleIsValid, catcache::id, MyDatabaseId, PointerIsValid, RelationGetRelid, RelationIsValid, slist_container, and slist_foreach.
Referenced by CacheInvalidateHeapTupleCommon().
|
static |
Definition at line 985 of file catcache.c.
References catctup::cache_elem, CacheMemoryContext, catcache::cc_bucket, catcache::cc_nbuckets, catcache::cc_ntup, catcache::cc_relname, dlist_mutable_iter::cur, DEBUG1, dlist_container, dlist_delete(), dlist_foreach_modify, dlist_push_head(), elog, HASH_INDEX, catctup::hash_value, i, catcache::id, MemoryContextAllocZero(), and pfree().
Referenced by CatalogCacheCreateEntry().
|
static |
Definition at line 1023 of file catcache.c.
References catclist::cache_elem, CacheMemoryContext, catcache::cc_lbucket, catcache::cc_nlbuckets, catcache::cc_nlist, catcache::cc_relname, dlist_mutable_iter::cur, DEBUG1, dlist_container, dlist_delete(), dlist_foreach_modify, dlist_push_head(), elog, HASH_INDEX, catclist::hash_value, i, catcache::id, MemoryContextAllocZero(), and pfree().
Referenced by SearchCatCacheList().
void ReleaseCatCache | ( | HeapTuple | tuple | ) |
Definition at line 1623 of file catcache.c.
References CurrentResourceOwner, and ReleaseCatCacheWithOwner().
Referenced by ReleaseSysCache().
void ReleaseCatCacheList | ( | CatCList * | list | ) |
Definition at line 2071 of file catcache.c.
References CurrentResourceOwner, sort-test::list, and ReleaseCatCacheListWithOwner().
Referenced by AddEnumLabel(), blvalidate(), brinvalidate(), btvalidate(), ginvalidate(), gistvalidate(), hashvalidate(), opclass_for_family_datatype(), RenameEnumLabel(), sepgsql_relation_drop(), spgvalidate(), and transformFrameOffset().
|
static |
Definition at line 2077 of file catcache.c.
References Assert(), CatCacheRemoveCList(), CL_MAGIC, CurrentResourceOwner, sort-test::list, and ResourceOwnerForgetCatCacheListRef().
Referenced by ReleaseCatCacheList(), and ResOwnerReleaseCatCacheList().
|
static |
Definition at line 1629 of file catcache.c.
References Assert(), catctup::c_list, CatCacheRemoveCTup(), catctup::ct_magic, CT_MAGIC, CurrentResourceOwner, catctup::dead, catctup::my_cache, catctup::refcount, catclist::refcount, ResourceOwnerForgetCatCacheRef(), and catctup::tuple.
Referenced by ReleaseCatCache(), and ResOwnerReleaseCatCache().
|
static |
Definition at line 736 of file catcache.c.
References Assert(), catctup::c_list, CatCInProgress::cache, catcache_in_progress_stack, CatCacheRemoveCList(), CatCacheRemoveCTup(), catcache::cc_bucket, catcache::cc_lbucket, catcache::cc_nbuckets, catcache::cc_nlbuckets, dlist_mutable_iter::cur, catctup::dead, catclist::dead, dlist_container, dlist_foreach_modify, i, CatCInProgress::next, catctup::refcount, and catclist::refcount.
Referenced by CatalogCacheFlushCatalog(), and ResetCatalogCachesExt().
void ResetCatalogCaches | ( | void | ) |
void ResetCatalogCachesExt | ( | bool | debug_discard | ) |
Definition at line 804 of file catcache.c.
References CatCInProgress::cache, CACHE_elog, CacheHdr, catcacheheader::ch_caches, slist_iter::cur, DEBUG2, ResetCatalogCache(), slist_container, and slist_foreach.
Referenced by InvalidateSystemCachesExtended(), and ResetCatalogCaches().
|
inlinestatic |
Definition at line 174 of file catcache.c.
References catlistref_resowner_desc, sort-test::list, PointerGetDatum(), and ResourceOwnerForget().
Referenced by ReleaseCatCacheListWithOwner().
|
inlinestatic |
Definition at line 164 of file catcache.c.
References catcache_resowner_desc, PointerGetDatum(), and ResourceOwnerForget().
Referenced by ReleaseCatCacheWithOwner().
|
inlinestatic |
Definition at line 169 of file catcache.c.
References catlistref_resowner_desc, sort-test::list, PointerGetDatum(), and ResourceOwnerRemember().
Referenced by SearchCatCacheList().
|
inlinestatic |
Definition at line 159 of file catcache.c.
References catcache_resowner_desc, PointerGetDatum(), and ResourceOwnerRemember().
Referenced by SearchCatCacheInternal(), and SearchCatCacheMiss().
|
static |
Definition at line 2422 of file catcache.c.
References Assert(), catcache::cc_relname, catctup::ct_magic, CT_MAGIC, DatumGetPointer(), catcache::id, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), catctup::my_cache, psprintf(), catctup::refcount, and HeapTupleData::t_self.
|
static |
Definition at line 2445 of file catcache.c.
References DatumGetPointer(), sort-test::list, and psprintf().
|
static |
Definition at line 2416 of file catcache.c.
References DatumGetPointer(), and ReleaseCatCacheWithOwner().
|
static |
Definition at line 2439 of file catcache.c.
References DatumGetPointer(), and ReleaseCatCacheListWithOwner().
Definition at line 1312 of file catcache.c.
References CatCInProgress::cache, catcache::cc_nkeys, and SearchCatCacheInternal().
Referenced by SearchSysCache().
Definition at line 1329 of file catcache.c.
References CatCInProgress::cache, and SearchCatCacheInternal().
Referenced by SearchSysCache1().
Definition at line 1337 of file catcache.c.
References CatCInProgress::cache, and SearchCatCacheInternal().
Referenced by SearchSysCache2().
Definition at line 1345 of file catcache.c.
References CatCInProgress::cache, and SearchCatCacheInternal().
Referenced by SearchSysCache3().
Definition at line 1353 of file catcache.c.
References CatCInProgress::cache, and SearchCatCacheInternal().
Referenced by SearchSysCache4().
|
inlinestatic |
Definition at line 1363 of file catcache.c.
References Assert(), CatCInProgress::cache, catctup::cache_elem, CACHE_elog, CatalogCacheCompareTuple(), CatalogCacheComputeHashValue(), CatalogCacheInitializeCache(), CATCACHE_MAXKEYS, catcache::cc_bucket, catcache::cc_nbuckets, catcache::cc_nkeys, catcache::cc_relname, catcache::cc_tupdesc, dlist_iter::cur, CurrentResourceOwner, catctup::dead, DEBUG2, dlist_container, dlist_foreach, dlist_move_head(), HASH_INDEX, catctup::hash_value, IsTransactionState(), catctup::keys, catctup::negative, catctup::refcount, ResourceOwnerEnlarge(), ResourceOwnerRememberCatCacheRef(), SearchCatCacheMiss(), catctup::tuple, and unlikely.
Referenced by SearchCatCache(), SearchCatCache1(), SearchCatCache2(), SearchCatCache3(), and SearchCatCache4().
Definition at line 1696 of file catcache.c.
References AccessShareLock, Assert(), catctup::c_list, CatCInProgress::cache, catclist::cache_elem, CACHE_elog, CacheMemoryContext, CatalogCacheCompareTuple(), CatalogCacheComputeHashValue(), CatalogCacheComputeTupleHashValue(), CatalogCacheCreateEntry(), CatalogCacheInitializeCache(), catcache_in_progress_stack, CATCACHE_MAXKEYS, CatCacheCopyKeys(), CatCacheRemoveCTup(), catcache::cc_bucket, catcache::cc_indexoid, catcache::cc_keyno, catcache::cc_lbucket, catcache::cc_nbuckets, catcache::cc_nkeys, catcache::cc_nlbuckets, catcache::cc_nlist, catcache::cc_relname, catcache::cc_reloid, catcache::cc_skey, catcache::cc_tupdesc, catclist::cl_magic, CL_MAGIC, dlist_iter::cur, CurrentResourceOwner, CatCInProgress::dead, catctup::dead, catclist::dead, DEBUG2, dlist_container, dlist_foreach, dlist_move_head(), dlist_push_head(), HASH_INDEX, CatCInProgress::hash_value, catctup::hash_value, catclist::hash_value, HeapTupleIsValid, i, IndexScanOK(), INJECTION_POINT, SysScanDescData::irel, ItemPointerEquals(), catclist::keys, lappend(), lfirst, CatCInProgress::list, list_length(), catclist::members, MemoryContextAllocZero(), MemoryContextSwitchTo(), catclist::my_cache, catclist::n_members, catctup::negative, CatCInProgress::next, NIL, catclist::nkeys, catclist::ordered, palloc(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, catctup::refcount, catclist::refcount, RehashCatCacheLists(), ResourceOwnerEnlarge(), ResourceOwnerRememberCatCacheListRef(), ScanKeyData::sk_argument, systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), table_open(), catctup::tuple, and unlikely.
Referenced by SearchSysCacheList().
|
static |
Definition at line 1475 of file catcache.c.
References AccessShareLock, Assert(), CatCInProgress::cache, CACHE_elog, CacheHdr, CatalogCacheCreateEntry(), CATCACHE_MAXKEYS, catcache::cc_indexoid, catcache::cc_ntup, catcache::cc_relname, catcache::cc_reloid, catcache::cc_skey, catcacheheader::ch_ntup, CurrentResourceOwner, DEBUG2, HeapTupleIsValid, IndexScanOK(), IsBootstrapProcessingMode, catctup::refcount, ResourceOwnerEnlarge(), ResourceOwnerRememberCatCacheRef(), ScanKeyData::sk_argument, systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), and catctup::tuple.
Referenced by SearchCatCacheInternal().
Definition at line 244 of file catcache.c.
References a, b, DatumGetBool(), DirectFunctionCall2Coll(), and texteq().
Referenced by GetCCHashEqFuncs().
Definition at line 254 of file catcache.c.
References DatumGetInt32(), DirectFunctionCall1Coll(), and hashtext().
Referenced by GetCCHashEqFuncs().
|
static |
Definition at line 84 of file catcache.c.
Referenced by CatalogCacheCreateEntry(), CatalogCacheFlushCatalog(), CatCacheRemoveCTup(), InitCatCache(), PrepareToInvalidateCacheTuple(), ResetCatalogCachesExt(), and SearchCatCacheMiss().
|
static |
Definition at line 61 of file catcache.c.
Referenced by CatalogCacheCreateEntry(), CatCacheInvalidate(), ResetCatalogCache(), and SearchCatCacheList().
|
static |
Definition at line 137 of file catcache.c.
Referenced by ResourceOwnerForgetCatCacheRef(), and ResourceOwnerRememberCatCacheRef().
|
static |
Definition at line 147 of file catcache.c.
Referenced by ResourceOwnerForgetCatCacheListRef(), and ResourceOwnerRememberCatCacheListRef().