]> granicus.if.org Git - postgresql/blob - src/include/utils/catcache.h
Massive commit to run PGINDENT on all *.c and *.h files.
[postgresql] / src / include / utils / catcache.h
1 /*-------------------------------------------------------------------------
2  *
3  * catcache.h--
4  *        Low-level catalog cache definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: catcache.h,v 1.6 1997/09/07 05:02:14 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef CATCACHE_H
14 #define CATCACHE_H
15
16 /* #define              CACHEDEBUG               turns DEBUG elogs on */
17
18 #include <access/htup.h>
19 #include <lib/dllist.h>
20 #include <nodes/memnodes.h>
21 #include <utils/rel.h>
22
23 /*
24  *              struct catctup:                 tuples in the cache.
25  *              struct catcache:                information for managing a cache.
26  */
27
28 typedef struct catctup
29 {
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 */
34 }                               CatCTup;
35
36 /* voodoo constants */
37 #define NCCBUCK 500                             /* CatCache buckets */
38 #define MAXTUP 300                              /* Maximum # of tuples cached per cache */
39
40 typedef struct catcache
41 {
42         Oid                             relationId;
43         Oid                             indexId;
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) */
51         short                   cc_nkeys;
52         short                   cc_size;
53         short                   cc_key[4];
54         short                   cc_klen[4];
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];
59 }                               CatCache;
60
61 #define InvalidCatalogCacheId   (-1)
62
63 extern struct catcache *Caches;
64 extern GlobalMemory CacheCxt;
65
66 extern void
67 CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
68                                                  ItemPointer pointer);
69 extern void             ResetSystemCache(void);
70 extern CatCache *
71 InitSysCache(char *relname, char *indname, int id, int nkeys,
72                          int key[], HeapTuple(*iScanfuncP) ());
73 extern HeapTuple
74 SearchSysCache(struct catcache * cache, Datum v1, Datum v2,
75                            Datum v3, Datum v4);
76 extern void
77 RelationInvalidateCatalogCacheTuple(Relation relation,
78                                                                         HeapTuple tuple, void (*function) ());
79
80 #endif                                                  /* CATCACHE_H */