Commit 9cf80f2f authored by Tom Lane's avatar Tom Lane

Clean out another pocket of functions called via nonspecific function

pointers, namely the catcache tuple fetch routines.  Also get rid of
the unused and possibly confusing 'size' field in struct cachedesc.
Since it doesn't allow for variable-length fields, anyone who
actually trusted it would likely be making a mistake...
parent 1652d433
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.115 2000/06/15 03:32:02 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.116 2000/06/17 04:56:36 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -479,13 +479,13 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname) ...@@ -479,13 +479,13 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname)
/* XXX Natts_pg_class_fixed is a hack - see pg_class.h */ /* XXX Natts_pg_class_fixed is a hack - see pg_class.h */
tuple = heap_addheader(Natts_pg_class_fixed, tuple = heap_addheader(Natts_pg_class_fixed,
sizeof(*indexRelation->rd_rel), CLASS_TUPLE_SIZE,
(char *) indexRelation->rd_rel); (char *) indexRelation->rd_rel);
/* ---------------- /* ----------------
* the new tuple must have the same oid as the relcache entry for the * the new tuple must have the same oid as the relcache entry for the
* index. sure would be embarassing to do this sort of thing in polite * index. sure would be embarrassing to do this sort of thing in
* company. * polite company.
* ---------------- * ----------------
*/ */
tuple->t_data->t_oid = RelationGetRelid(indexRelation); tuple->t_data->t_oid = RelationGetRelid(indexRelation);
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.65 2000/06/05 07:28:53 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.66 2000/06/17 04:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
#include "utils/syscache.h" #include "utils/syscache.h"
static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e); static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP); static Index CatalogCacheComputeHashIndex(CatCache *cacheInP);
static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP, static Index CatalogCacheComputeTupleHashIndex(CatCache *cacheInOutP,
Relation relation, Relation relation,
HeapTuple tuple); HeapTuple tuple);
static void CatalogCacheInitializeCache(struct catcache * cache, static void CatalogCacheInitializeCache(CatCache *cache,
Relation relation); Relation relation);
static Datum cc_hashname(PG_FUNCTION_ARGS); static Datum cc_hashname(PG_FUNCTION_ARGS);
/* ---------------- /* ----------------
...@@ -168,7 +168,7 @@ do { \ ...@@ -168,7 +168,7 @@ do { \
#endif #endif
static void static void
CatalogCacheInitializeCache(struct catcache * cache, CatalogCacheInitializeCache(CatCache * cache,
Relation relation) Relation relation)
{ {
MemoryContext oldcxt; MemoryContext oldcxt;
...@@ -196,7 +196,7 @@ CatalogCacheInitializeCache(struct catcache * cache, ...@@ -196,7 +196,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
*/ */
if (!RelationIsValid(relation)) if (!RelationIsValid(relation))
{ {
struct catcache *cp; CatCache *cp;
/* ---------------- /* ----------------
* scan the caches to see if any other cache has opened the relation * scan the caches to see if any other cache has opened the relation
...@@ -307,7 +307,7 @@ CatalogCacheInitializeCache(struct catcache * cache, ...@@ -307,7 +307,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
* -------------------------------- * --------------------------------
*/ */
static Index static Index
CatalogCacheComputeHashIndex(struct catcache * cacheInP) CatalogCacheComputeHashIndex(CatCache * cacheInP)
{ {
uint32 hashIndex = 0; uint32 hashIndex = 0;
...@@ -351,7 +351,7 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP) ...@@ -351,7 +351,7 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP)
* -------------------------------- * --------------------------------
*/ */
static Index static Index
CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP, CatalogCacheComputeTupleHashIndex(CatCache * cacheInOutP,
Relation relation, Relation relation,
HeapTuple tuple) HeapTuple tuple)
{ {
...@@ -543,7 +543,7 @@ void ...@@ -543,7 +543,7 @@ void
ResetSystemCache() ResetSystemCache()
{ {
MemoryContext oldcxt; MemoryContext oldcxt;
struct catcache *cache; CatCache *cache;
CACHE1_elog(DEBUG, "ResetSystemCache called"); CACHE1_elog(DEBUG, "ResetSystemCache called");
...@@ -632,7 +632,7 @@ SystemCacheRelationFlushed(Oid relId) ...@@ -632,7 +632,7 @@ SystemCacheRelationFlushed(Oid relId)
} }
/* -------------------------------- /* --------------------------------
* InitIndexedSysCache * InitSysCache
* *
* This allocates and initializes a cache for a system catalog relation. * This allocates and initializes a cache for a system catalog relation.
* Actually, the cache is only partially initialized to avoid opening the * Actually, the cache is only partially initialized to avoid opening the
...@@ -666,7 +666,7 @@ InitSysCache(char *relname, ...@@ -666,7 +666,7 @@ InitSysCache(char *relname,
int id, int id,
int nkeys, int nkeys,
int *key, int *key,
HeapTuple (*iScanfuncP) ()) ScanFunc iScanfuncP)
{ {
CatCache *cp; CatCache *cp;
int i; int i;
...@@ -797,11 +797,11 @@ InitSysCache(char *relname, ...@@ -797,11 +797,11 @@ InitSysCache(char *relname,
* This code short-circuits the normal index lookup for cache loads * This code short-circuits the normal index lookup for cache loads
* in those cases and replaces it with a heap scan. * in those cases and replaces it with a heap scan.
* *
* cache should already be initailized * cache should already be initialized
* -------------------------------- * --------------------------------
*/ */
static HeapTuple static HeapTuple
SearchSelfReferences(struct catcache * cache) SearchSelfReferences(CatCache * cache)
{ {
HeapTuple ntp; HeapTuple ntp;
Relation rel; Relation rel;
...@@ -896,7 +896,7 @@ SearchSelfReferences(struct catcache * cache) ...@@ -896,7 +896,7 @@ SearchSelfReferences(struct catcache * cache)
* -------------------------------- * --------------------------------
*/ */
HeapTuple HeapTuple
SearchSysCache(struct catcache * cache, SearchSysCache(CatCache * cache,
Datum v1, Datum v1,
Datum v2, Datum v2,
Datum v3, Datum v3,
...@@ -1035,34 +1035,22 @@ SearchSysCache(struct catcache * cache, ...@@ -1035,34 +1035,22 @@ SearchSysCache(struct catcache * cache,
if ((RelationGetForm(relation))->relhasindex if ((RelationGetForm(relation))->relhasindex
&& !IsIgnoringSystemIndexes()) && !IsIgnoringSystemIndexes())
{ {
HeapTuple indextp;
/* ---------- /* ----------
* Switch back to old memory context so memory not freed * Switch back to old memory context so memory not freed
* in the scan function will go away at transaction end. * in the scan function will go away at transaction end.
* wieck - 10/18/1996 * wieck - 10/18/1996
* ---------- * ----------
*/ */
HeapTuple indextp;
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
Assert(cache->cc_iscanfunc);
switch (cache->cc_nkeys) /* We call the scanfunc with all four arguments to satisfy the
{ * declared prototype, even though the function will likely not
case 4: * use all four.
indextp = cache->cc_iscanfunc(relation, v1, v2, v3, v4); */
break; indextp = cache->cc_iscanfunc(relation, v1, v2, v3, v4);
case 3:
indextp = cache->cc_iscanfunc(relation, v1, v2, v3);
break;
case 2:
indextp = cache->cc_iscanfunc(relation, v1, v2);
break;
case 1:
indextp = cache->cc_iscanfunc(relation, v1);
break;
default:
indextp = NULL;
break;
}
/* ---------- /* ----------
* Back to Cache context. If we got a tuple copy it * Back to Cache context. If we got a tuple copy it
* into our context. wieck - 10/18/1996 * into our context. wieck - 10/18/1996
...@@ -1200,7 +1188,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation, ...@@ -1200,7 +1188,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
HeapTuple tuple, HeapTuple tuple,
void (*function) (int, Index, ItemPointer)) void (*function) (int, Index, ItemPointer))
{ {
struct catcache *ccp; CatCache *ccp;
MemoryContext oldcxt; MemoryContext oldcxt;
Oid relationId; Oid relationId;
...@@ -1251,6 +1239,4 @@ RelationInvalidateCatalogCacheTuple(Relation relation, ...@@ -1251,6 +1239,4 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
* ---------------- * ----------------
*/ */
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
/* sendpm('I', "Invalidated tuple"); */
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.99 2000/06/02 15:57:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.100 2000/06/17 04:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -344,12 +344,13 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) ...@@ -344,12 +344,13 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
switch (buildinfo.infotype) switch (buildinfo.infotype)
{ {
case INFO_RELID: case INFO_RELID:
return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id); return_tuple = ClassOidIndexScan(pg_class_desc,
ObjectIdGetDatum(buildinfo.i.info_id));
break; break;
case INFO_RELNAME: case INFO_RELNAME:
return_tuple = ClassNameIndexScan(pg_class_desc, return_tuple = ClassNameIndexScan(pg_class_desc,
buildinfo.i.info_name); PointerGetDatum(buildinfo.i.info_name));
break; break;
default: default:
...@@ -382,10 +383,17 @@ AllocateRelationDesc(Relation relation, u_int natts, ...@@ -382,10 +383,17 @@ AllocateRelationDesc(Relation relation, u_int natts,
Form_pg_class relationForm; Form_pg_class relationForm;
/* ---------------- /* ----------------
* allocate space for the relation tuple form * Copy the relation tuple form
*
* We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE.
* relacl is NOT stored in the relcache --- there'd be little point
* in it, since we don't copy the tuple's nullvalues bitmap and hence
* wouldn't know if the value is valid ... bottom line is that relacl
* *cannot* be retrieved from the relcache. Get it from the syscache
* if you need it.
* ---------------- * ----------------
*/ */
relationForm = (Form_pg_class) palloc(sizeof(FormData_pg_class)); relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
memcpy((char *) relationForm, (char *) relp, CLASS_TUPLE_SIZE); memcpy((char *) relationForm, (char *) relp, CLASS_TUPLE_SIZE);
...@@ -586,14 +594,16 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo, ...@@ -586,14 +594,16 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
bool columnDropped = false; bool columnDropped = false;
#endif /* _DROP_COLUMN_HACK__ */ #endif /* _DROP_COLUMN_HACK__ */
atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel, atttup = AttributeRelidNumIndexScan(attrel,
RelationGetRelid(relation), i); ObjectIdGetDatum(RelationGetRelid(relation)),
Int32GetDatum(i));
if (!HeapTupleIsValid(atttup)) if (!HeapTupleIsValid(atttup))
{ {
#ifdef _DROP_COLUMN_HACK__ #ifdef _DROP_COLUMN_HACK__
atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel, atttup = AttributeRelidNumIndexScan(attrel,
RelationGetRelid(relation), DROPPED_COLUMN_INDEX(i)); ObjectIdGetDatum(RelationGetRelid(relation)),
Int32GetDatum(DROPPED_COLUMN_INDEX(i)));
if (!HeapTupleIsValid(atttup)) if (!HeapTupleIsValid(atttup))
#endif /* _DROP_COLUMN_HACK__ */ #endif /* _DROP_COLUMN_HACK__ */
elog(ERROR, "cannot find attribute %d of relation %s", i, elog(ERROR, "cannot find attribute %d of relation %s", i,
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: indexing.h,v 1.39 2000/06/07 04:09:44 momjian Exp $ * $Id: indexing.h,v 1.40 2000/06/17 04:56:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "access/htup.h" #include "access/htup.h"
/* /*
* Some definitions for indices on pg_attribute * Number of indices that exist for each system catalog
*/ */
#define Num_pg_aggregate_indices 1 #define Num_pg_aggregate_indices 1
#define Num_pg_am_indices 1 #define Num_pg_am_indices 1
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#define Num_pg_trigger_indices 3 #define Num_pg_trigger_indices 3
#define Num_pg_type_indices 2 #define Num_pg_type_indices 2
/* /*
* Names of indices on system catalogs * Names of indices on system catalogs
*/ */
...@@ -109,56 +108,58 @@ extern char *IndexedCatalogNames[]; ...@@ -109,56 +108,58 @@ extern char *IndexedCatalogNames[];
/* /*
* indexing.c prototypes * indexing.c prototypes
*
* Functions for each index to perform the necessary scan on a cache miss.
*/ */
extern void CatalogOpenIndices(int nIndices, char **names, Relation *idescs); extern void CatalogOpenIndices(int nIndices, char **names, Relation *idescs);
extern void CatalogCloseIndices(int nIndices, Relation *idescs); extern void CatalogCloseIndices(int nIndices, Relation *idescs);
extern void CatalogIndexInsert(Relation *idescs, extern void CatalogIndexInsert(Relation *idescs, int nIndices,
int nIndices, Relation heapRelation, HeapTuple heapTuple);
Relation heapRelation,
HeapTuple heapTuple);
extern bool CatalogHasIndex(char *catName, Oid catId); extern bool CatalogHasIndex(char *catName, Oid catId);
/*
* Functions for each index to perform the necessary scan on a cache miss.
* All index-value arguments should be passed as Datum for portability!
*/
extern HeapTuple AccessMethodOpidIndexScan(Relation heapRelation, extern HeapTuple AccessMethodOpidIndexScan(Relation heapRelation,
Oid claid, Oid opopr, Oid opid); Datum claid, Datum opopr, Datum opid);
extern HeapTuple AccessMethodStrategyIndexScan(Relation heapRelation, extern HeapTuple AccessMethodStrategyIndexScan(Relation heapRelation,
Oid opid, Oid claid, int2 opstrategy); Datum opid, Datum claid, Datum opstrategy);
extern HeapTuple AggregateNameTypeIndexScan(Relation heapRelation, extern HeapTuple AggregateNameTypeIndexScan(Relation heapRelation,
char *aggName, Oid aggType); Datum aggName, Datum aggType);
extern HeapTuple AmNameIndexScan(Relation heapRelation, char *amName); extern HeapTuple AmNameIndexScan(Relation heapRelation, Datum amName);
extern HeapTuple AttributeRelidNameIndexScan(Relation heapRelation, extern HeapTuple AttributeRelidNameIndexScan(Relation heapRelation,
Oid relid, char *attname); Datum relid, Datum attname);
extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation, extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation,
Oid relid, AttrNumber attnum); Datum relid, Datum attnum);
extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName); extern HeapTuple ClassNameIndexScan(Relation heapRelation, Datum relName);
extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName); extern HeapTuple ClassNameIndexScan(Relation heapRelation, Datum relName);
extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId); extern HeapTuple ClassOidIndexScan(Relation heapRelation, Datum relId);
extern HeapTuple GroupNameIndexScan(Relation heapRelation, char *groName); extern HeapTuple GroupNameIndexScan(Relation heapRelation, Datum groName);
extern HeapTuple GroupSysidIndexScan(Relation heapRelation, int4 sysId); extern HeapTuple GroupSysidIndexScan(Relation heapRelation, Datum sysId);
extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Oid relid); extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Datum relid);
extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid, extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation,
int4 seqno); Datum relid, Datum seqno);
extern HeapTuple LanguageNameIndexScan(Relation heapRelation, char *lanName); extern HeapTuple LanguageNameIndexScan(Relation heapRelation, Datum lanName);
extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Oid lanId); extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Datum lanId);
extern HeapTuple ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName); extern HeapTuple ListenerPidRelnameIndexScan(Relation heapRelation,
extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Oid defType); Datum pid, Datum relName);
extern HeapTuple OpclassNameIndexScan(Relation heapRelation, char *opcName); extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Datum defType);
extern HeapTuple OpclassNameIndexScan(Relation heapRelation, Datum opcName);
extern HeapTuple OperatorNameIndexScan(Relation heapRelation, extern HeapTuple OperatorNameIndexScan(Relation heapRelation,
char *oprName, Oid oprLeft, Oid oprRight, char oprKind); Datum oprName, Datum oprLeft,
extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Oid oprId); Datum oprRight, Datum oprKind);
extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Datum oprId);
extern HeapTuple ProcedureNameIndexScan(Relation heapRelation, extern HeapTuple ProcedureNameIndexScan(Relation heapRelation,
char *procName, int2 nargs, Oid *argTypes); Datum procName, Datum nargs, Datum argTypes);
extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId); extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Datum procId);
extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Oid rewriteId); extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Datum rewriteId);
extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation, extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation,
char *ruleName); Datum ruleName);
extern HeapTuple ShadowNameIndexScan(Relation heapRelation, char *useName); extern HeapTuple ShadowNameIndexScan(Relation heapRelation, Datum useName);
extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, int4 sysId); extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, Datum sysId);
extern HeapTuple StatisticRelidAttnumIndexScan(Relation heapRelation, extern HeapTuple StatisticRelidAttnumIndexScan(Relation heapRelation,
Oid relId, AttrNumber attNum); Datum relId, Datum attNum);
extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName); extern HeapTuple TypeNameIndexScan(Relation heapRelation, Datum typeName);
extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId); extern HeapTuple TypeOidIndexScan(Relation heapRelation, Datum typeId);
......
...@@ -8,21 +8,16 @@ ...@@ -8,21 +8,16 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_class.h,v 1.37 2000/06/12 03:40:53 momjian Exp $ * $Id: pg_class.h,v 1.38 2000/06/17 04:56:31 tgl Exp $
* *
* NOTES * NOTES
* ``pg_relation'' is being replaced by ``pg_class''. currently
* we are only changing the name in the catalogs but someday the
* code will be changed too. -cim 2/26/90
* [it finally happens. -ay 11/5/94]
*
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
* information from the DATA() statements. * information from the DATA() statements.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef PG_RELATION_H #ifndef PG_CLASS_H
#define PG_RELATION_H #define PG_CLASS_H
/* ---------------- /* ----------------
* postgres.h contains the system type definintions and the * postgres.h contains the system type definintions and the
...@@ -37,18 +32,16 @@ ...@@ -37,18 +32,16 @@
* *
* Note: the #if 0, #endif around the BKI_BEGIN.. END block * Note: the #if 0, #endif around the BKI_BEGIN.. END block
* below keeps cpp from seeing what is meant for the * below keeps cpp from seeing what is meant for the
* genbki script: pg_relation is now called pg_class, but * genbki script
* only in the catalogs -cim 2/26/90
* ---------------- * ----------------
*/ */
/* ---------------- /* ----------------
* This structure is actually variable-length (the last attribute is * This structure is actually variable-length (the last attribute is
* a POSTGRES array). Hence, sizeof(FormData_pg_class) does not * a POSTGRES array). Hence, sizeof(FormData_pg_class) does not
* describe the fixed-length or actual size of the structure. * necessarily match the actual length of the structure. Furthermore
* FormData_pg_class.relacl may not be correctly aligned, either, * relacl may be a NULL field. Hence, you MUST use heap_getattr()
* if aclitem and struct varlena don't align together. Hence, * to get the relacl field ... and don't forget to check isNull.
* you MUST use heap_getattr() to get the relacl field.
* ---------------- * ----------------
*/ */
CATALOG(pg_class) BOOTSTRAP CATALOG(pg_class) BOOTSTRAP
...@@ -64,24 +57,26 @@ CATALOG(pg_class) BOOTSTRAP ...@@ -64,24 +57,26 @@ CATALOG(pg_class) BOOTSTRAP
bool relisshared; bool relisshared;
char relkind; char relkind;
int2 relnatts; int2 relnatts;
/* /*
* relnatts is the number of user attributes this class has. There * relnatts is the number of user attributes this class has. There
* must be exactly this many instances in Class pg_attribute for this * must be exactly this many instances in Class pg_attribute for this
* class which have attnum > 0 (= user attribute). * class that have attnum > 0 (= user attribute).
*/ */
int2 relchecks; /* # of CHECK constraints, not stored in int2 relchecks; /* # of CHECK constraints for class */
* db? */
int2 reltriggers; /* # of TRIGGERs */ int2 reltriggers; /* # of TRIGGERs */
int2 relukeys; /* # of Unique keys */ int2 relukeys; /* # of Unique keys */
int2 relfkeys; /* # of FOREIGN KEYs */ int2 relfkeys; /* # of FOREIGN KEYs */
int2 relrefs; /* # of references to this relation */ int2 relrefs; /* # of references to this rel (not used!) */
bool relhaspkey; /* has PRIMARY KEY */ bool relhaspkey; /* has PRIMARY KEY */
bool relhasrules; bool relhasrules; /* has associated rules */
bool relhassubclass; bool relhassubclass; /* has derived classes */
aclitem relacl[1]; /* this is here for the catalog */ /*
* relacl may or may not be present, see note above!
*/
aclitem relacl[1]; /* we declare this just for the catalog */
} FormData_pg_class; } FormData_pg_class;
/* Size of fixed part of pg_class tuples, not counting relacl or padding */
#define CLASS_TUPLE_SIZE \ #define CLASS_TUPLE_SIZE \
(offsetof(FormData_pg_class,relhassubclass) + sizeof(bool)) (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool))
...@@ -123,7 +118,7 @@ typedef FormData_pg_class *Form_pg_class; ...@@ -123,7 +118,7 @@ typedef FormData_pg_class *Form_pg_class;
#define Anum_pg_class_relrefs 16 #define Anum_pg_class_relrefs 16
#define Anum_pg_class_relhaspkey 17 #define Anum_pg_class_relhaspkey 17
#define Anum_pg_class_relhasrules 18 #define Anum_pg_class_relhasrules 18
#define Anum_pg_class_relhassubclass 19 #define Anum_pg_class_relhassubclass 19
#define Anum_pg_class_relacl 20 #define Anum_pg_class_relacl 20
/* ---------------- /* ----------------
...@@ -176,10 +171,10 @@ DESCR(""); ...@@ -176,10 +171,10 @@ DESCR("");
#define RELKIND_INDEX 'i' /* secondary index */ #define RELKIND_INDEX 'i' /* secondary index */
#define RELKIND_LOBJECT 'l' /* large objects */ #define RELKIND_LOBJECT 'l' /* large objects */
#define RELKIND_RELATION 'r' /* cataloged heap */ #define RELKIND_RELATION 'r' /* ordinary cataloged heap */
#define RELKIND_SPECIAL 's' /* special (non-heap) */ #define RELKIND_SPECIAL 's' /* special (non-heap) */
#define RELKIND_SEQUENCE 'S' /* SEQUENCE relation */ #define RELKIND_SEQUENCE 'S' /* SEQUENCE relation */
#define RELKIND_UNCATALOGED 'u' /* temporary heap */ #define RELKIND_UNCATALOGED 'u' /* temporary heap */
#define RELKIND_LONGVALUE 'v' /* moved off huge values */ #define RELKIND_LONGVALUE 'v' /* moved off huge values */
#endif /* PG_RELATION_H */ #endif /* PG_CLASS_H */
...@@ -7,18 +7,29 @@ ...@@ -7,18 +7,29 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: catcache.h,v 1.23 2000/06/15 03:33:10 momjian Exp $ * $Id: catcache.h,v 1.24 2000/06/17 04:56:29 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef CATCACHE_H #ifndef CATCACHE_H
#define CATCACHE_H #define CATCACHE_H
/* #define CACHEDEBUG turns DEBUG elogs on */ /* #define CACHEDEBUG */ /* turns DEBUG elogs on */
#include "access/htup.h" #include "access/htup.h"
#include "lib/dllist.h" #include "lib/dllist.h"
/*
* 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);
/* /*
* struct catctup: tuples in the cache. * struct catctup: tuples in the cache.
* struct catcache: information for managing a cache. * struct catcache: information for managing a cache.
...@@ -26,8 +37,7 @@ ...@@ -26,8 +37,7 @@
typedef struct catctup typedef struct catctup
{ {
HeapTuple ct_tup; /* A pointer to a tuple */ HeapTuple ct_tup; /* A pointer to a tuple */
/* /*
* Each tuple in the cache has two catctup items, one in the LRU list * 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 * and one in the hashbucket list for its hash value. ct_node in each
...@@ -38,7 +48,7 @@ typedef struct catctup ...@@ -38,7 +48,7 @@ typedef struct catctup
/* voodoo constants */ /* voodoo constants */
#define NCCBUCK 500 /* CatCache buckets */ #define NCCBUCK 500 /* CatCache buckets */
#define MAXTUP 300 /* Maximum # of tuples cached per cache */ #define MAXTUP 300 /* Maximum # of tuples stored per cache */
typedef struct catcache typedef struct catcache
...@@ -47,7 +57,7 @@ typedef struct catcache ...@@ -47,7 +57,7 @@ typedef struct catcache
Oid indexId; Oid indexId;
char *cc_relname; /* relation name for defered open */ char *cc_relname; /* relation name for defered open */
char *cc_indname; /* index name for defered open */ char *cc_indname; /* index name for defered open */
HeapTuple (*cc_iscanfunc) (); /* index scanfunction */ ScanFunc cc_iscanfunc; /* index scan function */
TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */ TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */
int id; /* XXX could be improved -hirohama */ int id; /* XXX could be improved -hirohama */
bool busy; /* for detecting recursive lookups */ bool busy; /* for detecting recursive lookups */
...@@ -71,11 +81,14 @@ extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex, ...@@ -71,11 +81,14 @@ extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
ItemPointer pointer); ItemPointer pointer);
extern void ResetSystemCache(void); extern void ResetSystemCache(void);
extern void SystemCacheRelationFlushed(Oid relId); extern void SystemCacheRelationFlushed(Oid relId);
extern CatCache *InitSysCache(char *relname, char *indname, int id, int nkeys, extern CatCache *InitSysCache(char *relname, char *indname, int id,
int *key, HeapTuple (*iScanfuncP) ()); int nkeys, int *key,
extern HeapTuple SearchSysCache(struct catcache * cache, Datum v1, Datum v2, ScanFunc iScanfuncP);
Datum v3, Datum v4); extern HeapTuple SearchSysCache(CatCache * cache,
Datum v1, Datum v2,
Datum v3, Datum v4);
extern void RelationInvalidateCatalogCacheTuple(Relation relation, extern void RelationInvalidateCatalogCacheTuple(Relation relation,
HeapTuple tuple, void (*function) ()); HeapTuple tuple,
void (*function) (int, Index, ItemPointer));
#endif /* CATCACHE_H */ #endif /* CATCACHE_H */
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: syscache.h,v 1.25 2000/04/12 17:16:55 momjian Exp $ * $Id: syscache.h,v 1.26 2000/06/17 04:56:29 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,17 +18,14 @@ ...@@ -18,17 +18,14 @@
#include "access/htup.h" #include "access/htup.h"
/* #define CACHEDEBUG *//* turns DEBUG elogs on */
/* /*
* Declarations for util/syscache.c. * Declarations for util/syscache.c.
* *
* SysCache identifiers. * SysCache identifiers.
* *
* The order of these must match the order * The order of these must match the order
* they are entered into the structure cacheinfo[] in syscache.c * they are entered into the structure cacheinfo[] in syscache.c.
* Keep them in alphabeticall order. * Keep them in alphabetical order.
*/ */
#define AGGNAME 0 #define AGGNAME 0
...@@ -60,30 +57,13 @@ ...@@ -60,30 +57,13 @@
#define TYPENAME 26 #define TYPENAME 26
#define TYPEOID 27 #define TYPEOID 27
/* ----------------
* struct cachedesc: information needed for a call to InitSysCache()
* ----------------
*/
struct cachedesc
{
char *name; /* this is Name so that we can initialize
* it */
int nkeys;
int key[4];
int size; /* sizeof(appropriate struct) */
char *indname; /* index relation for this cache, if
* exists */
HeapTuple (*iScanFunc) ();/* function to handle index scans */
};
extern void zerocaches(void); extern void zerocaches(void);
extern void InitCatalogCache(void); extern void InitCatalogCache(void);
extern HeapTuple SearchSysCacheTupleCopy(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4);
extern HeapTuple SearchSysCacheTuple(int cacheId, extern HeapTuple SearchSysCacheTuple(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4); Datum key1, Datum key2, Datum key3, Datum key4);
extern HeapTuple SearchSysCacheTupleCopy(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4);
extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup, extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
AttrNumber attributeNumber, AttrNumber attributeNumber, bool *isNull);
bool *isnull);
#endif /* SYSCACHE_H */ #endif /* SYSCACHE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment