PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
inval.h File Reference
#include "access/htup.h"
#include "storage/relfilenode.h"
#include "utils/relcache.h"
Include dependency graph for inval.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* SyscacheCallbackFunction )(Datum arg, int cacheid, uint32 hashvalue)
 
typedef void(* RelcacheCallbackFunction )(Datum arg, Oid relid)
 

Functions

void AcceptInvalidationMessages (void)
 
void AtEOXact_Inval (bool isCommit)
 
void AtEOSubXact_Inval (bool isCommit)
 
void AtPrepare_Inval (void)
 
void PostPrepare_Inval (void)
 
void CommandEndInvalidationMessages (void)
 
void CacheInvalidateHeapTuple (Relation relation, HeapTuple tuple, HeapTuple newtuple)
 
void CacheInvalidateCatalog (Oid catalogId)
 
void CacheInvalidateRelcache (Relation relation)
 
void CacheInvalidateRelcacheAll (void)
 
void CacheInvalidateRelcacheByTuple (HeapTuple classTuple)
 
void CacheInvalidateRelcacheByRelid (Oid relid)
 
void CacheInvalidateSmgr (RelFileNodeBackend rnode)
 
void CacheInvalidateRelmap (Oid databaseId)
 
void CacheRegisterSyscacheCallback (int cacheid, SyscacheCallbackFunction func, Datum arg)
 
void CacheRegisterRelcacheCallback (RelcacheCallbackFunction func, Datum arg)
 
void CallSyscacheCallbacks (int cacheid, uint32 hashvalue)
 
void InvalidateSystemCaches (void)
 

Typedef Documentation

typedef void(* RelcacheCallbackFunction)(Datum arg, Oid relid)

Definition at line 23 of file inval.h.

typedef void(* SyscacheCallbackFunction)(Datum arg, int cacheid, uint32 hashvalue)

Definition at line 22 of file inval.h.

Function Documentation

void AcceptInvalidationMessages ( void  )

Definition at line 672 of file inval.c.

References InvalidateSystemCaches(), LocalExecuteInvalidationMessage(), and ReceiveSharedInvalidMessages().

Referenced by AtStart_Cache(), ConditionalLockRelation(), ConditionalLockRelationOid(), LockDatabaseObject(), LockRelation(), LockRelationOid(), LockSharedObject(), ProcessCatchupInterrupt(), RangeVarGetRelidExtended(), relation_openrv(), relation_openrv_extended(), RemoveRelations(), and write_relcache_init_file().

673 {
676 
677  /*
678  * Test code to force cache flushes anytime a flush could happen.
679  *
680  * If used with CLOBBER_FREED_MEMORY, CLOBBER_CACHE_ALWAYS provides a
681  * fairly thorough test that the system contains no cache-flush hazards.
682  * However, it also makes the system unbelievably slow --- the regression
683  * tests take about 100 times longer than normal.
684  *
685  * If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY. This
686  * slows things by at least a factor of 10000, so I wouldn't suggest
687  * trying to run the entire regression tests that way. It's useful to try
688  * a few simple tests, to make sure that cache reload isn't subject to
689  * internal cache-flush hazards, but after you've done a few thousand
690  * recursive reloads it's unlikely you'll learn more.
691  */
692 #if defined(CLOBBER_CACHE_ALWAYS)
693  {
694  static bool in_recursion = false;
695 
696  if (!in_recursion)
697  {
698  in_recursion = true;
700  in_recursion = false;
701  }
702  }
703 #elif defined(CLOBBER_CACHE_RECURSIVELY)
705 #endif
706 }
void InvalidateSystemCaches(void)
Definition: inval.c:634
void ReceiveSharedInvalidMessages(void(*invalFunction)(SharedInvalidationMessage *msg), void(*resetFunction)(void))
Definition: sinval.c:71
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:547
void AtEOSubXact_Inval ( bool  isCommit)

