169 #define CatCacheMsgs 0
170 #define RelCacheMsgs 1
189 #define SetSubGroupToFollow(targetgroup, priorgroup, subgroup) \
191 (targetgroup)->firstmsg[subgroup] = \
192 (targetgroup)->nextmsg[subgroup] = \
193 (priorgroup)->nextmsg[subgroup]; \
196 #define SetGroupToFollow(targetgroup, priorgroup) \
198 SetSubGroupToFollow(targetgroup, priorgroup, CatCacheMsgs); \
199 SetSubGroupToFollow(targetgroup, priorgroup, RelCacheMsgs); \
202 #define NumMessagesInSubGroup(group, subgroup) \
203 ((group)->nextmsg[subgroup] - (group)->firstmsg[subgroup])
205 #define NumMessagesInGroup(group) \
206 (NumMessagesInSubGroup(group, CatCacheMsgs) + \
207 NumMessagesInSubGroup(group, RelCacheMsgs))
270 #define MAX_SYSCACHE_CALLBACKS 64
271 #define MAX_RELCACHE_CALLBACKS 10
312 int nextindex = group->
nextmsg[subgroup];
316 if (ima->
msgs == NULL)
330 int reqsize = 2 * ima->
maxmsgs;
339 ima->
msgs[nextindex] = *msg;
372 #define ProcessMessageSubGroup(group, subgroup, codeFragment) \
374 int _msgindex = (group)->firstmsg[subgroup]; \
375 int _endmsg = (group)->nextmsg[subgroup]; \
376 for (; _msgindex < _endmsg; _msgindex++) \
378 SharedInvalidationMessage *msg = \
379 &InvalMessageArrays[subgroup].msgs[_msgindex]; \
390 #define ProcessMessageSubGroupMulti(group, subgroup, codeFragment) \
392 int n = NumMessagesInSubGroup(group, subgroup); \
394 SharedInvalidationMessage *msgs = \
395 &InvalMessageArrays[subgroup].msgs[(group)->firstmsg[subgroup]]; \
570 cacheId, hashValue, dbId);
663 elog(
ERROR,
"cannot start a subtransaction when there are unprocessed inval messages");
834 elog(
FATAL,
"unrecognized SI message ID: %d", msg->
id);
893 #ifdef DISCARD_CACHES_ENABLED
940 bool *RelcacheInitFileInval)
949 *RelcacheInitFileInval =
false;
982 (memcpy(msgarray + nmsgs,
988 (memcpy(msgarray + nmsgs,
994 (memcpy(msgarray + nmsgs,
1000 (memcpy(msgarray + nmsgs,
1004 Assert(nmsgs == nummsgs);
1016 bool *RelcacheInitFileInval)
1025 *RelcacheInitFileInval =
false;
1038 (memcpy(msgarray + nmsgs,
1044 (memcpy(msgarray + nmsgs,
1048 Assert(nmsgs == nummsgs);
1063 int nmsgs,
bool RelcacheInitFileInval,
1069 elog(
DEBUG4,
"replaying commit with %d messages%s", nmsgs,
1070 (RelcacheInitFileInval ?
" and relcache file invalidation" :
""));
1072 if (RelcacheInitFileInval)
1074 elog(
DEBUG4,
"removing relcache init files for database %u", dbid);
1097 if (RelcacheInitFileInval)
1391 info = prepare_callback();
1414 if (tupleRelId == RelationRelationId)
1418 relationId = classtup->oid;
1419 if (classtup->relisshared)
1424 else if (tupleRelId == AttributeRelationId)
1428 relationId = atttup->attrelid;
1442 else if (tupleRelId == IndexRelationId)
1452 relationId = indextup->indexrelid;
1455 else if (tupleRelId == ConstraintRelationId)
1463 if (constrtup->contype == CONSTRAINT_FOREIGN &&
1466 relationId = constrtup->conrelid;
1540 databaseId, catalogId);
1559 if (relation->
rd_rel->relisshared)
1565 databaseId, relationId);
1593 relationId = classtup->oid;
1594 if (classtup->relisshared)
1599 databaseId, relationId);
1615 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1682 msg.
rm.
dbId = databaseId;
1708 if (cacheid < 0 || cacheid >= SysCacheSize)
1709 elog(
FATAL,
"invalid cache ID: %d", cacheid);
1711 elog(
FATAL,
"out of syscache_callback_list slots");
1750 elog(
FATAL,
"out of relcache_callback_list slots");
1769 if (cacheid < 0 || cacheid >= SysCacheSize)
1770 elog(
ERROR,
"invalid cache ID: %d", cacheid);
1778 ccitem->
function(ccitem->
arg, cacheid, hashvalue);
1779 i = ccitem->
link - 1;
1809 xlrec.
nmsgs = nmsgs;
#define Assert(condition)
#define OidIsValid(objectId)
bool IsToastRelation(Relation relation)
bool IsCatalogRelation(Relation relation)
bool IsSharedRelation(Oid relationId)
void ResetCatalogCaches(void)
void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple, void(*function)(int, uint32, Oid, void *), void *context)
void CatalogCacheFlushCatalog(Oid catId)
static int recursion_depth
volatile uint32 CritSectionCount
#define HeapTupleIsValid(tuple)
static InvalidationInfo * PrepareInvalidationState(void)
void PostPrepare_Inval(void)
void InvalidateSystemCachesExtended(bool debug_discard)
static void AddCatcacheInvalidationMessage(InvalidationMsgsGroup *group, int id, uint32 hashValue, Oid dbId)
static void AddCatalogInvalidationMessage(InvalidationMsgsGroup *group, Oid dbId, Oid catId)
static void RegisterRelcacheInvalidation(InvalidationInfo *info, Oid dbId, Oid relId)
static int relcache_callback_count
#define NumMessagesInGroup(group)
static void AddRelcacheInvalidationMessage(InvalidationMsgsGroup *group, Oid dbId, Oid relId)
void LogLogicalInvalidations(void)
void CacheInvalidateHeapTupleInplace(Relation relation, HeapTuple tuple, HeapTuple newtuple)
void AcceptInvalidationMessages(void)
static void ProcessInvalidationMessages(InvalidationMsgsGroup *group, void(*func)(SharedInvalidationMessage *msg))
void CacheInvalidateRelmap(Oid databaseId)
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
struct TransInvalidationInfo TransInvalidationInfo
static void RegisterCatcacheInvalidation(int cacheId, uint32 hashValue, Oid dbId, void *context)
void CacheInvalidateCatalog(Oid catalogId)
#define ProcessMessageSubGroupMulti(group, subgroup, codeFragment)
static InvalidationInfo * inplaceInvalInfo
static void AppendInvalidationMessageSubGroup(InvalidationMsgsGroup *dest, InvalidationMsgsGroup *src, int subgroup)
static void RegisterSnapshotInvalidation(InvalidationInfo *info, Oid dbId, Oid relId)
struct InvalidationInfo InvalidationInfo
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
static struct RELCACHECALLBACK relcache_callback_list[MAX_RELCACHE_CALLBACKS]
static TransInvalidationInfo * transInvalInfo
void CallSyscacheCallbacks(int cacheid, uint32 hashvalue)
int xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs, bool *RelcacheInitFileInval)
#define ProcessMessageSubGroup(group, subgroup, codeFragment)
void CacheInvalidateRelcache(Relation relation)
static void AppendInvalidationMessages(InvalidationMsgsGroup *dest, InvalidationMsgsGroup *src)
static void ProcessInvalidationMessagesMulti(InvalidationMsgsGroup *group, void(*func)(const SharedInvalidationMessage *msgs, int n))
int inplaceGetInvalidationMessages(SharedInvalidationMessage **msgs, bool *RelcacheInitFileInval)
void CacheInvalidateRelcacheByRelid(Oid relid)
void InvalidateSystemCaches(void)
void AtEOXact_Inval(bool isCommit)
#define MAX_SYSCACHE_CALLBACKS
void CacheInvalidateSmgr(RelFileLocatorBackend rlocator)
#define SetGroupToFollow(targetgroup, priorgroup)
void AtEOSubXact_Inval(bool isCommit)
static void AddSnapshotInvalidationMessage(InvalidationMsgsGroup *group, Oid dbId, Oid relId)
static int16 syscache_callback_links[SysCacheSize]
static void AddInvalidationMessage(InvalidationMsgsGroup *group, int subgroup, const SharedInvalidationMessage *msg)
void PreInplace_Inval(void)
struct InvalMessageArray InvalMessageArray
void CommandEndInvalidationMessages(void)
void AtInplace_Inval(void)
static void RegisterCatalogInvalidation(InvalidationInfo *info, Oid dbId, Oid catId)
#define MAX_RELCACHE_CALLBACKS
void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func, Datum arg)
void ForgetInplace_Inval(void)
static InvalidationInfo * PrepareInplaceInvalidationState(void)
#define SetSubGroupToFollow(targetgroup, priorgroup, subgroup)
struct InvalidationMsgsGroup InvalidationMsgsGroup
void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple)
static void CacheInvalidateHeapTupleCommon(Relation relation, HeapTuple tuple, HeapTuple newtuple, InvalidationInfo *(*prepare_callback)(void))
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
static InvalMessageArray InvalMessageArrays[2]
static int syscache_callback_count
void ProcessCommittedInvalidationMessages(SharedInvalidationMessage *msgs, int nmsgs, bool RelcacheInitFileInval, Oid dbid, Oid tsid)
void CacheInvalidateRelcacheAll(void)
void CacheRegisterSyscacheCallback(int cacheid, SyscacheCallbackFunction func, Datum arg)
void(* SyscacheCallbackFunction)(Datum arg, int cacheid, uint32 hashvalue)
void(* RelcacheCallbackFunction)(Datum arg, Oid relid)
MemoryContext TopTransactionContext
void pfree(void *pointer)
void * palloc0(Size size)
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext CurTransactionContext
void * repalloc(void *pointer, Size size)
void * MemoryContextAlloc(MemoryContext context, Size size)
#define VALGRIND_MAKE_MEM_DEFINED(addr, size)
#define IsBootstrapProcessingMode()
FormData_pg_attribute * Form_pg_attribute
FormData_pg_class * Form_pg_class
FormData_pg_constraint * Form_pg_constraint
FormData_pg_index * Form_pg_index
static Datum ObjectIdGetDatum(Oid X)
#define RelationGetRelid(relation)
void RelationCacheInvalidate(bool debug_discard)
void RelationCacheInitFilePostInvalidate(void)
void RelationCacheInitFilePreInvalidate(void)
bool RelationIdIsInInitFile(Oid relationId)
void RelationCacheInvalidateEntry(Oid relationId)
void RelationMapInvalidate(bool shared)
char * GetDatabasePath(Oid dbOid, Oid spcOid)
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
void ReceiveSharedInvalidMessages(void(*invalFunction)(SharedInvalidationMessage *msg), void(*resetFunction)(void))
#define SHAREDINVALCATALOG_ID
#define SHAREDINVALSMGR_ID
#define SHAREDINVALSNAPSHOT_ID
#define SHAREDINVALRELCACHE_ID
#define SHAREDINVALRELMAP_ID
void smgrreleaserellocator(RelFileLocatorBackend rlocator)
void InvalidateCatalogSnapshot(void)
SharedInvalidationMessage * msgs
bool RelcacheInitFileInval
InvalidationMsgsGroup CurrentCmdInvalidMsgs
RelcacheCallbackFunction function
SyscacheCallbackFunction function
struct TransInvalidationInfo * parent
struct InvalidationInfo ii
InvalidationMsgsGroup PriorCmdInvalidMsgs
void SysCacheInvalidate(int cacheId, uint32 hashValue)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
bool RelationInvalidatesSnapshotsOnly(Oid relid)
SharedInvalCatcacheMsg cc
SharedInvalRelcacheMsg rc
SharedInvalCatalogMsg cat
SharedInvalSnapshotMsg sn
int GetCurrentTransactionNestLevel(void)
bool IsTransactionState(void)
CommandId GetCurrentCommandId(bool used)
#define MinSizeOfXactInvals
#define XLOG_XACT_INVALIDATIONS
#define XLogLogicalInfoActive()
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const char *data, uint32 len)
void XLogBeginInsert(void)