1 /*-------------------------------------------------------------------------
4 * Low-level catalog cache definitions.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: catcache.h,v 1.6 1997/09/07 05:02:14 momjian Exp $
11 *-------------------------------------------------------------------------
16 /* #define CACHEDEBUG turns DEBUG elogs on */
18 #include <access/htup.h>
19 #include <lib/dllist.h>
20 #include <nodes/memnodes.h>
21 #include <utils/rel.h>
24 * struct catctup: tuples in the cache.
25 * struct catcache: information for managing a cache.
28 typedef struct catctup
30 HeapTuple ct_tup; /* A pointer to a tuple */
31 Dlelem *ct_node; /* points to LRU list is the CatCTup is in
32 * the cache, else, points to the cache if
33 * the CatCTup is in LRU list */
36 /* voodoo constants */
37 #define NCCBUCK 500 /* CatCache buckets */
38 #define MAXTUP 300 /* Maximum # of tuples cached per cache */
40 typedef struct catcache
44 char *cc_relname; /* relation name for defered open */
45 char *cc_indname; /* index name for defered open */
46 HeapTuple(*cc_iscanfunc) (); /* index scanfunction */
47 TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */
48 int id; /* XXX could be improved -hirohama */
49 short cc_ntup; /* # of tuples in this cache */
50 short cc_maxtup; /* max # of tuples allowed (LRU) */
55 ScanKeyData cc_skey[4];
56 struct catcache *cc_next;
57 Dllist *cc_lrulist; /* LRU list, most recent first */
58 Dllist *cc_cache[NCCBUCK + 1];
61 #define InvalidCatalogCacheId (-1)
63 extern struct catcache *Caches;
64 extern GlobalMemory CacheCxt;
67 CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
69 extern void ResetSystemCache(void);
71 InitSysCache(char *relname, char *indname, int id, int nkeys,
72 int key[], HeapTuple(*iScanfuncP) ());
74 SearchSysCache(struct catcache * cache, Datum v1, Datum v2,
77 RelationInvalidateCatalogCacheTuple(Relation relation,
78 HeapTuple tuple, void (*function) ());
80 #endif /* CATCACHE_H */