Definition at line 981 of file inval.c.

References AppendInvalidationMessages(), Assert, CommandEndInvalidationMessages(), GetCurrentTransactionNestLevel(), LocalExecuteInvalidationMessage(), TransInvalidationInfo::my_level, NULL, TransInvalidationInfo::parent, pfree(), TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), TransInvalidationInfo::RelcacheInitFileInval, and transInvalInfo.

Referenced by AbortSubTransaction(), and CommitSubTransaction().

982 {
983  int my_level;
985 
986  /* Quick exit if no messages. */
987  if (myInfo == NULL)
988  return;
989 
990  /* Also bail out quickly if messages are not for this level. */
991  my_level = GetCurrentTransactionNestLevel();
992  if (myInfo->my_level != my_level)
993  {
994  Assert(myInfo->my_level < my_level);
995  return;
996  }
997 
998  if (isCommit)
999  {
1000  /* If CurrentCmdInvalidMsgs still has anything, fix it */
1002 
1003  /*
1004  * We create invalidation stack entries lazily, so the parent might
1005  * not have one. Instead of creating one, moving all the data over,
1006  * and then freeing our own, we can just adjust the level of our own
1007  * entry.
1008  */
1009  if (myInfo->parent == NULL || myInfo->parent->my_level < my_level - 1)
1010  {
1011  myInfo->my_level--;
1012  return;
1013  }
1014 
1015  /* Pass up my inval messages to parent */
1017  &myInfo->PriorCmdInvalidMsgs);
1018 
1019  /* Pending relcache inval becomes parent's problem too */
1020  if (myInfo->RelcacheInitFileInval)
1021  myInfo->parent->RelcacheInitFileInval = true;
1022 
1023  /* Pop the transaction state stack */
1024  transInvalInfo = myInfo->parent;
1025 
1026  /* Need not free anything else explicitly */
1027  pfree(myInfo);
1028  }
1029  else
1030  {
1033 
1034  /* Pop the transaction state stack */
1035  transInvalInfo = myInfo->parent;
1036 
1037  /* Need not free anything else explicitly */
1038  pfree(myInfo);
1039  }
1040 }
static void AppendInvalidationMessages(InvalidationListHeader *dest, InvalidationListHeader *src)
Definition: inval.c:433
InvalidationListHeader PriorCmdInvalidMsgs
Definition: inval.c:165
void CommandEndInvalidationMessages(void)
Definition: inval.c:1058
struct TransInvalidationInfo * parent
Definition: inval.c:156
static TransInvalidationInfo * transInvalInfo
Definition: inval.c:171
void pfree(void *pointer)
Definition: mcxt.c:992
bool RelcacheInitFileInval
Definition: inval.c:168
static void ProcessInvalidationMessages(InvalidationListHeader *hdr, void(*func)(SharedInvalidationMessage *msg))
Definition: inval.c:447
int GetCurrentTransactionNestLevel(void)
Definition: xact.c:760
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:547
void AtEOXact_Inval ( bool  isCommit)

Definition at line 922 of file inval.c.

References AppendInvalidationMessages(), Assert, TransInvalidationInfo::CurrentCmdInvalidMsgs, LocalExecuteInvalidationMessage(), TransInvalidationInfo::my_level, NULL, numSharedInvalidMessagesArray, TransInvalidationInfo::parent, TransInvalidationInfo::PriorCmdInvalidMsgs, ProcessInvalidationMessages(), ProcessInvalidationMessagesMulti(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), TransInvalidationInfo::RelcacheInitFileInval, and SendSharedInvalidMessages().

Referenced by AbortTransaction(), CommitTransaction(), and PostPrepare_Inval().

