1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* catcache.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* Low-level catalog cache definitions.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* $Id: catcache.h,v 1.19 2000/01/26 05:58:37 momjian Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef CATCACHE_H
|
1996-08-28 03:59:28 +02:00
|
|
|
#define CATCACHE_H
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/* #define CACHEDEBUG turns DEBUG elogs on */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/htup.h"
|
|
|
|
#include "lib/dllist.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* struct catctup: tuples in the cache.
|
|
|
|
* struct catcache: information for managing a cache.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct catctup
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple ct_tup; /* A pointer to a tuple */
|
1999-06-04 04:19:47 +02:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
Dlelem *ct_node; /* the other catctup for this tuple */
|
1997-09-08 23:56:23 +02:00
|
|
|
} CatCTup;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* voodoo constants */
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NCCBUCK 500 /* CatCache buckets */
|
|
|
|
#define MAXTUP 300 /* Maximum # of tuples cached per cache */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct catcache
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Oid relationId;
|
|
|
|
Oid indexId;
|
|
|
|
char *cc_relname; /* relation name for defered open */
|
|
|
|
char *cc_indname; /* index name for defered open */
|
1997-09-08 23:56:23 +02:00
|
|
|
HeapTuple (*cc_iscanfunc) (); /* index scanfunction */
|
1997-09-08 04:41:22 +02:00
|
|
|
TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */
|
|
|
|
int id; /* XXX could be improved -hirohama */
|
1999-06-04 04:19:47 +02:00
|
|
|
bool busy; /* for detecting recursive lookups */
|
1997-09-08 04:41:22 +02:00
|
|
|
short cc_ntup; /* # of tuples in this cache */
|
|
|
|
short cc_maxtup; /* max # of tuples allowed (LRU) */
|
|
|
|
short cc_nkeys;
|
|
|
|
short cc_size;
|
|
|
|
short cc_key[4];
|
|
|
|
short cc_klen[4];
|
|
|
|
ScanKeyData cc_skey[4];
|
1997-09-07 07:04:48 +02:00
|
|
|
struct catcache *cc_next;
|
1997-09-08 04:41:22 +02:00
|
|
|
Dllist *cc_lrulist; /* LRU list, most recent first */
|
1999-06-04 04:19:47 +02:00
|
|
|
Dllist *cc_cache[NCCBUCK + 1]; /* hash buckets */
|
1997-09-08 23:56:23 +02:00
|
|
|
} CatCache;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define InvalidCatalogCacheId (-1)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
extern GlobalMemory CacheCxt;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
|
1997-09-07 07:04:48 +02:00
|
|
|
ItemPointer pointer);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void ResetSystemCache(void);
|
1998-02-23 18:44:24 +01:00
|
|
|
extern void SystemCacheRelationFlushed(Oid relId);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern CatCache *InitSysCache(char *relname, char *indname, int id, int nkeys,
|
1998-09-01 05:29:17 +02:00
|
|
|
int *key, HeapTuple (*iScanfuncP) ());
|
1998-09-01 06:40:42 +02:00
|
|
|
extern HeapTuple SearchSysCache(struct catcache * cache, Datum v1, Datum v2,
|
1997-09-07 07:04:48 +02:00
|
|
|
Datum v3, Datum v4);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void RelationInvalidateCatalogCacheTuple(Relation relation,
|
1997-09-07 07:04:48 +02:00
|
|
|
HeapTuple tuple, void (*function) ());
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* CATCACHE_H */
|