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(), LogicalRepApplyLoop(), 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:950
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:761
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
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:6057
#define NULL
Definition: c.h:229
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6031
#define Assert(condition)
Definition: c.h:675
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 1202 of file inval.c.

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

Referenced by finish_heap_swap().

1203 {
1204  Oid databaseId;
1205 
1207 
1208  if (IsSharedRelation(catalogId))
1209  databaseId = InvalidOid;
1210  else
1211  databaseId = MyDatabaseId;
1212 
1213  RegisterCatalogInvalidation(databaseId, catalogId);
1214 }
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  * See comments in file header for deeper explanation.
1136  *
1137  * Note we ignore newtuple here; we assume an update cannot move a tuple
1138  * from being part of one relcache entry to being part of another.
1139  */
1140  if (tupleRelId == RelationRelationId)
1141  {
1142  Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
1143 
1144  relationId = HeapTupleGetOid(tuple);
1145  if (classtup->relisshared)
1146  databaseId = InvalidOid;
1147  else
1148  databaseId = MyDatabaseId;
1149  }
1150  else if (tupleRelId == AttributeRelationId)
1151  {
1152  Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
1153 
1154  relationId = atttup->attrelid;
1155 
1156  /*
1157  * KLUGE ALERT: we always send the relcache event with MyDatabaseId,
1158  * even if the rel in question is shared (which we can't easily tell).
1159  * This essentially means that only backends in this same database
1160  * will react to the relcache flush request. This is in fact
1161  * appropriate, since only those backends could see our pg_attribute
1162  * change anyway. It looks a bit ugly though. (In practice, shared
1163  * relations can't have schema changes after bootstrap, so we should
1164  * never come here for a shared rel anyway.)
1165  */
1166  databaseId = MyDatabaseId;
1167  }
1168  else if (tupleRelId == IndexRelationId)
1169  {
1170  Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple);
1171 
1172  /*
1173  * When a pg_index row is updated, we should send out a relcache inval
1174  * for the index relation. As above, we don't know the shared status
1175  * of the index, but in practice it doesn't matter since indexes of
1176  * shared catalogs can't have such updates.
1177  */
1178  relationId = indextup->indexrelid;
1179  databaseId = MyDatabaseId;
1180  }
1181  else
1182  return;
1183 
1184  /*
1185  * Yes. We need to register a relcache invalidation event.
1186  */
1187  RegisterRelcacheInvalidation(databaseId, relationId);
1188 }
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:187
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:1353
#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:417
static void RegisterSnapshotInvalidation(Oid dbId, Oid relId)
Definition: inval.c:533
void CacheInvalidateRelcache ( Relation  relation)

Definition at line 1226 of file inval.c.

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

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

1227 {
1228  Oid databaseId;
1229  Oid relationId;
1230 
1232 
1233  relationId = RelationGetRelid(relation);
1234  if (relation->rd_rel->relisshared)
1235  databaseId = InvalidOid;
1236  else
1237  databaseId = MyDatabaseId;
1238 
1239  RegisterRelcacheInvalidation(databaseId, relationId);
1240 }
Form_pg_class rd_rel
Definition: rel.h:114
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:417
void CacheInvalidateRelcacheAll ( void  )

Definition at line 1250 of file inval.c.

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

Referenced by AlterPublicationOptions().

1251 {
1253 
1255 }
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 1285 of file inval.c.

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

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

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

Definition at line 1262 of file inval.c.

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

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

1263 {
1264  Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
1265  Oid databaseId;
1266  Oid relationId;
1267 
1269 
1270  relationId = HeapTupleGetOid(classTuple);
1271  if (classtup->relisshared)
1272  databaseId = InvalidOid;
1273  else
1274  databaseId = MyDatabaseId;
1275  RegisterRelcacheInvalidation(databaseId, relationId);
1276 }
#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 1355 of file inval.c.

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

Referenced by write_relmap_file().

1356 {
1358 
1359  msg.rm.id = SHAREDINVALRELMAP_ID;
1360  msg.rm.dbId = databaseId;
1361  /* check AddCatcacheInvalidationMessage() for an explanation */
1362  VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
1363 
1364  SendSharedInvalidMessages(&msg, 1);
1365 }
#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 1325 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().

1326 {
1328 
1329  msg.sm.id = SHAREDINVALSMGR_ID;
1330  msg.sm.backend_hi = rnode.backend >> 16;
1331  msg.sm.backend_lo = rnode.backend & 0xffff;
1332  msg.sm.rnode = rnode.node;
1333  /* check AddCatcacheInvalidationMessage() for an explanation */
1334  VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
1335 
1336  SendSharedInvalidMessages(&msg, 1);
1337 }
#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 1406 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().

1408 {
1410  elog(FATAL, "out of relcache_callback_list slots");
1411 
1414 
1416 }
#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 1382 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().

1385 {
1387  elog(FATAL, "out of syscache_callback_list slots");
1388 
1392 
1394 }
#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 1425 of file inval.c.

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

Referenced by CatalogCacheFlushCatalog(), and LocalExecuteInvalidationMessage().

1426 {
1427  int i;
1428 
1429  for (i = 0; i < syscache_callback_count; i++)
1430  {
1431  struct SYSCACHECALLBACK *ccitem = syscache_callback_list + i;
1432 
1433  if (ccitem->id == cacheid)
1434  (*ccitem->function) (ccitem->arg, cacheid, hashvalue);
1435  }
1436 }
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:229
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:2756
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