1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* catcache.h--
|
1997-09-07 07:04:48 +02:00
|
|
|
* Low-level catalog cache definitions.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
1998-02-26 05:46:47 +01:00
|
|
|
* $Id: catcache.h,v 1.11 1998/02/26 04:43:53 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
|
|
|
|
1996-11-04 08:59:39 +01:00
|
|
|
#include <access/htup.h>
|
1996-11-04 12:51:27 +01:00
|
|
|
#include <lib/dllist.h>
|
|
|
|
#include <nodes/memnodes.h>
|
|
|
|
#include <utils/rel.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 */
|
|
|
|
Dlelem *ct_node; /* points to LRU list is the CatCTup is in
|
1997-09-07 07:04:48 +02:00
|
|
|
* the cache, else, points to the cache if
|
|
|
|
* the CatCTup is in LRU list */
|
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 */
|
|
|
|
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 */
|
|
|
|
Dllist *cc_cache[NCCBUCK + 1];
|
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 struct catcache *Caches;
|
|
|
|
extern GlobalMemory CacheCxt;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-02-26 05:46:47 +01: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-02-26 05:46:47 +01:00
|
|
|
extern CatCache *
|
|
|
|
InitSysCache(char *relname, char *indname, int id, int nkeys,
|
1997-09-08 23:56:23 +02:00
|
|
|
int key[], HeapTuple (*iScanfuncP) ());
|
1998-02-26 05:46:47 +01:00
|
|
|
extern HeapTuple
|
|
|
|
SearchSysCache(struct catcache * cache, Datum v1, Datum v2,
|
1997-09-07 07:04:48 +02:00
|
|
|
Datum v3, Datum v4);
|
1998-02-26 05:46:47 +01: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
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#endif /* CATCACHE_H */
|