diff options
Diffstat (limited to 'src/include/utils')
-rw-r--r-- | src/include/utils/catcache.h | 36 | ||||
-rw-r--r-- | src/include/utils/lsyscache.h | 4 | ||||
-rw-r--r-- | src/include/utils/syscache.h | 20 |
3 files changed, 42 insertions, 18 deletions
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index e55b6492d8c..ed78284a478 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catcache.h,v 1.27 2000/11/10 00:33:12 tgl Exp $ + * $Id: catcache.h,v 1.28 2000/11/16 22:30:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -32,18 +32,29 @@ typedef struct catctup { - HeapTuple ct_tup; /* A pointer to a tuple */ + int ct_magic; /* for Assert checks */ +#define CT_MAGIC 0x57261502 + /* - * Each tuple in the cache has two catctup items, one in the LRU list - * and one in the hashbucket list for its hash value. ct_node in each - * one points to the other one. + * 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. + * + * A tuple marked "dead" must not be returned by subsequent searches. + * However, it won't be physically deleted from the cache until its + * refcount goes to zero. */ - Dlelem *ct_node; /* the other catctup for this tuple */ + Dlelem lrulist_elem; /* list member of global LRU list */ + Dlelem cache_elem; /* list member of per-bucket list */ + int refcount; /* number of active references */ + bool dead; /* dead but not yet removed? */ + HeapTupleData tuple; /* tuple management header */ } CatCTup; + /* voodoo constants */ #define NCCBUCK 500 /* CatCache buckets */ -#define MAXTUP 300 /* Maximum # of tuples stored per cache */ +#define MAXTUP 500 /* Maximum # of tuples stored per cache */ typedef struct catcache @@ -60,8 +71,8 @@ typedef struct catcache 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 indexscans */ - Dllist *cc_lrulist; /* LRU list, most recent first */ - Dllist *cc_cache[NCCBUCK + 1]; /* hash buckets */ + Dllist cc_lrulist; /* overall LRU list, most recent first */ + Dllist cc_cache[NCCBUCK]; /* hash buckets */ } CatCache; #define InvalidCatalogCacheId (-1) @@ -70,12 +81,15 @@ typedef struct catcache extern MemoryContext CacheMemoryContext; extern void CreateCacheMemoryContext(void); +extern void AtEOXact_CatCache(bool isCommit); -extern CatCache *InitSysCache(int id, char *relname, char *indname, +extern CatCache *InitCatCache(int id, char *relname, char *indname, int nkeys, int *key); -extern HeapTuple SearchSysCache(CatCache *cache, + +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); diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 516949d1de9..f8547baa884 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.26 2000/10/05 19:48:34 momjian Exp $ + * $Id: lsyscache.h,v 1.27 2000/11/16 22:30:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,6 @@ extern bool op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp); extern Oid op_hashjoinable(Oid opno, Oid ltype, Oid rtype); extern bool op_iscachable(Oid opno); -extern HeapTuple get_operator_tuple(Oid opno); extern Oid get_commutator(Oid opno); extern Oid get_negator(Oid opno); extern RegProcedure get_oprrest(Oid opno); @@ -39,6 +38,7 @@ extern bool func_iscachable(Oid funcid); extern char *get_rel_name(Oid relid); extern int16 get_typlen(Oid typid); extern bool get_typbyval(Oid typid); +extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval); extern Datum get_typdefault(Oid typid); #endif /* LSYSCACHE_H */ diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 5d17e8db44c..73abd53e134 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: syscache.h,v 1.26 2000/06/17 04:56:29 tgl Exp $ + * $Id: syscache.h,v 1.27 2000/11/16 22:30:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -57,12 +57,22 @@ #define TYPENAME 26 #define TYPEOID 27 -extern void zerocaches(void); extern void InitCatalogCache(void); -extern HeapTuple SearchSysCacheTuple(int cacheId, + +extern HeapTuple SearchSysCache(int cacheId, + Datum key1, Datum key2, Datum key3, Datum key4); +extern void ReleaseSysCache(HeapTuple tuple); + +/* convenience routines */ +extern HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4); -extern HeapTuple SearchSysCacheTupleCopy(int cacheId, - Datum key1, Datum key2, Datum key3, Datum key4); +extern Oid GetSysCacheOid(int cacheId, + Datum key1, Datum key2, Datum key3, Datum key4); + +/* macro for just probing for existence of a tuple via the syscache */ +#define SearchSysCacheExists(c,k1,k2,k3,k4) \ + OidIsValid(GetSysCacheOid(c,k1,k2,k3,k4)) + extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull); |