PostgreSQL Source Code  git master
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 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

◆ RelcacheCallbackFunction

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

Definition at line 23 of file inval.h.

◆ SyscacheCallbackFunction

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

Definition at line 22 of file inval.h.

Function Documentation

◆ AcceptInvalidationMessages()

void AcceptInvalidationMessages ( void  )

Definition at line 681 of file inval.c.

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

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

682 {
685 
686  /*
687  * Test code to force cache flushes anytime a flush could happen.
688  *
689  * If used with CLOBBER_FREED_MEMORY, CLOBBER_CACHE_ALWAYS provides a
690  * fairly thorough test that the system contains no cache-flush hazards.
691  * However, it also makes the system unbelievably slow --- the regression
692  * tests take about 100 times longer than normal.
693  *
694  * If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY. This
695  * slows things by at least a factor of 10000, so I wouldn't suggest
696  * trying to run the entire regression tests that way. It's useful to try
697  * a few simple tests, to make sure that cache reload isn't subject to
698  * internal cache-flush hazards, but after you've done a few thousand
699  * recursive reloads it's unlikely you'll learn more.
700  */
701 #if defined(CLOBBER_CACHE_ALWAYS)
702  {
703  static bool in_recursion = false;
704 
705  if (!in_recursion)
706  {
707  in_recursion = true;
709  in_recursion = false;
710  }
711  }
712 #elif defined(CLOBBER_CACHE_RECURSIVELY)
713  {
714  static int recursion_depth = 0;
715 
716  /* Maximum depth is arbitrary depending on your threshold of pain */
717  if (recursion_depth < 3)
718  {
719  recursion_depth++;
721  recursion_depth--;
722  }
723  }
724 #endif
725 }
static int recursion_depth
Definition: elog.c:147
void InvalidateSystemCaches(void)
Definition: inval.c:643
void ReceiveSharedInvalidMessages(void(*invalFunction)(SharedInvalidationMessage *msg), void(*resetFunction)(void))
Definition: sinval.c:71
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:556

◆ AtEOSubXact_Inval()

void AtEOSubXact_Inval ( bool  isCommit)

Definition at line 1008 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().

1009 {
1010  int my_level;
1012 
1013  /* Quick exit if no messages. */
1014  if (myInfo == NULL)
1015  return;
1016 
1017  /* Also bail out quickly if messages are not for this level. */
1018  my_level = GetCurrentTransactionNestLevel();
1019  if (myInfo->my_level != my_level)
1020  {
1021  Assert(myInfo->my_level < my_level);
1022  return;
1023  }
1024 
1025  if (isCommit)
1026  {
1027  /* If CurrentCmdInvalidMsgs still has anything, fix it */
1029 
1030  /*
1031  * We create invalidation stack entries lazily, so the parent might
1032  * not have one. Instead of creating one, moving all the data over,
1033  * and then freeing our own, we can just adjust the level of our own
1034  * entry.
1035  */
1036  if (myInfo->parent == NULL || myInfo->parent->my_level < my_level - 1)
1037  {
1038  myInfo->my_level--;
1039  return;
1040  }
1041 
1042  /* Pass up my inval messages to parent */
1044  &myInfo->PriorCmdInvalidMsgs);
1045 
1046  /* Pending relcache inval becomes parent's problem too */
1047  if (myInfo->RelcacheInitFileInval)
1048  myInfo->parent->RelcacheInitFileInval = true;
1049 
1050  /* Pop the transaction state stack */
1051  transInvalInfo = myInfo->parent;
1052 
1053  /* Need not free anything else explicitly */
1054  pfree(myInfo);
1055  }
1056  else
1057  {
1060 
1061  /* Pop the transaction state stack */
1062  transInvalInfo = myInfo->parent;
1063 
1064  /* Need not free anything else explicitly */
1065  pfree(myInfo);
1066  }
1067 }
static void AppendInvalidationMessages(InvalidationListHeader *dest, InvalidationListHeader *src)
Definition: inval.c:442
InvalidationListHeader PriorCmdInvalidMsgs
Definition: inval.c:167
void CommandEndInvalidationMessages(void)
Definition: inval.c:1085
struct TransInvalidationInfo * parent
Definition: inval.c:158
static TransInvalidationInfo * transInvalInfo
Definition: inval.c:173
void pfree(void *pointer)
Definition: mcxt.c:1056
bool RelcacheInitFileInval
Definition: inval.c:170
static void ProcessInvalidationMessages(InvalidationListHeader *hdr, void(*func)(SharedInvalidationMessage *msg))
Definition: inval.c:456
int GetCurrentTransactionNestLevel(void)
Definition: xact.c:841
#define Assert(condition)
Definition: c.h:733
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:556

