aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/storage/sinval.h56
-rw-r--r--src/include/storage/sinvaladt.h23
-rw-r--r--src/include/utils/catcache.h7
-rw-r--r--src/include/utils/inval.h9
4 files changed, 68 insertions, 27 deletions
diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h
index 93a10e72feb..7d43c645780 100644
--- a/src/include/storage/sinval.h
+++ b/src/include/storage/sinval.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sinval.h,v 1.18 2001/02/26 00:50:08 tgl Exp $
+ * $Id: sinval.h,v 1.19 2001/06/19 19:42:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,15 +17,61 @@
#include "storage/itemptr.h"
#include "storage/spin.h"
+
+/*
+ * We currently support two types of shared-invalidation messages: one that
+ * invalidates an entry in a catcache, and one that invalidates a relcache
+ * entry. More types could be added if needed. The message type is
+ * identified by the first "int16" field of the message struct. Zero or
+ * positive means a catcache inval message (and also serves as the catcache
+ * ID field). -1 means a relcache inval message. Other negative values
+ * are available to identify other inval message types.
+ *
+ * Shared-inval events are initially driven by detecting tuple inserts,
+ * updates and deletions in system catalogs (see RelationInvalidateHeapTuple
+ * and RelationMark4RollbackHeapTuple). Note that some system catalogs have
+ * multiple caches on them (with different indexes). On detecting a tuple
+ * invalidation in such a catalog, a separate catcache inval message must be
+ * generated for each of its caches. The catcache inval message carries the
+ * hash index for the target tuple, so that the catcache only needs to search
+ * one hash chain not all its chains. Of course this assumes that all the
+ * backends are using identical hashing code, but that should be OK.
+ */
+
+typedef struct
+{
+ int16 id; /* cache ID --- must be first */
+ uint16 hashIndex; /* hashchain index within this catcache */
+ Oid dbId; /* database ID, or 0 if a shared relation */
+ ItemPointerData tuplePtr; /* tuple identifier in cached relation */
+} SharedInvalCatcacheMsg;
+
+#define SHAREDINVALRELCACHE_ID (-1)
+
+typedef struct
+{
+ int16 id; /* type field --- must be first */
+ Oid dbId; /* database ID, or 0 if a shared relation */
+ Oid relId; /* relation ID */
+} SharedInvalRelcacheMsg;
+
+typedef union
+{
+ int16 id; /* type field --- must be first */
+ SharedInvalCatcacheMsg cc;
+ SharedInvalRelcacheMsg rc;
+} SharedInvalidationMessage;
+
+
extern SPINLOCK SInvalLock;
extern int SInvalShmemSize(int maxBackends);
extern void CreateSharedInvalidationState(int maxBackends);
extern void InitBackendSharedInvalidationState(void);
-extern void RegisterSharedInvalid(int cacheId, Index hashIndex,
- ItemPointer pointer);
-extern void InvalidateSharedInvalid(void (*invalFunction) (),
- void (*resetFunction) ());
+extern void SendSharedInvalidMessage(SharedInvalidationMessage *msg);
+extern void ReceiveSharedInvalidMessages(
+ void (*invalFunction) (SharedInvalidationMessage *msg),
+ void (*resetFunction) (void));
extern bool DatabaseHasActiveBackends(Oid databaseId, bool ignoreMyself);
extern bool TransactionIdIsInProgress(TransactionId xid);
diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h
index 22b073350df..606304ce317 100644
--- a/src/include/storage/sinvaladt.h
+++ b/src/include/storage/sinvaladt.h
@@ -7,15 +7,15 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sinvaladt.h,v 1.26 2001/03/22 04:01:09 momjian Exp $
+ * $Id: sinvaladt.h,v 1.27 2001/06/19 19:42:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef SINVALADT_H
#define SINVALADT_H
-#include "storage/itemptr.h"
#include "storage/shmem.h"
+#include "storage/sinval.h"
/*
* The shared cache invalidation manager is responsible for transmitting
@@ -45,6 +45,9 @@
* large so that we don't need to do this often. It must be a multiple of
* MAXNUMMESSAGES so that the existing circular-buffer entries don't need
* to be moved when we do it.
+ *
+ * The struct type SharedInvalidationMessage, defining the contents of
+ * a single message, is defined in sinval.h.
*/
@@ -61,15 +64,6 @@
#define MAXNUMMESSAGES 4096
#define MSGNUMWRAPAROUND (MAXNUMMESSAGES * 4096)
-/* The content of one shared-invalidation message */
-typedef struct SharedInvalidData
-{
- int cacheId; /* XXX */
- Index hashIndex;
- ItemPointerData pointerData;
-} SharedInvalidData;
-
-typedef SharedInvalidData *SharedInvalid;
/* Per-backend state in shared invalidation structure */
typedef struct ProcState
@@ -83,7 +77,6 @@ typedef struct ProcState
/* Shared cache invalidation memory segment */
typedef struct SISeg
{
-
/*
* General state information
*/
@@ -96,7 +89,7 @@ typedef struct SISeg
/*
* Circular buffer holding shared-inval messages
*/
- SharedInvalidData buffer[MAXNUMMESSAGES];
+ SharedInvalidationMessage buffer[MAXNUMMESSAGES];
/*
* Per-backend state info.
@@ -117,9 +110,9 @@ extern SISeg *shmInvalBuffer; /* pointer to the shared inval buffer */
extern void SIBufferInit(int maxBackends);
extern int SIBackendInit(SISeg *segP);
-extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidData *data);
+extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data);
extern int SIGetDataEntry(SISeg *segP, int backendId,
- SharedInvalidData *data);
+ SharedInvalidationMessage *data);
extern void SIDelExpiredDataEntries(SISeg *segP);
#endif /* SINVALADT_H */
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h
index a2d3064a8b9..6b7a656e010 100644
--- a/src/include/utils/catcache.h
+++ b/src/include/utils/catcache.h
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catcache.h,v 1.33 2001/06/18 03:35:07 tgl Exp $
+ * $Id: catcache.h,v 1.34 2001/06/19 19:42:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,6 +36,7 @@ typedef struct catcache
char *cc_relname; /* name of relation the tuples come from */
char *cc_indname; /* name of index matching cache keys */
int cc_reloidattr; /* AttrNumber of relation OID, or 0 */
+ bool cc_relisshared; /* is relation shared? */
TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */
int cc_ntup; /* # of tuples currently in this cache */
int cc_size; /* # of hash buckets in this cache */
@@ -98,7 +99,7 @@ extern void CatalogCacheFlushRelation(Oid relId);
extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
ItemPointer pointer);
extern void PrepareToInvalidateCacheTuple(Relation relation,
- HeapTuple tuple,
- void (*function) (int, Index, ItemPointer));
+ HeapTuple tuple,
+ void (*function) (int, Index, ItemPointer, Oid));
#endif /* CATCACHE_H */
diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h
index 7da14e51722..d6277e27e1b 100644
--- a/src/include/utils/inval.h
+++ b/src/include/utils/inval.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: inval.h,v 1.19 2001/01/24 19:43:28 momjian Exp $
+ * $Id: inval.h,v 1.20 2001/06/19 19:42:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,11 +16,12 @@
#include "access/htup.h"
-extern void DiscardInvalid(void);
-extern void RegisterInvalid(bool send);
+extern void AcceptInvalidationMessages(void);
-extern void ImmediateLocalInvalidation(bool send);
+extern void AtEOXactInvalidationMessages(bool isCommit);
+
+extern void CommandEndInvalidationMessages(bool isCommit);
extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple);