aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/inval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache/inval.c')
-rw-r--r--src/backend/utils/cache/inval.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 40d79942d5e..0e383b32c84 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -48,6 +48,12 @@
* (XXX is it worth testing likewise for duplicate catcache flush entries?
* Probably not.)
*
+ * If a relcache flush is issued for a system relation that we preload
+ * from the relcache init file, we must also delete the init file so that
+ * it will be rebuilt during the next backend restart. The actual work of
+ * manipulating the init file is in relcache.c, but we keep track of the
+ * need for it here.
+ *
* All the request lists are kept in TopTransactionContext memory, since
* they need not live beyond the end of the current transaction.
*
@@ -56,7 +62,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.47 2001/11/16 23:30:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.48 2002/02/19 20:11:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -107,6 +113,8 @@ typedef struct InvalidationListHeader
*/
static InvalidationListHeader GlobalInvalidMsgs;
+static bool RelcacheInitFileInval; /* init file must be invalidated? */
+
/*
* head of invalidation message list for the current command
* eaten by AtCommit_LocalCache() in CommandCounterIncrement()
@@ -339,6 +347,13 @@ RegisterRelcacheInvalidation(Oid dbId, Oid relId)
dbId, relId);
AddRelcacheInvalidationMessage(&LocalInvalidMsgs,
dbId, relId);
+
+ /*
+ * If the relation being invalidated is one of those cached in the
+ * relcache init file, mark that we need to zap that file at commit.
+ */
+ if (RelationIdIsInInitFile(relId))
+ RelcacheInitFileInval = true;
}
/*
@@ -418,8 +433,8 @@ InvalidateSystemCaches(void)
/*
* PrepareForTupleInvalidation
- * Invoke functions for the tuple which register invalidation
- * of catalog/relation cache.
+ * Detect whether invalidation of this tuple implies invalidation
+ * of catalog/relation cache entries; if so, register inval events.
*/
static void
PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
@@ -525,8 +540,19 @@ AtEOXactInvalidationMessages(bool isCommit)
{
if (isCommit)
{
+ /*
+ * Relcache init file invalidation requires processing both
+ * before and after we send the SI messages. However, we need
+ * not do anything unless we committed.
+ */
+ if (RelcacheInitFileInval)
+ RelationCacheInitFileInvalidate(true);
+
ProcessInvalidationMessages(&GlobalInvalidMsgs,
SendSharedInvalidMessage);
+
+ if (RelcacheInitFileInval)
+ RelationCacheInitFileInvalidate(false);
}
else
{
@@ -534,6 +560,8 @@ AtEOXactInvalidationMessages(bool isCommit)
LocalExecuteInvalidationMessage);
}
+ RelcacheInitFileInval = false;
+
DiscardInvalidationMessages(&GlobalInvalidMsgs, false);
DiscardInvalidationMessages(&LocalInvalidMsgs, false);
DiscardInvalidationMessages(&RollbackMsgs, false);