◆ AtEOXact_Inval()

void AtEOXact_Inval ( bool  isCommit)

Definition at line 949 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().

950 {
951  /* Quick exit if no messages */
952  if (transInvalInfo == NULL)
953  return;
954 
955  /* Must be at top of stack */
957 
958  if (isCommit)
959  {
960  /*
961  * Relcache init file invalidation requires processing both before and
962  * after we send the SI messages. However, we need not do anything
963  * unless we committed.
964  */
967 
970 
973 
976  }
977  else
978  {
981  }
982 
983  /* Need not free anything explicitly */
984  transInvalInfo = NULL;
987 }
static void AppendInvalidationMessages(InvalidationListHeader *dest, InvalidationListHeader *src)
Definition: inval.c:442
static SharedInvalidationMessage * SharedInvalidMessagesArray
Definition: inval.c:175
InvalidationListHeader PriorCmdInvalidMsgs
Definition: inval.c:167
struct TransInvalidationInfo * parent
Definition: inval.c:158
static TransInvalidationInfo * transInvalInfo
Definition: inval.c:173
InvalidationListHeader CurrentCmdInvalidMsgs
Definition: inval.c:164
static int numSharedInvalidMessagesArray
Definition: inval.c:176
static void ProcessInvalidationMessagesMulti(InvalidationListHeader *hdr, void(*func)(const SharedInvalidationMessage *msgs, int n))
Definition: inval.c:468
bool RelcacheInitFileInval
Definition: inval.c:170
static void ProcessInvalidationMessages(InvalidationListHeader *hdr, void(*func)(SharedInvalidationMessage *msg))
Definition: inval.c:456
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:5963
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:5938
#define Assert(condition)
Definition: c.h:733
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
Definition: sinval.c:49
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:556

◆ CacheInvalidateCatalog()

void CacheInvalidateCatalog ( Oid  catalogId)

Definition at line 1246 of file inval.c.

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

Referenced by finish_heap_swap().

1247 {
1248  Oid databaseId;
1249 
1251 
1252  if (IsSharedRelation(catalogId))
1253  databaseId = InvalidOid;
1254  else
1255  databaseId = MyDatabaseId;
1256 
1257  RegisterCatalogInvalidation(databaseId, catalogId);
1258 }
unsigned int Oid
Definition: postgres_ext.h:31
static void PrepareInvalidationState(void)
Definition: inval.c:732
Oid MyDatabaseId
Definition: globals.c:85
static void RegisterCatalogInvalidation(Oid dbId, Oid catId)
Definition: inval.c:500
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:239
#define InvalidOid
Definition: postgres_ext.h:36

◆ CacheInvalidateHeapTuple()

void CacheInvalidateHeapTuple ( Relation  relation,
HeapTuple  tuple,
HeapTuple  newtuple 
)

Definition at line 1114 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().