923 {
924  /* Quick exit if no messages */
925  if (transInvalInfo == NULL)
926  return;
927 
928  /* Must be at top of stack */
930 
931  if (isCommit)
932  {
933  /*
934  * Relcache init file invalidation requires processing both before and
935  * after we send the SI messages. However, we need not do anything
936  * unless we committed.
937  */
940 
943 
946 
949  }
950  else
951  {
954  }
955 
956  /* Need not free anything explicitly */
960 }
static void AppendInvalidationMessages(InvalidationListHeader *dest, InvalidationListHeader *src)
Definition: inval.c:433
static SharedInvalidationMessage * SharedInvalidMessagesArray
Definition: inval.c:173
InvalidationListHeader PriorCmdInvalidMsgs
Definition: inval.c:165
struct TransInvalidationInfo * parent
Definition: inval.c:156
static TransInvalidationInfo * transInvalInfo
Definition: inval.c:171
InvalidationListHeader CurrentCmdInvalidMsgs
Definition: inval.c:162
static int numSharedInvalidMessagesArray
Definition: inval.c:174
static void ProcessInvalidationMessagesMulti(InvalidationListHeader *hdr, void(*func)(const SharedInvalidationMessage *msgs, int n))
Definition: inval.c:459
bool RelcacheInitFileInval
Definition: inval.c:168
static void ProcessInvalidationMessages(InvalidationListHeader *hdr, void(*func)(SharedInvalidationMessage *msg))
Definition: inval.c:447
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:5982
#define NULL
Definition: c.h:226
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:5956
#define Assert(condition)
Definition: c.h:671
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
Definition: sinval.c:49
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:547
void AtPrepare_Inval ( void  )
void CacheInvalidateCatalog ( Oid  catalogId)

Definition at line 1201 of file inval.c.

References InvalidOid, IsSharedRelation(), MyDatabaseId, PrepareInvalidationState(), and RegisterCatalogInvalidation().

Referenced by finish_heap_swap().

1202 {
1203  Oid databaseId;
1204 
1206 
1207  if (IsSharedRelation(catalogId))
1208  databaseId = InvalidOid;
1209  else
1210  databaseId = MyDatabaseId;
1211 
1212  RegisterCatalogInvalidation(databaseId, catalogId);
1213 }
unsigned int Oid
Definition: postgres_ext.h:31
static void PrepareInvalidationState(void)
Definition: inval.c:713
Oid MyDatabaseId
Definition: globals.c:76
static void RegisterCatalogInvalidation(Oid dbId, Oid catId)
Definition: inval.c:491
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:219
#define InvalidOid
Definition: postgres_ext.h:36
void CacheInvalidateHeapTuple ( Relation  relation,
HeapTuple  tuple,
HeapTuple  newtuple 
)

Definition at line 1087 of file inval.c.

References AttributeRelationId, GETSTRUCT, HeapTupleGetOid, IndexRelationId, InvalidOid, IsBootstrapProcessingMode, IsCatalogRelation(), IsSharedRelation(), IsToastRelation(), MyDatabaseId, PrepareInvalidationState(), PrepareToInvalidateCacheTuple(), RegisterCatcacheInvalidation(), RegisterRelcacheInvalidation(), RegisterSnapshotInvalidation(), RelationGetRelid, RelationInvalidatesSnapshotsOnly(), and RelationRelationId.

Referenced by heap_delete(), heap_inplace_update(), heap_insert(), heap_multi_insert(), and heap_update().

