PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/htup_details.h"
#include "access/xact.h"
#include "access/xloginsert.h"
#include "catalog/catalog.h"
#include "catalog/pg_constraint.h"
#include "miscadmin.h"
#include "storage/sinval.h"
#include "storage/smgr.h"
#include "utils/catcache.h"
#include "utils/inval.h"
#include "utils/memdebug.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relmapper.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | InvalMessageArray |
struct | InvalidationMsgsGroup |
struct | TransInvalidationInfo |
struct | SYSCACHECALLBACK |
struct | RELCACHECALLBACK |
Macros | |
#define | CatCacheMsgs 0 |
#define | RelCacheMsgs 1 |
#define | SetSubGroupToFollow(targetgroup, priorgroup, subgroup) |
#define | SetGroupToFollow(targetgroup, priorgroup) |
#define | NumMessagesInSubGroup(group, subgroup) ((group)->nextmsg[subgroup] - (group)->firstmsg[subgroup]) |
#define | NumMessagesInGroup(group) |
#define | MAX_SYSCACHE_CALLBACKS 64 |
#define | MAX_RELCACHE_CALLBACKS 10 |
#define | ProcessMessageSubGroup(group, subgroup, codeFragment) |
#define | ProcessMessageSubGroupMulti(group, subgroup, codeFragment) |
Typedefs | |
typedef struct InvalMessageArray | InvalMessageArray |
typedef struct InvalidationMsgsGroup | InvalidationMsgsGroup |
typedef struct TransInvalidationInfo | TransInvalidationInfo |
Variables | |
static InvalMessageArray | InvalMessageArrays [2] |
static TransInvalidationInfo * | transInvalInfo = NULL |
int | debug_discard_caches = 0 |
static struct SYSCACHECALLBACK | syscache_callback_list [MAX_SYSCACHE_CALLBACKS] |
static int16 | syscache_callback_links [SysCacheSize] |
static int | syscache_callback_count = 0 |
static struct RELCACHECALLBACK | relcache_callback_list [MAX_RELCACHE_CALLBACKS] |
static int | relcache_callback_count = 0 |
#define NumMessagesInGroup | ( | group | ) |
#define NumMessagesInSubGroup | ( | group, | |
subgroup | |||
) | ((group)->nextmsg[subgroup] - (group)->firstmsg[subgroup]) |
#define ProcessMessageSubGroup | ( | group, | |
subgroup, | |||
codeFragment | |||
) |
#define ProcessMessageSubGroupMulti | ( | group, | |
subgroup, | |||
codeFragment | |||
) |
#define SetGroupToFollow | ( | targetgroup, | |
priorgroup | |||
) |
#define SetSubGroupToFollow | ( | targetgroup, | |
priorgroup, | |||
subgroup | |||
) |
typedef struct InvalidationMsgsGroup InvalidationMsgsGroup |
typedef struct InvalMessageArray InvalMessageArray |
typedef struct TransInvalidationInfo TransInvalidationInfo |
void AcceptInvalidationMessages | ( | void | ) |
Definition at line 806 of file inval.c.
References debug_discard_caches, InvalidateSystemCaches(), InvalidateSystemCachesExtended(), LocalExecuteInvalidationMessage(), ReceiveSharedInvalidMessages(), and recursion_depth.
Referenced by apply_handle_commit_internal(), AtStart_Cache(), ConditionalLockDatabaseObject(), ConditionalLockRelation(), ConditionalLockRelationOid(), ConditionalLockSharedObject(), delay_execution_planner(), InitializeSessionUserId(), LockDatabaseObject(), LockRelation(), LockRelationId(), LockRelationOid(), LockSharedObject(), LogicalRepApplyLoop(), pgstat_init_function_usage(), ProcessCatchupInterrupt(), RangeVarGetRelidExtended(), relation_openrv(), relation_openrv_extended(), RelationBuildPartitionDesc(), RemoveRelations(), and write_relcache_init_file().
|
static |
Definition at line 423 of file inval.c.
References AddInvalidationMessage(), SharedInvalidationMessage::cat, CatCacheMsgs, SharedInvalCatalogMsg::catId, SharedInvalCatalogMsg::dbId, SharedInvalCatalogMsg::id, SHAREDINVALCATALOG_ID, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterCatalogInvalidation().
|
static |
Definition at line 395 of file inval.c.
References AddInvalidationMessage(), Assert, CatCacheMsgs, SharedInvalidationMessage::cc, SharedInvalCatcacheMsg::dbId, SharedInvalCatcacheMsg::hashValue, SharedInvalCatcacheMsg::id, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterCatcacheInvalidation().
|
static |
Definition at line 290 of file inval.c.
References Assert, InvalMessageArrays, InvalMessageArray::maxmsgs, MemoryContextAlloc(), InvalMessageArray::msgs, InvalidationMsgsGroup::nextmsg, repalloc(), and TopTransactionContext.
Referenced by AddCatalogInvalidationMessage(), AddCatcacheInvalidationMessage(), AddRelcacheInvalidationMessage(), and AddSnapshotInvalidationMessage().
|
static |
Definition at line 441 of file inval.c.
References AddInvalidationMessage(), SharedInvalRelcacheMsg::dbId, SharedInvalRelcacheMsg::id, InvalidOid, ProcessMessageSubGroup, SharedInvalidationMessage::rc, RelCacheMsgs, SharedInvalRelcacheMsg::relId, SHAREDINVALRELCACHE_ID, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterRelcacheInvalidation().
|
static |
Definition at line 473 of file inval.c.
References AddInvalidationMessage(), SharedInvalSnapshotMsg::dbId, SharedInvalSnapshotMsg::id, ProcessMessageSubGroup, RelCacheMsgs, SharedInvalSnapshotMsg::relId, SHAREDINVALSNAPSHOT_ID, SharedInvalidationMessage::sn, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterSnapshotInvalidation().
|
static |
Definition at line 500 of file inval.c.
References AppendInvalidationMessageSubGroup(), CatCacheMsgs, generate_unaccent_rules::dest, and RelCacheMsgs.
Referenced by AtEOSubXact_Inval(), AtEOXact_Inval(), and CommandEndInvalidationMessages().
|
static |
Definition at line 330 of file inval.c.
References Assert, generate_unaccent_rules::dest, InvalidationMsgsGroup::firstmsg, InvalidationMsgsGroup::nextmsg, and SetSubGroupToFollow.
Referenced by AppendInvalidationMessages().
void AtEOSubXact_Inval | ( | bool | isCommit | ) |
Definition at line 1082 of file inval.c.
References AppendInvalidationMessages(), Assert, CommandEndInvalidationMessages(), TransInvalidationInfo::CurrentCmdInvalidMsgs, GetCurrentTransactionNestLevel(), LocalExecuteInvalidationMessage(), TransInvalidationInfo::my_level, TransInvalidationInfo::parent, pfree(), TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), TransInvalidationInfo::RelcacheInitFileInval, SetGroupToFollow, and transInvalInfo.
Referenced by AbortSubTransaction(), and CommitSubTransaction().
void AtEOXact_Inval | ( | bool | isCommit | ) |
Definition at line 1025 of file inval.c.
References AppendInvalidationMessages(), Assert, TransInvalidationInfo::CurrentCmdInvalidMsgs, LocalExecuteInvalidationMessage(), TransInvalidationInfo::my_level, TransInvalidationInfo::parent, TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), ProcessInvalidationMessagesMulti(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), TransInvalidationInfo::RelcacheInitFileInval, SendSharedInvalidMessages(), and transInvalInfo.
Referenced by AbortTransaction(), CommitTransaction(), and PostPrepare_Inval().
void CacheInvalidateCatalog | ( | Oid | catalogId | ) |
Definition at line 1336 of file inval.c.
References InvalidOid, IsSharedRelation(), MyDatabaseId, PrepareInvalidationState(), and RegisterCatalogInvalidation().
Referenced by finish_heap_swap().
Definition at line 1204 of file inval.c.
References GETSTRUCT, InvalidOid, IsBootstrapProcessingMode, IsCatalogRelation(), IsSharedRelation(), IsToastRelation(), MyDatabaseId, OidIsValid, PrepareInvalidationState(), PrepareToInvalidateCacheTuple(), RegisterCatcacheInvalidation(), RegisterRelcacheInvalidation(), RegisterSnapshotInvalidation(), RelationGetRelid, and RelationInvalidatesSnapshotsOnly().
Referenced by AlterDomainAddConstraint(), AlterDomainDropConstraint(), heap_delete(), heap_inplace_update(), heap_insert(), heap_multi_insert(), and heap_update().
void CacheInvalidateRelcache | ( | Relation | relation | ) |
Definition at line 1360 of file inval.c.
References InvalidOid, MyDatabaseId, PrepareInvalidationState(), RelationData::rd_rel, RegisterRelcacheInvalidation(), and RelationGetRelid.
Referenced by AlterPolicy(), ATExecAlterConstrRecurse(), ATExecDetachPartition(), ATExecGenericOptions(), ATExecValidateConstraint(), CreatePolicy(), CreateStatistics(), DetachPartitionFinalize(), EnableDisableRule(), EnableDisableTrigger(), index_concurrently_set_dead(), index_constraint_create(), index_create(), index_drop(), reindex_index(), relation_mark_replica_identity(), RelationSetNewRelfilenumber(), RemovePolicyById(), RemoveRewriteRuleById(), RemoveTriggerById(), rename_constraint_internal(), rename_policy(), RenameRewriteRule(), renametrig_internal(), SetRelationNumChecks(), StorePartitionBound(), and StorePartitionKey().
void CacheInvalidateRelcacheAll | ( | void | ) |
Definition at line 1384 of file inval.c.
References InvalidOid, PrepareInvalidationState(), and RegisterRelcacheInvalidation().
Referenced by AlterPublicationOptions(), CreatePublication(), InvalidatePublicationRels(), and RemovePublicationById().
void CacheInvalidateRelcacheByRelid | ( | Oid | relid | ) |
Definition at line 1419 of file inval.c.
References CacheInvalidateRelcacheByTuple(), elog, ERROR, HeapTupleIsValid, ObjectIdGetDatum(), PrepareInvalidationState(), ReleaseSysCache(), and SearchSysCache1().
Referenced by ATExecAlterConstraint(), ATExecAttachPartition(), DefineIndex(), DetachPartitionFinalize(), heap_drop_with_catalog(), InvalidatePublicationRels(), ReindexRelationConcurrently(), RemoveStatisticsById(), and StorePartitionBound().
void CacheInvalidateRelcacheByTuple | ( | HeapTuple | classTuple | ) |
Definition at line 1396 of file inval.c.
References GETSTRUCT, InvalidOid, MyDatabaseId, PrepareInvalidationState(), and RegisterRelcacheInvalidation().
Referenced by CacheInvalidateRelcacheByRelid(), copy_table_data(), CreateTriggerFiringOn(), index_update_stats(), RemoveRoleFromObjectPolicy(), SetRelationHasSubclass(), SetRelationRuleStatus(), and swap_relation_files().
void CacheInvalidateRelmap | ( | Oid | databaseId | ) |
Definition at line 1489 of file inval.c.
References SharedInvalRelmapMsg::dbId, SharedInvalRelmapMsg::id, SharedInvalidationMessage::rm, SendSharedInvalidMessages(), SHAREDINVALRELMAP_ID, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by write_relmap_file().
void CacheInvalidateSmgr | ( | RelFileLocatorBackend | rlocator | ) |
Definition at line 1459 of file inval.c.
References RelFileLocatorBackend::backend, SharedInvalSmgrMsg::backend_hi, SharedInvalSmgrMsg::backend_lo, SharedInvalSmgrMsg::id, RelFileLocatorBackend::locator, SharedInvalSmgrMsg::rlocator, SendSharedInvalidMessages(), SHAREDINVALSMGR_ID, SharedInvalidationMessage::sm, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by smgrdounlinkall(), smgrtruncate(), and vm_extend().
void CacheRegisterRelcacheCallback | ( | RelcacheCallbackFunction | func, |
Datum | arg | ||
) |
Definition at line 1558 of file inval.c.
References RELCACHECALLBACK::arg, arg, elog, FATAL, RELCACHECALLBACK::function, MAX_RELCACHE_CALLBACKS, relcache_callback_count, and relcache_callback_list.
Referenced by init_rel_sync_cache(), InitializeRelfilenumberMap(), InitPlanCache(), logicalrep_partmap_init(), logicalrep_relmap_init(), and lookup_type_cache().
void CacheRegisterSyscacheCallback | ( | int | cacheid, |
SyscacheCallbackFunction | func, | ||
Datum | arg | ||
) |
Definition at line 1516 of file inval.c.
References SYSCACHECALLBACK::arg, arg, elog, FATAL, SYSCACHECALLBACK::function, i, SYSCACHECALLBACK::id, SYSCACHECALLBACK::link, MAX_SYSCACHE_CALLBACKS, syscache_callback_count, syscache_callback_links, and syscache_callback_list.
Referenced by BuildEventTriggerCache(), find_oper_cache_entry(), GetConnection(), init_rel_sync_cache(), init_ts_config_cache(), initialize_acl(), InitializeAttoptCache(), InitializeLogRepWorker(), InitializeSearchPath(), InitializeShippableCache(), InitializeTableSpaceCache(), InitPlanCache(), lookup_proof_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), ParallelApplyWorkerMain(), pgoutput_startup(), ri_InitHashTables(), SetupApplyOrSyncWorker(), and superuser_arg().
void CallSyscacheCallbacks | ( | int | cacheid, |
uint32 | hashvalue | ||
) |
Definition at line 1577 of file inval.c.
References SYSCACHECALLBACK::arg, Assert, elog, ERROR, SYSCACHECALLBACK::function, i, SYSCACHECALLBACK::id, SYSCACHECALLBACK::link, syscache_callback_links, and syscache_callback_list.
Referenced by CatalogCacheFlushCatalog(), and LocalExecuteInvalidationMessage().
void CommandEndInvalidationMessages | ( | void | ) |
Definition at line 1170 of file inval.c.
References AppendInvalidationMessages(), TransInvalidationInfo::CurrentCmdInvalidMsgs, LocalExecuteInvalidationMessage(), LogLogicalInvalidations(), TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), transInvalInfo, and XLogLogicalInfoActive.
Referenced by AtCCI_LocalCache(), and AtEOSubXact_Inval().
void InvalidateSystemCaches | ( | void | ) |
Definition at line 792 of file inval.c.
References InvalidateSystemCachesExtended().
Referenced by AcceptInvalidationMessages(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), ParallelWorkerMain(), and pg_logical_slot_get_changes_guts().
void InvalidateSystemCachesExtended | ( | bool | debug_discard | ) |
Definition at line 674 of file inval.c.
References SYSCACHECALLBACK::arg, RELCACHECALLBACK::arg, SYSCACHECALLBACK::function, RELCACHECALLBACK::function, i, SYSCACHECALLBACK::id, InvalidateCatalogSnapshot(), InvalidOid, RelationCacheInvalidate(), relcache_callback_count, relcache_callback_list, ResetCatalogCaches(), syscache_callback_count, and syscache_callback_list.
Referenced by AcceptInvalidationMessages(), and InvalidateSystemCaches().
void LocalExecuteInvalidationMessage | ( | SharedInvalidationMessage * | msg | ) |
Definition at line 705 of file inval.c.
References RELCACHECALLBACK::arg, RelFileLocatorBackend::backend, SharedInvalSmgrMsg::backend_hi, SharedInvalSmgrMsg::backend_lo, CallSyscacheCallbacks(), SharedInvalidationMessage::cat, CatalogCacheFlushCatalog(), SharedInvalCatalogMsg::catId, SharedInvalidationMessage::cc, SharedInvalCatcacheMsg::dbId, SharedInvalCatalogMsg::dbId, SharedInvalRelcacheMsg::dbId, SharedInvalRelmapMsg::dbId, SharedInvalSnapshotMsg::dbId, elog, FATAL, RELCACHECALLBACK::function, SharedInvalCatcacheMsg::hashValue, i, SharedInvalCatcacheMsg::id, SharedInvalidationMessage::id, InvalidateCatalogSnapshot(), InvalidOid, RelFileLocatorBackend::locator, MyDatabaseId, SharedInvalidationMessage::rc, RelationCacheInvalidate(), RelationCacheInvalidateEntry(), RelationMapInvalidate(), relcache_callback_count, relcache_callback_list, SharedInvalRelcacheMsg::relId, SharedInvalSmgrMsg::rlocator, SharedInvalidationMessage::rm, SHAREDINVALCATALOG_ID, SHAREDINVALRELCACHE_ID, SHAREDINVALRELMAP_ID, SHAREDINVALSMGR_ID, SHAREDINVALSNAPSHOT_ID, SharedInvalidationMessage::sm, smgrreleaserellocator(), SharedInvalidationMessage::sn, and SysCacheInvalidate().
Referenced by AcceptInvalidationMessages(), AtEOSubXact_Inval(), AtEOXact_Inval(), CommandEndInvalidationMessages(), ReorderBufferExecuteInvalidations(), and ReorderBufferImmediateInvalidation().
void LogLogicalInvalidations | ( | void | ) |
Definition at line 1604 of file inval.c.
References CatCacheMsgs, TransInvalidationInfo::CurrentCmdInvalidMsgs, MinSizeOfXactInvals, xl_xact_invals::nmsgs, NumMessagesInGroup, ProcessMessageSubGroupMulti, RelCacheMsgs, transInvalInfo, XLOG_XACT_INVALIDATIONS, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by CommandEndInvalidationMessages(), and RecordTransactionCommit().
void PostPrepare_Inval | ( | void | ) |
Definition at line 863 of file inval.c.
References AtEOXact_Inval().
Referenced by PrepareTransaction().
|
static |
Definition at line 611 of file inval.c.
References Assert, CatCacheMsgs, TransInvalidationInfo::CurrentCmdInvalidMsgs, elog, ERROR, GetCurrentTransactionNestLevel(), InvalMessageArrays, InvalMessageArray::maxmsgs, MemoryContextAllocZero(), InvalMessageArray::msgs, TransInvalidationInfo::my_level, NumMessagesInGroup, TransInvalidationInfo::parent, TransInvalidationInfo::PriorCmdInvalidMsgs, RelCacheMsgs, SetGroupToFollow, TopTransactionContext, and transInvalInfo.
Referenced by CacheInvalidateCatalog(), CacheInvalidateHeapTuple(), CacheInvalidateRelcache(), CacheInvalidateRelcacheAll(), CacheInvalidateRelcacheByRelid(), and CacheInvalidateRelcacheByTuple().
void ProcessCommittedInvalidationMessages | ( | SharedInvalidationMessage * | msgs, |
int | nmsgs, | ||
bool | RelcacheInitFileInval, | ||
Oid | dbid, | ||
Oid | tsid | ||
) |
Definition at line 961 of file inval.c.
References DatabasePath, DEBUG4, elog, GetDatabasePath(), OidIsValid, pfree(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), and SendSharedInvalidMessages().
Referenced by standby_redo(), and xact_redo_commit().
|
static |
Definition at line 514 of file inval.c.
References CatCacheMsgs, ProcessMessageSubGroup, and RelCacheMsgs.
Referenced by AtEOSubXact_Inval(), AtEOXact_Inval(), and CommandEndInvalidationMessages().
|
static |
Definition at line 526 of file inval.c.
References CatCacheMsgs, ProcessMessageSubGroupMulti, and RelCacheMsgs.
Referenced by AtEOXact_Inval().
Definition at line 558 of file inval.c.
References AddCatalogInvalidationMessage(), TransInvalidationInfo::CurrentCmdInvalidMsgs, and transInvalInfo.
Referenced by CacheInvalidateCatalog().
Definition at line 544 of file inval.c.
References AddCatcacheInvalidationMessage(), TransInvalidationInfo::CurrentCmdInvalidMsgs, and transInvalInfo.
Referenced by CacheInvalidateHeapTuple().
Definition at line 570 of file inval.c.
References AddRelcacheInvalidationMessage(), TransInvalidationInfo::CurrentCmdInvalidMsgs, GetCurrentCommandId(), InvalidOid, RelationIdIsInInitFile(), TransInvalidationInfo::RelcacheInitFileInval, and transInvalInfo.
Referenced by CacheInvalidateHeapTuple(), CacheInvalidateRelcache(), CacheInvalidateRelcacheAll(), and CacheInvalidateRelcacheByTuple().
Definition at line 600 of file inval.c.
References AddSnapshotInvalidationMessage(), TransInvalidationInfo::CurrentCmdInvalidMsgs, and transInvalInfo.
Referenced by CacheInvalidateHeapTuple().
int xactGetCommittedInvalidationMessages | ( | SharedInvalidationMessage ** | msgs, |
bool * | RelcacheInitFileInval | ||
) |
Definition at line 882 of file inval.c.
References Assert, CatCacheMsgs, TransInvalidationInfo::CurrentCmdInvalidMsgs, CurTransactionContext, MemoryContextAlloc(), TransInvalidationInfo::my_level, NumMessagesInGroup, TransInvalidationInfo::parent, TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessMessageSubGroupMulti, TransInvalidationInfo::RelcacheInitFileInval, RelCacheMsgs, and transInvalInfo.
Referenced by RecordTransactionCommit(), and StartPrepare().
int debug_discard_caches = 0 |
Definition at line 240 of file inval.c.
Referenced by AcceptInvalidationMessages(), LookupOpclassInfo(), and RelationBuildDesc().
|
static |
Definition at line 171 of file inval.c.
Referenced by AddInvalidationMessage(), and PrepareInvalidationState().
|
static |
Definition at line 273 of file inval.c.
Referenced by CacheRegisterRelcacheCallback(), InvalidateSystemCachesExtended(), and LocalExecuteInvalidationMessage().
|
static |
|
static |
Definition at line 265 of file inval.c.
Referenced by CacheRegisterSyscacheCallback(), and InvalidateSystemCachesExtended().
|
static |
Definition at line 263 of file inval.c.
Referenced by CacheRegisterSyscacheCallback(), and CallSyscacheCallbacks().
|
static |
Referenced by CacheRegisterSyscacheCallback(), CallSyscacheCallbacks(), and InvalidateSystemCachesExtended().
|
static |
Definition at line 237 of file inval.c.
Referenced by AtEOSubXact_Inval(), AtEOXact_Inval(), CommandEndInvalidationMessages(), LogLogicalInvalidations(), PrepareInvalidationState(), RegisterCatalogInvalidation(), RegisterCatcacheInvalidation(), RegisterRelcacheInvalidation(), RegisterSnapshotInvalidation(), and xactGetCommittedInvalidationMessages().