1117 {
1118  Oid tupleRelId;
1119  Oid databaseId;
1120  Oid relationId;
1121 
1122  /* Do nothing during bootstrap */
1124  return;
1125 
1126  /*
1127  * We only need to worry about invalidation for tuples that are in system
1128  * catalogs; user-relation tuples are never in catcaches and can't affect
1129  * the relcache either.
1130  */
1131  if (!IsCatalogRelation(relation))
1132  return;
1133 
1134  /*
1135  * IsCatalogRelation() will return true for TOAST tables of system
1136  * catalogs, but we don't care about those, either.
1137  */
1138  if (IsToastRelation(relation))
1139  return;
1140 
1141  /*
1142  * If we're not prepared to queue invalidation messages for this
1143  * subtransaction level, get ready now.
1144  */
1146 
1147  /*
1148  * First let the catcache do its thing
1149  */
1150  tupleRelId = RelationGetRelid(relation);
1151  if (RelationInvalidatesSnapshotsOnly(tupleRelId))
1152  {
1153  databaseId = IsSharedRelation(tupleRelId) ? InvalidOid : MyDatabaseId;
1154  RegisterSnapshotInvalidation(databaseId, tupleRelId);
1155  }
1156  else
1157  PrepareToInvalidateCacheTuple(relation, tuple, newtuple,
1159 
1160  /*
1161  * Now, is this tuple one of the primary definers of a relcache entry? See
1162  * comments in file header for deeper explanation.
1163  *
1164  * Note we ignore newtuple here; we assume an update cannot move a tuple
1165  * from being part of one relcache entry to being part of another.
1166  */
1167  if (tupleRelId == RelationRelationId)
1168  {
1169  Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
1170 
1171  relationId = classtup->oid;
1172  if (classtup->relisshared)
1173  databaseId = InvalidOid;
1174  else
1175  databaseId = MyDatabaseId;
1176  }
1177  else if (tupleRelId == AttributeRelationId)
1178  {
1179  Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
1180 
1181  relationId = atttup->attrelid;
1182 
1183  /*
1184  * KLUGE ALERT: we always send the relcache event with MyDatabaseId,
1185  * even if the rel in question is shared (which we can't easily tell).
1186  * This essentially means that only backends in this same database
1187  * will react to the relcache flush request. This is in fact
1188  * appropriate, since only those backends could see our pg_attribute
1189  * change anyway. It looks a bit ugly though. (In practice, shared
1190  * relations can't have schema changes after bootstrap, so we should
1191  * never come here for a shared rel anyway.)
1192  */
1193  databaseId = MyDatabaseId;
1194  }
1195  else if (tupleRelId == IndexRelationId)
1196  {
1197  Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple);
1198 
1199  /*
1200  * When a pg_index row is updated, we should send out a relcache inval
1201  * for the index relation. As above, we don't know the shared status
1202  * of the index, but in practice it doesn't matter since indexes of
1203  * shared catalogs can't have such updates.
1204  */
1205  relationId = indextup->indexrelid;
1206  databaseId = MyDatabaseId;
1207  }
1208  else if (tupleRelId == ConstraintRelationId)
1209  {
1210  Form_pg_constraint constrtup = (Form_pg_constraint) GETSTRUCT(tuple);
1211 
1212  /*
1213  * Foreign keys are part of relcache entries, too, so send out an
1214  * inval for the table that the FK applies to.
1215  */
1216  if (constrtup->contype == CONSTRAINT_FOREIGN &&
1217  OidIsValid(constrtup->conrelid))
1218  {
1219  relationId = constrtup->conrelid;
1220  databaseId = MyDatabaseId;
1221  }
1222  else
1223  return;
1224  }
1225  else
1226  return;
1227 
1228  /*
1229  * Yes. We need to register a relcache invalidation event.
1230  */
1231  RegisterRelcacheInvalidation(databaseId, relationId);
1232 }
bool IsToastRelation(Relation relation)
Definition: catalog.c:141
bool IsCatalogRelation(Relation relation)
Definition: catalog.c:99
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple, void(*function)(int, uint32, Oid))
Definition: catcache.c:2007
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:639
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
static void PrepareInvalidationState(void)
Definition: inval.c:732
FormData_pg_index * Form_pg_index
Definition: pg_index.h:66
Oid MyDatabaseId
Definition: globals.c:85
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:239
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:512
FormData_pg_constraint * Form_pg_constraint
static void RegisterCatcacheInvalidation(int cacheId, uint32 hashValue, Oid dbId)
Definition: inval.c:486
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1473
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:374
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150
#define RelationGetRelid(relation)
Definition: rel.h:423
static void RegisterSnapshotInvalidation(Oid dbId, Oid relId)
Definition: inval.c:542

◆ CacheInvalidateRelcache()

void CacheInvalidateRelcache ( Relation  relation)

Definition at line 1270 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(), 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().

1271 {
1272  Oid databaseId;
1273  Oid relationId;
1274 
1276 
1277  relationId = RelationGetRelid(relation);
1278  if (relation->rd_rel->relisshared)
1279  databaseId = InvalidOid;
1280  else
1281  databaseId = MyDatabaseId;
1282 
1283  RegisterRelcacheInvalidation(databaseId, relationId);
1284 }
Form_pg_class rd_rel
Definition: rel.h:83
unsigned int Oid
Definition: postgres_ext.h:31
static void PrepareInvalidationState(void)
Definition: inval.c:732
Oid MyDatabaseId
Definition: globals.c:85
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:512
#define RelationGetRelid(relation)
Definition: rel.h:423

◆ CacheInvalidateRelcacheAll()

void CacheInvalidateRelcacheAll ( void  )