1090 {
1091  Oid tupleRelId;
1092  Oid databaseId;
1093  Oid relationId;
1094 
1095  /* Do nothing during bootstrap */
1097  return;
1098 
1099  /*
1100  * We only need to worry about invalidation for tuples that are in system
1101  * catalogs; user-relation tuples are never in catcaches and can't affect
1102  * the relcache either.
1103  */
1104  if (!IsCatalogRelation(relation))
1105  return;
1106 
1107  /*
1108  * IsCatalogRelation() will return true for TOAST tables of system
1109  * catalogs, but we don't care about those, either.
1110  */
1111  if (IsToastRelation(relation))
1112  return;
1113 
1114  /*
1115  * If we're not prepared to queue invalidation messages for this
1116  * subtransaction level, get ready now.
1117  */
1119 
1120  /*
1121  * First let the catcache do its thing
1122  */
1123  tupleRelId = RelationGetRelid(relation);
1124  if (RelationInvalidatesSnapshotsOnly(tupleRelId))
1125  {
1126  databaseId = IsSharedRelation(tupleRelId) ? InvalidOid : MyDatabaseId;
1127  RegisterSnapshotInvalidation(databaseId, tupleRelId);
1128  }
1129  else
1130  PrepareToInvalidateCacheTuple(relation, tuple, newtuple,
1132 
1133  /*
1134  * Now, is this tuple one of the primary definers of a relcache entry?
1135  *
1136  * Note we ignore newtuple here; we assume an update cannot move a tuple
1137  * from being part of one relcache entry to being part of another.
1138  */
1139  if (tupleRelId == RelationRelationId)
1140  {
1141  Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
1142 
1143  relationId = HeapTupleGetOid(tuple);
1144  if (classtup->relisshared)
1145  databaseId = InvalidOid;
1146  else
1147  databaseId = MyDatabaseId;
1148  }
1149  else if (tupleRelId == AttributeRelationId)
1150  {
1151  Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
1152 
1153  relationId = atttup->attrelid;
1154 
1155  /*
1156  * KLUGE ALERT: we always send the relcache event with MyDatabaseId,
1157  * even if the rel in question is shared (which we can't easily tell).
1158  * This essentially means that only backends in this same database
1159  * will react to the relcache flush request. This is in fact
1160  * appropriate, since only those backends could see our pg_attribute
1161  * change anyway. It looks a bit ugly though. (In practice, shared
1162  * relations can't have schema changes after bootstrap, so we should
1163  * never come here for a shared rel anyway.)
1164  */
1165  databaseId = MyDatabaseId;
1166  }
1167  else if (tupleRelId == IndexRelationId)
1168  {
1169  Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple);
1170 
1171  /*
1172  * When a pg_index row is updated, we should send out a relcache inval
1173  * for the index relation. As above, we don't know the shared status
1174  * of the index, but in practice it doesn't matter since indexes of
1175  * shared catalogs can't have such updates.
1176  */
1177  relationId = indextup->indexrelid;
1178  databaseId = MyDatabaseId;
1179  }
1180  else
1181  return;
1182 
1183  /*
1184  * Yes. We need to register a relcache invalidation event.
1185  */
1186  RegisterRelcacheInvalidation(databaseId, relationId);
1187 }
bool IsToastRelation(Relation relation)
Definition: catalog.c:135
bool IsCatalogRelation(Relation relation)
Definition: catalog.c:91
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define IndexRelationId
Definition: pg_index.h:29
#define RelationRelationId
Definition: pg_class.h:29
void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple, void(*function)(int, uint32, Oid))
Definition: catcache.c:1846
#define AttributeRelationId
Definition: pg_attribute.h:33
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
static void PrepareInvalidationState(void)
Definition: inval.c:713
FormData_pg_index * Form_pg_index
Definition: pg_index.h:67
Oid MyDatabaseId
Definition: globals.c:76
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:219
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:503
static void RegisterCatcacheInvalidation(int cacheId, uint32 hashValue, Oid dbId)
Definition: inval.c:477
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1320
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:365
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
#define RelationGetRelid(relation)
Definition: rel.h:413
static void RegisterSnapshotInvalidation(Oid dbId, Oid relId)
Definition: inval.c:533
void CacheInvalidateRelcache ( Relation  relation)

Definition at line 1225 of file inval.c.

References InvalidOid, MyDatabaseId, PrepareInvalidationState(), RelationData::rd_rel, RegisterRelcacheInvalidation(), and RelationGetRelid.

