diff options
Diffstat (limited to 'src/include/utils/catcache.h')
-rw-r--r-- | src/include/utils/catcache.h | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 369dfd02c59..e55b6492d8c 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -3,11 +3,17 @@ * catcache.h * Low-level catalog cache definitions. * + * NOTE: every catalog cache must have a corresponding unique index on + * the system table that it caches --- ie, the index must match the keys + * used to do lookups in this cache. All cache fetches are done with + * indexscans (under normal conditions). The index should be unique to + * guarantee that there can only be one matching row for a key combination. + * * * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catcache.h,v 1.26 2000/08/06 04:16:40 tgl Exp $ + * $Id: catcache.h,v 1.27 2000/11/10 00:33:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,18 +26,7 @@ #include "lib/dllist.h" /* - * Functions that implement index scans for caches must match this signature - * (except we allow unused key arguments to be omitted --- is that really - * portable?) - */ -typedef HeapTuple (*ScanFunc) (Relation heapRelation, - Datum key1, - Datum key2, - Datum key3, - Datum key4); - -/* - * struct catctup: tuples in the cache. + * struct catctup: individual tuple in the cache. * struct catcache: information for managing a cache. */ @@ -53,22 +48,18 @@ typedef struct catctup typedef struct catcache { - Oid relationId; - Oid indexId; - char *cc_relname; /* relation name for defered open */ - char *cc_indname; /* index name for defered open */ - ScanFunc cc_iscanfunc; /* index scan function */ - TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */ - int id; /* XXX could be improved -hirohama */ - bool busy; /* for detecting recursive lookups */ - short cc_ntup; /* # of tuples in this cache */ + int id; /* cache identifier --- see syscache.h */ + struct catcache *cc_next; /* link to next catcache */ + char *cc_relname; /* name of relation the tuples come from */ + char *cc_indname; /* name of index matching cache keys */ + TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */ + short cc_ntup; /* # of tuples in this cache */ short cc_maxtup; /* max # of tuples allowed (LRU) */ - short cc_nkeys; - short cc_size; + short cc_size; /* # of hash buckets in this cache */ + short cc_nkeys; /* number of keys (1..4) */ short cc_key[4]; /* AttrNumber of each key */ PGFunction cc_hashfunc[4]; /* hash function to use for each key */ - ScanKeyData cc_skey[4]; - struct catcache *cc_next; + ScanKeyData cc_skey[4]; /* precomputed key info for indexscans */ Dllist *cc_lrulist; /* LRU list, most recent first */ Dllist *cc_cache[NCCBUCK + 1]; /* hash buckets */ } CatCache; @@ -79,17 +70,17 @@ typedef struct catcache extern MemoryContext CacheMemoryContext; extern void CreateCacheMemoryContext(void); -extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex, - ItemPointer pointer); -extern void ResetSystemCache(void); -extern void SystemCacheRelationFlushed(Oid relId); -extern void SystemCacheAbort(void); -extern CatCache *InitSysCache(char *relname, char *indname, int id, - int nkeys, int *key, - ScanFunc iScanfuncP); -extern HeapTuple SearchSysCache(CatCache * cache, + +extern CatCache *InitSysCache(int id, char *relname, char *indname, + int nkeys, int *key); +extern HeapTuple SearchSysCache(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4); + +extern void ResetSystemCache(void); +extern void SystemCacheRelationFlushed(Oid relId); +extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex, + ItemPointer pointer); extern void RelationInvalidateCatalogCacheTuple(Relation relation, HeapTuple tuple, void (*function) (int, Index, ItemPointer)); |