PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/htup_details.h"
#include "access/xact.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/guc.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 | InvalidationChunk |
struct | InvalidationListHeader |
struct | TransInvalidationInfo |
struct | SYSCACHECALLBACK |
struct | RELCACHECALLBACK |
Macros | |
#define | MAX_SYSCACHE_CALLBACKS 64 |
#define | MAX_RELCACHE_CALLBACKS 10 |
#define | FIRSTCHUNKSIZE 32 |
#define | ProcessMessageList(listHdr, codeFragment) |
#define | ProcessMessageListMulti(listHdr, codeFragment) |
Typedefs | |
typedef struct InvalidationChunk | InvalidationChunk |
typedef struct InvalidationListHeader | InvalidationListHeader |
typedef struct TransInvalidationInfo | TransInvalidationInfo |
Variables | |
static TransInvalidationInfo * | transInvalInfo = NULL |
static SharedInvalidationMessage * | SharedInvalidMessagesArray |
static int | numSharedInvalidMessagesArray |
static int | maxSharedInvalidMessagesArray |
int | debug_invalidate_system_caches_always = 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 FIRSTCHUNKSIZE 32 |
Referenced by AddInvalidationMessage(), and MakeSharedInvalidMessagesArray().
#define MAX_RELCACHE_CALLBACKS 10 |
Definition at line 197 of file inval.c.
Referenced by CacheRegisterRelcacheCallback().
#define MAX_SYSCACHE_CALLBACKS 64 |
Definition at line 196 of file inval.c.
Referenced by CacheRegisterSyscacheCallback().
#define ProcessMessageList | ( | listHdr, | |
codeFragment | |||
) |
Definition at line 301 of file inval.c.
Referenced by AddRelcacheInvalidationMessage(), AddSnapshotInvalidationMessage(), and ProcessInvalidationMessages().
#define ProcessMessageListMulti | ( | listHdr, | |
codeFragment | |||
) |
Definition at line 321 of file inval.c.
Referenced by ProcessInvalidationMessagesMulti().
typedef struct InvalidationChunk InvalidationChunk |
typedef struct InvalidationListHeader InvalidationListHeader |
typedef struct TransInvalidationInfo TransInvalidationInfo |
void AcceptInvalidationMessages | ( | void | ) |
Definition at line 687 of file inval.c.
References debug_invalidate_system_caches_always, InvalidateSystemCaches(), LocalExecuteInvalidationMessage(), ReceiveSharedInvalidMessages(), and recursion_depth.
Referenced by apply_handle_commit_internal(), AtStart_Cache(), ConditionalLockRelation(), ConditionalLockRelationOid(), delay_execution_planner(), InitializeSessionUserId(), LockDatabaseObject(), LockRelation(), LockRelationOid(), LockSharedObject(), LogicalRepApplyLoop(), ProcessCatchupInterrupt(), RangeVarGetRelidExtended(), relation_openrv(), relation_openrv_extended(), RemoveRelations(), and write_relcache_init_file().
|
static |
Definition at line 373 of file inval.c.
References AddInvalidationMessage(), SharedInvalidationMessage::cat, SharedInvalCatalogMsg::catId, InvalidationListHeader::cclist, SharedInvalCatalogMsg::dbId, SharedInvalCatalogMsg::id, SHAREDINVALCATALOG_ID, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterCatalogInvalidation().
|
static |
Definition at line 345 of file inval.c.
References AddInvalidationMessage(), Assert, SharedInvalidationMessage::cc, InvalidationListHeader::cclist, SharedInvalCatcacheMsg::dbId, SharedInvalCatcacheMsg::hashValue, SharedInvalCatcacheMsg::id, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterCatcacheInvalidation().
|
static |
Definition at line 235 of file inval.c.
References CurTransactionContext, FIRSTCHUNKSIZE, InvalidationChunk::maxitems, MemoryContextAlloc(), InvalidationChunk::msgs, InvalidationChunk::next, InvalidationChunk::nitems, and offsetof.
Referenced by AddCatalogInvalidationMessage(), AddCatcacheInvalidationMessage(), AddRelcacheInvalidationMessage(), and AddSnapshotInvalidationMessage().
|
static |
Definition at line 391 of file inval.c.
References AddInvalidationMessage(), SharedInvalRelcacheMsg::dbId, SharedInvalRelcacheMsg::id, InvalidOid, ProcessMessageList, SharedInvalidationMessage::rc, InvalidationListHeader::rclist, SharedInvalRelcacheMsg::relId, SHAREDINVALRELCACHE_ID, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterRelcacheInvalidation().
|
static |
Definition at line 421 of file inval.c.
References AddInvalidationMessage(), SharedInvalSnapshotMsg::dbId, SharedInvalSnapshotMsg::id, ProcessMessageList, InvalidationListHeader::rclist, SharedInvalSnapshotMsg::relId, SHAREDINVALSNAPSHOT_ID, SharedInvalidationMessage::sn, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by RegisterSnapshotInvalidation().
|
static |
Definition at line 277 of file inval.c.
References InvalidationChunk::next.
Referenced by AppendInvalidationMessages().
|
static |
Definition at line 448 of file inval.c.
References AppendInvalidationMessageList(), InvalidationListHeader::cclist, and InvalidationListHeader::rclist.
Referenced by AtEOSubXact_Inval(), AtEOXact_Inval(), and CommandEndInvalidationMessages().
void AtEOSubXact_Inval | ( | bool | isCommit | ) |
Definition at line 1011 of file inval.c.
References AppendInvalidationMessages(), Assert, CommandEndInvalidationMessages(), GetCurrentTransactionNestLevel(), LocalExecuteInvalidationMessage(), TransInvalidationInfo::my_level, TransInvalidationInfo::parent, pfree(), TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), TransInvalidationInfo::RelcacheInitFileInval, and transInvalInfo.
Referenced by AbortSubTransaction(), and CommitSubTransaction().
void AtEOXact_Inval | ( | bool | isCommit | ) |
Definition at line 952 of file inval.c.
References AppendInvalidationMessages(), Assert, TransInvalidationInfo::CurrentCmdInvalidMsgs, LocalExecuteInvalidationMessage(), TransInvalidationInfo::my_level, numSharedInvalidMessagesArray, TransInvalidationInfo::parent, TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), ProcessInvalidationMessagesMulti(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), TransInvalidationInfo::RelcacheInitFileInval, and SendSharedInvalidMessages().
Referenced by AbortTransaction(), CommitTransaction(), and PostPrepare_Inval().
void CacheInvalidateCatalog | ( | Oid | catalogId | ) |
Definition at line 1254 of file inval.c.
References InvalidOid, IsSharedRelation(), MyDatabaseId, PrepareInvalidationState(), and RegisterCatalogInvalidation().
Referenced by finish_heap_swap().
Definition at line 1122 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 1278 of file inval.c.
References InvalidOid, MyDatabaseId, PrepareInvalidationState(), RelationData::rd_rel, RegisterRelcacheInvalidation(), and RelationGetRelid.
Referenced by AlterPolicy(), ATExecAlterCollationRefreshVersion(), ATExecAlterConstraint(), ATExecDetachPartition(), ATExecGenericOptions(), ATExecValidateConstraint(), CreatePolicy(), CreateStatistics(), EnableDisableRule(), EnableDisableTrigger(), index_concurrently_set_dead(), index_create(), index_drop(), publication_add_relation(), reindex_index(), RelationSetNewRelfilenode(), RemovePolicyById(), RemoveRewriteRuleById(), RemoveRoleFromObjectPolicy(), RemoveTriggerById(), rename_constraint_internal(), rename_policy(), RenameRewriteRule(), renametrig(), SetRelationNumChecks(), StorePartitionBound(), and StorePartitionKey().
void CacheInvalidateRelcacheAll | ( | void | ) |
Definition at line 1302 of file inval.c.
References InvalidOid, PrepareInvalidationState(), and RegisterRelcacheInvalidation().
Referenced by AlterPublicationOptions().
void CacheInvalidateRelcacheByRelid | ( | Oid | relid | ) |
Definition at line 1337 of file inval.c.
References CacheInvalidateRelcacheByTuple(), elog, ERROR, HeapTupleIsValid, ObjectIdGetDatum, PrepareInvalidationState(), ReleaseSysCache(), RELOID, and SearchSysCache1().
Referenced by AlterPublicationOptions(), ATExecAlterConstraint(), ATExecDetachPartition(), DefineIndex(), heap_drop_with_catalog(), ReindexRelationConcurrently(), RemovePublicationRelById(), RemoveStatisticsById(), and StorePartitionBound().
void CacheInvalidateRelcacheByTuple | ( | HeapTuple | classTuple | ) |
Definition at line 1314 of file inval.c.
References GETSTRUCT, InvalidOid, MyDatabaseId, PrepareInvalidationState(), and RegisterRelcacheInvalidation().
Referenced by CacheInvalidateRelcacheByRelid(), copy_table_data(), CreateTrigger(), index_update_stats(), SetRelationHasSubclass(), SetRelationRuleStatus(), and swap_relation_files().
void CacheInvalidateRelmap | ( | Oid | databaseId | ) |
Definition at line 1407 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 | ( | RelFileNodeBackend | rnode | ) |
Definition at line 1377 of file inval.c.
References RelFileNodeBackend::backend, SharedInvalSmgrMsg::backend_hi, SharedInvalSmgrMsg::backend_lo, SharedInvalSmgrMsg::id, RelFileNodeBackend::node, SharedInvalSmgrMsg::rnode, 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 1476 of file inval.c.
References arg, RELCACHECALLBACK::arg, elog, FATAL, RELCACHECALLBACK::function, MAX_RELCACHE_CALLBACKS, relcache_callback_count, and relcache_callback_list.
Referenced by init_rel_sync_cache(), InitializeRelfilenodeMap(), InitPlanCache(), logicalrep_partmap_init(), logicalrep_relmap_init(), and lookup_type_cache().
void CacheRegisterSyscacheCallback | ( | int | cacheid, |
SyscacheCallbackFunction | func, | ||
Datum | arg | ||
) |
Definition at line 1434 of file inval.c.
References arg, SYSCACHECALLBACK::arg, elog, FATAL, SYSCACHECALLBACK::function, i, SYSCACHECALLBACK::id, SYSCACHECALLBACK::link, MAX_SYSCACHE_CALLBACKS, syscache_callback_count, syscache_callback_links, syscache_callback_list, and SysCacheSize.
Referenced by ApplyWorkerMain(), BuildEventTriggerCache(), find_oper_cache_entry(), GetConnection(), init_rel_sync_cache(), init_ts_config_cache(), initialize_acl(), InitializeAttoptCache(), InitializeSearchPath(), InitializeShippableCache(), InitializeTableSpaceCache(), InitPlanCache(), lookup_proof_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), pgoutput_startup(), ri_InitHashTables(), and superuser_arg().
void CallSyscacheCallbacks | ( | int | cacheid, |
uint32 | hashvalue | ||
) |
Definition at line 1495 of file inval.c.
References SYSCACHECALLBACK::arg, Assert, elog, ERROR, SYSCACHECALLBACK::function, i, SYSCACHECALLBACK::id, SYSCACHECALLBACK::link, syscache_callback_links, syscache_callback_list, and SysCacheSize.
Referenced by CatalogCacheFlushCatalog(), and LocalExecuteInvalidationMessage().
void CommandEndInvalidationMessages | ( | void | ) |
Definition at line 1088 of file inval.c.
References AppendInvalidationMessages(), TransInvalidationInfo::CurrentCmdInvalidMsgs, LocalExecuteInvalidationMessage(), LogLogicalInvalidations(), TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), and XLogLogicalInfoActive.
Referenced by AtCCI_LocalCache(), and AtEOSubXact_Inval().
void InvalidateSystemCaches | ( | void | ) |
Definition at line 649 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(), ParallelWorkerMain(), pg_logical_replication_slot_advance(), and pg_logical_slot_get_changes_guts().
void LocalExecuteInvalidationMessage | ( | SharedInvalidationMessage * | msg | ) |
Definition at line 562 of file inval.c.
References RELCACHECALLBACK::arg, RelFileNodeBackend::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, MyDatabaseId, RelFileNodeBackend::node, SharedInvalidationMessage::rc, RelationCacheInvalidate(), RelationCacheInvalidateEntry(), RelationMapInvalidate(), relcache_callback_count, relcache_callback_list, SharedInvalRelcacheMsg::relId, SharedInvalidationMessage::rm, SharedInvalSmgrMsg::rnode, SHAREDINVALCATALOG_ID, SHAREDINVALRELCACHE_ID, SHAREDINVALRELMAP_ID, SHAREDINVALSMGR_ID, SHAREDINVALSNAPSHOT_ID, SharedInvalidationMessage::sm, smgrclosenode(), SharedInvalidationMessage::sn, and SysCacheInvalidate().
Referenced by AcceptInvalidationMessages(), AtEOSubXact_Inval(), AtEOXact_Inval(), CommandEndInvalidationMessages(), ReorderBufferExecuteInvalidations(), and ReorderBufferImmediateInvalidation().
void LogLogicalInvalidations | ( | void | ) |
Definition at line 1521 of file inval.c.
References Assert, TransInvalidationInfo::CurrentCmdInvalidMsgs, MakeSharedInvalidMessagesArray(), MinSizeOfXactInvals, xl_xact_invals::nmsgs, numSharedInvalidMessagesArray, pfree(), ProcessInvalidationMessagesMulti(), SharedInvalidMessagesArray, XLOG_XACT_INVALIDATIONS, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by CommandEndInvalidationMessages(), and RecordTransactionCommit().
|
static |
Definition at line 781 of file inval.c.
References FIRSTCHUNKSIZE, maxSharedInvalidMessagesArray, numSharedInvalidMessagesArray, palloc(), and repalloc().
Referenced by LogLogicalInvalidations(), and xactGetCommittedInvalidationMessages().
void PostPrepare_Inval | ( | void | ) |
Definition at line 772 of file inval.c.
References AtEOXact_Inval().
Referenced by PrepareTransaction().
|
static |
Definition at line 735 of file inval.c.
References Assert, GetCurrentTransactionNestLevel(), MemoryContextAllocZero(), TransInvalidationInfo::my_level, TransInvalidationInfo::parent, 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 887 of file inval.c.
References DatabasePath, DEBUG4, elog, GetDatabasePath(), OidIsValid, pfree(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), SendSharedInvalidMessages(), and trace_recovery().
Referenced by standby_redo(), and xact_redo_commit().
|
static |
Definition at line 462 of file inval.c.
References InvalidationListHeader::cclist, ProcessMessageList, and InvalidationListHeader::rclist.
Referenced by AtEOSubXact_Inval(), AtEOXact_Inval(), and CommandEndInvalidationMessages().
|
static |
Definition at line 474 of file inval.c.
References InvalidationListHeader::cclist, ProcessMessageListMulti, and InvalidationListHeader::rclist.
Referenced by AtEOXact_Inval(), LogLogicalInvalidations(), and xactGetCommittedInvalidationMessages().
Definition at line 506 of file inval.c.
References AddCatalogInvalidationMessage(), and TransInvalidationInfo::CurrentCmdInvalidMsgs.
Referenced by CacheInvalidateCatalog().
Definition at line 492 of file inval.c.
References AddCatcacheInvalidationMessage(), and TransInvalidationInfo::CurrentCmdInvalidMsgs.
Referenced by CacheInvalidateHeapTuple().
Definition at line 518 of file inval.c.
References AddRelcacheInvalidationMessage(), TransInvalidationInfo::CurrentCmdInvalidMsgs, GetCurrentCommandId(), InvalidOid, RelationIdIsInInitFile(), and TransInvalidationInfo::RelcacheInitFileInval.
Referenced by CacheInvalidateHeapTuple(), CacheInvalidateRelcache(), CacheInvalidateRelcacheAll(), and CacheInvalidateRelcacheByTuple().
Definition at line 548 of file inval.c.
References AddSnapshotInvalidationMessage(), and TransInvalidationInfo::CurrentCmdInvalidMsgs.
Referenced by CacheInvalidateHeapTuple().
int xactGetCommittedInvalidationMessages | ( | SharedInvalidationMessage ** | msgs, |
bool * | RelcacheInitFileInval | ||
) |
Definition at line 831 of file inval.c.
References Assert, TransInvalidationInfo::CurrentCmdInvalidMsgs, CurTransactionContext, MakeSharedInvalidMessagesArray(), MemoryContextSwitchTo(), TransInvalidationInfo::my_level, numSharedInvalidMessagesArray, TransInvalidationInfo::parent, TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessagesMulti(), TransInvalidationInfo::RelcacheInitFileInval, and SharedInvalidMessagesArray.
Referenced by RecordTransactionCommit(), and StartPrepare().
int debug_invalidate_system_caches_always = 0 |
Definition at line 184 of file inval.c.
Referenced by AcceptInvalidationMessages(), LookupOpclassInfo(), and RelationBuildDesc().
|
static |
Definition at line 181 of file inval.c.
Referenced by MakeSharedInvalidMessagesArray().
|
static |
Definition at line 180 of file inval.c.
Referenced by AtEOXact_Inval(), LogLogicalInvalidations(), MakeSharedInvalidMessagesArray(), and xactGetCommittedInvalidationMessages().
|
static |
Definition at line 217 of file inval.c.
Referenced by CacheRegisterRelcacheCallback(), InvalidateSystemCaches(), and LocalExecuteInvalidationMessage().
|
static |
Referenced by CacheRegisterRelcacheCallback(), InvalidateSystemCaches(), and LocalExecuteInvalidationMessage().
|
static |
Definition at line 179 of file inval.c.
Referenced by LogLogicalInvalidations(), and xactGetCommittedInvalidationMessages().
|
static |
Definition at line 209 of file inval.c.
Referenced by CacheRegisterSyscacheCallback(), and InvalidateSystemCaches().
|
static |
Definition at line 207 of file inval.c.
Referenced by CacheRegisterSyscacheCallback(), and CallSyscacheCallbacks().
|
static |
Referenced by CacheRegisterSyscacheCallback(), CallSyscacheCallbacks(), and InvalidateSystemCaches().
|
static |
Definition at line 177 of file inval.c.
Referenced by AtEOSubXact_Inval(), and PrepareInvalidationState().