Referenced by AlterPolicy(), ATExecAlterConstraint(), ATExecDetachPartition(), ATExecGenericOptions(), ATExecValidateConstraint(), CreatePolicy(), EnableDisableRule(), EnableDisableTrigger(), heap_drop_with_catalog(), index_drop(), publication_add_relation(), reindex_index(), RemovePolicyById(), RemoveRewriteRuleById(), RemoveRoleFromObjectPolicy(), RemoveTriggerById(), rename_policy(), RenameRewriteRule(), renametrig(), SetRelationNumChecks(), StorePartitionBound(), and StorePartitionKey().

1226 {
1227  Oid databaseId;
1228  Oid relationId;
1229 
1231 
1232  relationId = RelationGetRelid(relation);
1233  if (relation->rd_rel->relisshared)
1234  databaseId = InvalidOid;
1235  else
1236  databaseId = MyDatabaseId;
1237 
1238  RegisterRelcacheInvalidation(databaseId, relationId);
1239 }
Form_pg_class rd_rel
Definition: rel.h:113
unsigned int Oid
Definition: postgres_ext.h:31
static void PrepareInvalidationState(void)
Definition: inval.c:713
Oid MyDatabaseId
Definition: globals.c:76
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:503
#define RelationGetRelid(relation)
Definition: rel.h:413
void CacheInvalidateRelcacheAll ( void  )

Definition at line 1249 of file inval.c.

References InvalidOid, PrepareInvalidationState(), and RegisterRelcacheInvalidation().

Referenced by AlterPublicationOptions().

1250 {
1252 
1254 }
static void PrepareInvalidationState(void)
Definition: inval.c:713
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:503
void CacheInvalidateRelcacheByRelid ( Oid  relid)

Definition at line 1284 of file inval.c.

References CacheInvalidateRelcacheByTuple(), elog, ERROR, HeapTupleIsValid, ObjectIdGetDatum, PrepareInvalidationState(), ReleaseSysCache(), RELOID, and SearchSysCache1.

Referenced by AlterPublicationOptions(), ATExecAlterConstraint(), DefineIndex(), and RemovePublicationRelById().

1285 {
1286  HeapTuple tup;
1287 
1289 
1290  tup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1291  if (!HeapTupleIsValid(tup))
1292  elog(ERROR, "cache lookup failed for relation %u", relid);
1294  ReleaseSysCache(tup);
1295 }
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
static void PrepareInvalidationState(void)
Definition: inval.c:713
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
Definition: inval.c:1261
#define elog
Definition: elog.h:219
void CacheInvalidateRelcacheByTuple ( HeapTuple  classTuple)

Definition at line 1261 of file inval.c.

References GETSTRUCT, HeapTupleGetOid, InvalidOid, MyDatabaseId, PrepareInvalidationState(), and RegisterRelcacheInvalidation().

Referenced by CacheInvalidateRelcacheByRelid(), index_update_stats(), SetRelationHasSubclass(), SetRelationRuleStatus(), and swap_relation_files().

