diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/utils/catcache.h | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index a2d99458a9d..a2d3064a8b9 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -13,32 +13,49 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catcache.h,v 1.32 2001/03/22 04:01:11 momjian Exp $ + * $Id: catcache.h,v 1.33 2001/06/18 03:35:07 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef CATCACHE_H #define CATCACHE_H - /* #define CACHEDEBUG *//* turns DEBUG elogs on */ - #include "access/htup.h" #include "lib/dllist.h" /* * struct catctup: individual tuple in the cache. * struct catcache: information for managing a cache. + * struct catcacheheader: information for managing all the caches. */ +typedef struct catcache +{ + 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 */ + int cc_reloidattr; /* AttrNumber of relation OID, or 0 */ + 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 */ + int cc_nkeys; /* number of keys (1..4) */ + int cc_key[4]; /* AttrNumber of each key */ + PGFunction cc_hashfunc[4]; /* hash function to use for each key */ + ScanKeyData cc_skey[4]; /* precomputed key info for heap scans */ + Dllist cc_bucket[1]; /* hash buckets --- VARIABLE LENGTH ARRAY */ +} CatCache; /* VARIABLE LENGTH STRUCT */ + + typedef struct catctup { int ct_magic; /* for Assert checks */ #define CT_MAGIC 0x57261502 - + CatCache *my_cache; /* link to owning catcache */ /* * Each tuple in a cache is a member of two lists: one lists all the - * elements in that cache in LRU order, and the other lists just the - * elements in one hashbucket, also in LRU order. + * elements in all the caches in LRU order, and the other lists just + * the elements in one hashbucket of one cache, also in LRU order. * * A tuple marked "dead" must not be returned by subsequent searches. * However, it won't be physically deleted from the cache until its @@ -52,30 +69,14 @@ typedef struct catctup } CatCTup; -/* voodoo constants */ -#define NCCBUCK 500 /* CatCache buckets */ -#define MAXTUP 500 /* Maximum # of tuples stored per cache */ - - -typedef struct catcache +typedef struct catcacheheader { - 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_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]; /* precomputed key info for heap scans */ - Dllist cc_lrulist; /* overall LRU list, most recent first */ - Dllist cc_cache[NCCBUCK]; /* hash buckets */ -} CatCache; + CatCache *ch_caches; /* head of list of CatCache structs */ + int ch_ntup; /* # of tuples in all caches */ + int ch_maxtup; /* max # of tuples allowed (LRU) */ + Dllist ch_lrulist; /* overall LRU list, most recent first */ +} CatCacheHeader; -#define InvalidCatalogCacheId (-1) /* this extern duplicates utils/memutils.h... */ extern MemoryContext CacheMemoryContext; @@ -84,15 +85,16 @@ extern void CreateCacheMemoryContext(void); extern void AtEOXact_CatCache(bool isCommit); extern CatCache *InitCatCache(int id, char *relname, char *indname, - int nkeys, int *key); + int reloidattr, + int nkeys, int *key); extern HeapTuple SearchCatCache(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4); extern void ReleaseCatCache(HeapTuple tuple); -extern void ResetSystemCache(void); -extern void SystemCacheRelationFlushed(Oid relId); +extern void ResetCatalogCaches(void); +extern void CatalogCacheFlushRelation(Oid relId); extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex, ItemPointer pointer); extern void PrepareToInvalidateCacheTuple(Relation relation, |