Definition at line 1294 of file inval.c.

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

Referenced by AlterPublicationOptions().

1295 {
1297 
1299 }
static void PrepareInvalidationState(void)
Definition: inval.c:732
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:512

◆ CacheInvalidateRelcacheByRelid()

void CacheInvalidateRelcacheByRelid ( Oid  relid)

Definition at line 1329 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().

1330 {
1331  HeapTuple tup;
1332 
1334 
1335  tup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1336  if (!HeapTupleIsValid(tup))
1337  elog(ERROR, "cache lookup failed for relation %u", relid);
1339  ReleaseSysCache(tup);
1340 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
static void PrepareInvalidationState(void)
Definition: inval.c:732
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
Definition: inval.c:1306

◆ CacheInvalidateRelcacheByTuple()

void CacheInvalidateRelcacheByTuple ( HeapTuple  classTuple)

Definition at line 1306 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().

1307 {
1308  Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
1309  Oid databaseId;
1310  Oid relationId;
1311 
1313 
1314  relationId = classtup->oid;
1315  if (classtup->relisshared)
1316  databaseId = InvalidOid;
1317  else
1318  databaseId = MyDatabaseId;
1319  RegisterRelcacheInvalidation(databaseId, relationId);
1320 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
static void PrepareInvalidationState(void)
Definition: inval.c:732
Oid MyDatabaseId
Definition: globals.c:85
#define InvalidOid
Definition: postgres_ext.h:36
static void RegisterRelcacheInvalidation(Oid dbId, Oid relId)
Definition: inval.c:512
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150

◆ CacheInvalidateRelmap()

void CacheInvalidateRelmap ( Oid  databaseId)

Definition at line 1399 of file inval.c.

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

Referenced by write_relmap_file().

1400 {
1402 
1403  msg.rm.id = SHAREDINVALRELMAP_ID;
1404  msg.rm.dbId = databaseId;
1405  /* check AddCatcacheInvalidationMessage() for an explanation */
1406  VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
1407 
1408  SendSharedInvalidMessages(&msg, 1);
1409 }
#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

◆ CacheInvalidateSmgr()

void CacheInvalidateSmgr ( RelFileNodeBackend  rnode)

Definition at line 1369 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(), smgrtruncate(), and vm_extend().

1370 {
1372 
1373  msg.sm.id = SHAREDINVALSMGR_ID;
1374  msg.sm.backend_hi = rnode.backend >> 16;
1375  msg.sm.backend_lo = rnode.backend & 0xffff;
1376  msg.sm.rnode = rnode.node;
1377  /* check AddCatcacheInvalidationMessage() for an explanation */
1378  VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
1379 
1380  SendSharedInvalidMessages(&msg, 1);
1381 }
#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

◆ CacheRegisterRelcacheCallback()

void CacheRegisterRelcacheCallback ( RelcacheCallbackFunction  func,
Datum  arg 
)

Definition at line 1468 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().

1470 {
1472  elog(FATAL, "out of relcache_callback_list slots");
1473 
1476 
1478 }
static struct RELCACHECALLBACK relcache_callback_list[MAX_RELCACHE_CALLBACKS]
#define MAX_RELCACHE_CALLBACKS
Definition: inval.c:191
static int relcache_callback_count
Definition: inval.c:211
RelcacheCallbackFunction function
Definition: inval.c:207
#define FATAL
Definition: elog.h:52
#define elog(elevel,...)
Definition: elog.h:228
void * arg

◆ CacheRegisterSyscacheCallback()

void CacheRegisterSyscacheCallback ( int  cacheid,
SyscacheCallbackFunction  func,
Datum  arg 
)

Definition at line 1426 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().

1429 {
1430  if (cacheid < 0 || cacheid >= SysCacheSize)
1431  elog(FATAL, "invalid cache ID: %d", cacheid);
1433  elog(FATAL, "out of syscache_callback_list slots");
1434 
1435  if (syscache_callback_links[cacheid] == 0)
1436  {
1437  /* first callback for this cache */
1439  }
1440  else
1441  {
1442  /* add to end of chain, so that older callbacks are called first */
1443  int i = syscache_callback_links[cacheid] - 1;
1444 
1445  while (syscache_callback_list[i].link > 0)
1446  i = syscache_callback_list[i].link - 1;
1448  }
1449 
1454 
1456 }
int16 link
Definition: inval.c:196
#define SysCacheSize
Definition: syscache.h:113
#define FATAL
Definition: elog.h:52
#define MAX_SYSCACHE_CALLBACKS
Definition: inval.c:190
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
static int syscache_callback_count
Definition: inval.c:203
static int16 syscache_callback_links[SysCacheSize]
Definition: inval.c:201
#define elog(elevel,...)
Definition: elog.h:228
int i
void * arg
SyscacheCallbackFunction function
Definition: inval.c:197

◆ CallSyscacheCallbacks()

void CallSyscacheCallbacks ( int  cacheid,
uint32  hashvalue 
)

Definition at line 1487 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().

1488 {
1489  int i;
1490 
1491  if (cacheid < 0 || cacheid >= SysCacheSize)
1492  elog(ERROR, "invalid cache ID: %d", cacheid);
1493 
1494  i = syscache_callback_links[cacheid] - 1;
1495  while (i >= 0)
1496  {
1497  struct SYSCACHECALLBACK *ccitem = syscache_callback_list + i;
1498 
1499  Assert(ccitem->id == cacheid);
1500  ccitem->function(ccitem->arg, cacheid, hashvalue);
1501  i = ccitem->link - 1;
1502  }
1503 }
int16 link
Definition: inval.c:196
#define SysCacheSize
Definition: syscache.h:113
#define ERROR
Definition: elog.h:43
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
#define Assert(condition)
Definition: c.h:733
static int16 syscache_callback_links[SysCacheSize]
Definition: inval.c:201
#define elog(elevel,...)
Definition: elog.h:228
int i
SyscacheCallbackFunction function
Definition: inval.c:197

◆ CommandEndInvalidationMessages()

void CommandEndInvalidationMessages ( void  )

Definition at line 1085 of file inval.c.

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

Referenced by AtCCI_LocalCache(), and AtEOSubXact_Inval().

1086 {
1087  /*
1088  * You might think this shouldn't be called outside any transaction, but
1089  * bootstrap does it, and also ABORT issued when not in a transaction. So
1090  * just quietly return if no state to work on.
1091  */
1092  if (transInvalInfo == NULL)
1093  return;
1094 
1099 }
static void AppendInvalidationMessages(InvalidationListHeader *dest, InvalidationListHeader *src)
Definition: inval.c:442
InvalidationListHeader PriorCmdInvalidMsgs
Definition: inval.c:167
static TransInvalidationInfo * transInvalInfo
Definition: inval.c:173
InvalidationListHeader CurrentCmdInvalidMsgs
Definition: inval.c:164
static void ProcessInvalidationMessages(InvalidationListHeader *hdr, void(*func)(SharedInvalidationMessage *msg))
Definition: inval.c:456
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:556

◆ InvalidateSystemCaches()

void InvalidateSystemCaches ( void  )

Definition at line 643 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().

644 {
645  int i;
646 
649  RelationCacheInvalidate(); /* gets smgr and relmap too */
650 
651  for (i = 0; i < syscache_callback_count; i++)
652  {
653  struct SYSCACHECALLBACK *ccitem = syscache_callback_list + i;
654 
655  ccitem->function(ccitem->arg, ccitem->id, 0);
656  }
657 
658  for (i = 0; i < relcache_callback_count; i++)
659  {
660  struct RELCACHECALLBACK *ccitem = relcache_callback_list + i;
661 
662  ccitem->function(ccitem->arg, InvalidOid);
663  }
664 }
static struct RELCACHECALLBACK relcache_callback_list[MAX_RELCACHE_CALLBACKS]
static int relcache_callback_count
Definition: inval.c:211
RelcacheCallbackFunction function
Definition: inval.c:207
void InvalidateCatalogSnapshot(void)
Definition: snapmgr.c:512
static struct SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]
static int syscache_callback_count
Definition: inval.c:203
#define InvalidOid
Definition: postgres_ext.h:36
void ResetCatalogCaches(void)
Definition: catcache.c:689
void RelationCacheInvalidate(void)
Definition: relcache.c:2778
int i
SyscacheCallbackFunction function
Definition: inval.c:197

◆ PostPrepare_Inval()

void PostPrepare_Inval ( void  )

Definition at line 769 of file inval.c.

References AtEOXact_Inval().

Referenced by PrepareTransaction().

770 {
771  AtEOXact_Inval(false);
772 }
void AtEOXact_Inval(bool isCommit)
Definition: inval.c:949