1262 {
1263  Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
1264  Oid databaseId;
1265  Oid relationId;
1266 
1268 
1269  relationId = HeapTupleGetOid(classTuple);
1270  if (classtup->relisshared)
1271  databaseId = InvalidOid;
1272  else
1273  databaseId = MyDatabaseId;
1274  RegisterRelcacheInvalidation(databaseId, relationId);
1275 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
unsigned int Oid
Definition: postgres_ext.h:31
static void PrepareInvalidationState(void)
Definition: inval.c:713
Oid MyDatabaseId
Definition: globals.c:76
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:503
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
void CacheInvalidateRelmap ( Oid  databaseId)

Definition at line 1354 of file inval.c.

References SharedInvalRelmapMsg::dbId, SharedInvalRelmapMsg::id, SharedInvalidationMessage::rm, SendSharedInvalidMessages(), SHAREDINVALRELMAP_ID, and VALGRIND_MAKE_MEM_DEFINED.

Referenced by write_relmap_file().

1355 {
1357 
1358  msg.rm.id = SHAREDINVALRELMAP_ID;
1359  msg.rm.dbId = databaseId;
1360  /* check AddCatcacheInvalidationMessage() for an explanation */
1361  VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
1362 
1363  SendSharedInvalidMessages(&msg, 1);
1364 }
#define VALGRIND_MAKE_MEM_DEFINED(addr, size)
Definition: memdebug.h:26
SharedInvalRelmapMsg rm
Definition: sinval.h:120
#define SHAREDINVALRELMAP_ID
Definition: sinval.h:96
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
Definition: sinval.c:49
void CacheInvalidateSmgr ( RelFileNodeBackend  rnode)

Definition at line 1324 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 smgrdounlink(), smgrdounlinkall(), smgrdounlinkfork(), smgrtruncate(), and vm_extend().

1325 {
1327 
1328  msg.sm.id = SHAREDINVALSMGR_ID;
1329  msg.sm.backend_hi = rnode.backend >> 16;
1330  msg.sm.backend_lo = rnode.backend & 0xffff;
1331  msg.sm.rnode = rnode.node;
1332  /* check AddCatcacheInvalidationMessage() for an explanation */
1333  VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
1334 
1335  SendSharedInvalidMessages(&msg, 1);
1336 }
#define VALGRIND_MAKE_MEM_DEFINED(addr, size)
Definition: memdebug.h:26
RelFileNode node
Definition: relfilenode.h:74
SharedInvalSmgrMsg sm
Definition: sinval.h:119
BackendId backend
Definition: relfilenode.h:75
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
Definition: sinval.c:49
uint16 backend_lo
Definition: sinval.h:92
RelFileNode rnode
Definition: sinval.h:93
#define SHAREDINVALSMGR_ID
Definition: sinval.h:85
void CacheRegisterRelcacheCallback ( RelcacheCallbackFunction  func,
Datum  arg 
)

Definition at line 1405 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_relmap_init(), and lookup_type_cache().

1407 {
1409  elog(FATAL, "out of relcache_callback_list slots");
1410 
1413 
1415 }
#define MAX_RELCACHE_CALLBACKS
Definition: inval.c:184
static int relcache_callback_count
Definition: inval.c:201
RelcacheCallbackFunction function
Definition: inval.c:197
#define FATAL
Definition: elog.h:52
static struct RELCACHECALLBACK relcache_callback_list[MAX_RELCACHE_CALLBACKS]
void * arg
#define elog
Definition: elog.h:219
void CacheRegisterSyscacheCallback ( int  cacheid,
SyscacheCallbackFunction  func,
Datum  arg 
)

Definition at line 1381 of file inval.c.

References arg, SYSCACHECALLBACK::arg, elog, FATAL, SYSCACHECALLBACK::function, SYSCACHECALLBACK::id, MAX_SYSCACHE_CALLBACKS, syscache_callback_count, and syscache_callback_list.

Referenced by ApplyWorkerMain(), BuildEventTriggerCache(), find_oper_cache_entry(), init_rel_sync_cache(), init_ts_config_cache(), initialize_acl(), InitializeAttoptCache(), InitializeSearchPath(), InitializeShippableCache(), InitializeTableSpaceCache(), InitPlanCache(), logicalrep_relmap_init(), lookup_proof_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), pgoutput_startup(), ri_InitHashTables(), and superuser_arg().

1384 {
1386  elog(FATAL, "out of syscache_callback_list slots");
1387 
1391 
1393 }
#define FATAL
Definition: elog.h:52
#define MAX_SYSCACHE_CALLBACKS
Definition: inval.c:183
static int syscache_callback_count
Definition: inval.c:193
void * arg
#define elog
Definition: elog.h:219
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
SyscacheCallbackFunction function
Definition: inval.c:189
void CallSyscacheCallbacks ( int  cacheid,
uint32  hashvalue 
)

