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-08-06 06:17:47 +02:00
|
|
|
* $Id: catcache.h,v 1.26 2000/08/06 04:16:40 tgl 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
|
|
|
|
|
2000-06-17 06:56:39 +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
|
|
|
|
2000-06-17 06:56:39 +02:00
|
|
|
/*
|
|
|
|
* Functions that implement index scans for caches must match this signature
|
|
|
|
* (except we allow unused key arguments to be omitted --- is that really
|
|
|
|
* portable?)
|
|
|
|
*/
|
|
|
|
typedef HeapTuple (*ScanFunc) (Relation heapRelation,
|
|
|
|
Datum key1,
|
|
|
|
Datum key2,
|
|
|
|
Datum key3,
|
|
|
|
Datum key4);
|
|
|
|
|
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
|
|
|
|
{
|
2000-06-17 06:56:39 +02:00
|
|
|
HeapTuple ct_tup; /* A pointer to a tuple */
|
2000-04-12 19:17:23 +02:00
|
|
|
/*
|
|
|
|
* Each tuple in the cache has two catctup items, one in the LRU list
|
1999-06-04 04:19:47 +02:00
|
|
|
* 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 */
|
2000-06-17 06:56:39 +02:00
|
|
|
#define MAXTUP 300 /* Maximum # of tuples stored per cache */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-02-21 04:36:59 +01: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 */
|
2000-06-17 06:56:39 +02:00
|
|
|
ScanFunc cc_iscanfunc; /* index scan function */
|
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;
|
2000-02-21 04:36:59 +01:00
|
|
|
short cc_key[4]; /* AttrNumber of each key */
|
2000-06-05 09:29:25 +02:00
|
|
|
PGFunction cc_hashfunc[4]; /* hash function to use for each key */
|
1997-09-08 04:41:22 +02:00
|
|
|
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 */
|
2000-04-12 19:17:23 +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
|
|
|
|
2000-06-28 05:33:33 +02:00
|
|
|
/* this extern duplicates utils/memutils.h... */
|
|
|
|
extern MemoryContext CacheMemoryContext;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-06-28 05:33:33 +02:00
|
|
|
extern void CreateCacheMemoryContext(void);
|
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);
|
2000-08-06 06:17:47 +02:00
|
|
|
extern void SystemCacheAbort(void);
|
2000-06-17 06:56:39 +02:00
|
|
|
extern CatCache *InitSysCache(char *relname, char *indname, int id,
|
|
|
|
int nkeys, int *key,
|
|
|
|
ScanFunc iScanfuncP);
|
|
|
|
extern HeapTuple SearchSysCache(CatCache * cache,
|
|
|
|
Datum v1, Datum v2,
|
|
|
|
Datum v3, Datum v4);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void RelationInvalidateCatalogCacheTuple(Relation relation,
|
2000-06-17 06:56:39 +02:00
|
|
|
HeapTuple tuple,
|
|
|
|
void (*function) (int, Index, ItemPointer));
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* CATCACHE_H */
|