diff options
Diffstat (limited to 'src/include/storage')
| -rw-r--r-- | src/include/storage/sinval.h | 56 | ||||
| -rw-r--r-- | src/include/storage/sinvaladt.h | 23 |
2 files changed, 59 insertions, 20 deletions
diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h index 93a10e72fe..7d43c64578 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 22b073350d..606304ce31 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 */ |