Definition at line 1424 of file inval.c.

References SYSCACHECALLBACK::arg, SYSCACHECALLBACK::function, i, SYSCACHECALLBACK::id, syscache_callback_count, and syscache_callback_list.

Referenced by CatalogCacheFlushCatalog(), and LocalExecuteInvalidationMessage().

1425 {
1426  int i;
1427 
1428  for (i = 0; i < syscache_callback_count; i++)
1429  {
1430  struct SYSCACHECALLBACK *ccitem = syscache_callback_list + i;
1431 
1432  if (ccitem->id == cacheid)
1433  (*ccitem->function) (ccitem->arg, cacheid, hashvalue);
1434  }
1435 }
static int syscache_callback_count
Definition: inval.c:193
int i
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
SyscacheCallbackFunction function
Definition: inval.c:189
void CommandEndInvalidationMessages ( void  )

Definition at line 1058 of file inval.c.

References AppendInvalidationMessages(), TransInvalidationInfo::CurrentCmdInvalidMsgs, LocalExecuteInvalidationMessage(), NULL, TransInvalidationInfo::PriorCmdInvalidMsgs, and ProcessInvalidationMessages().

Referenced by AtCCI_LocalCache(), and AtEOSubXact_Inval().

1059 {
1060  /*
1061  * You might think this shouldn't be called outside any transaction, but
1062  * bootstrap does it, and also ABORT issued when not in a transaction. So
1063  * just quietly return if no state to work on.
1064  */
1065  if (transInvalInfo == NULL)
1066  return;
1067 
1072 }
static void AppendInvalidationMessages(InvalidationListHeader *dest, InvalidationListHeader *src)
Definition: inval.c:433
InvalidationListHeader PriorCmdInvalidMsgs
Definition: inval.c:165
static TransInvalidationInfo * transInvalInfo
Definition: inval.c:171
InvalidationListHeader CurrentCmdInvalidMsgs
Definition: inval.c:162
static void ProcessInvalidationMessages(InvalidationListHeader *hdr, void(*func)(SharedInvalidationMessage *msg))
Definition: inval.c:447
#define NULL
Definition: c.h:226
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:547
void InvalidateSystemCaches ( void  )

Definition at line 634 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(), and pg_logical_slot_get_changes_guts().

635 {
636  int i;
637 
640  RelationCacheInvalidate(); /* gets smgr and relmap too */
641 
642  for (i = 0; i < syscache_callback_count; i++)
643  {
644  struct SYSCACHECALLBACK *ccitem = syscache_callback_list + i;
645 
646  (*ccitem->function) (ccitem->arg, ccitem->id, 0);
647  }
648 
649  for (i = 0; i < relcache_callback_count; i++)
650  {
651  struct RELCACHECALLBACK *ccitem = relcache_callback_list + i;
652 
653  (*ccitem->function) (ccitem->arg, InvalidOid);
654  }
655 }
static int relcache_callback_count
Definition: inval.c:201
RelcacheCallbackFunction function
Definition: inval.c:197
void InvalidateCatalogSnapshot(void)
Definition: snapmgr.c:506
static int syscache_callback_count
Definition: inval.c:193
#define InvalidOid
Definition: postgres_ext.h:36
static struct RELCACHECALLBACK relcache_callback_list[MAX_RELCACHE_CALLBACKS]
void ResetCatalogCaches(void)
Definition: catcache.c:645
void RelationCacheInvalidate(void)
Definition: relcache.c:2755
int i
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
SyscacheCallbackFunction function
Definition: inval.c:189
void PostPrepare_Inval ( void  )

Definition at line 750 of file inval.c.

References AtEOXact_Inval().

Referenced by PrepareTransaction().

751 {
752  AtEOXact_Inval(false);
753 }
void AtEOXact_Inval(bool isCommit)
Definition: inval.c:922