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...
This commit is contained in:
Tom Lane 2000-06-17 04:56:39 +00:00
parent 1652d43358
commit 9cf80f2f55
9 changed files with 340 additions and 388 deletions

View File

@ -8,7 +8,7 @@
*
*
* 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
@ -479,13 +479,13 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname)
/* XXX Natts_pg_class_fixed is a hack - see pg_class.h */
tuple = heap_addheader(Natts_pg_class_fixed,
sizeof(*indexRelation->rd_rel),
CLASS_TUPLE_SIZE,
(char *) indexRelation->rd_rel);
/* ----------------
* 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
* company.
* index. sure would be embarrassing to do this sort of thing in
* polite company.
* ----------------
*/
tuple->t_data->t_oid = RelationGetRelid(indexRelation);

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.65 2000/06/15 03:32:02 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.66 2000/06/17 04:56:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -293,7 +293,8 @@ CatalogIndexFetchTuple(Relation heapRelation,
HeapTuple
AggregateNameTypeIndexScan(Relation heapRelation, char *aggName, Oid aggType)
AggregateNameTypeIndexScan(Relation heapRelation,
Datum aggName, Datum aggType)
{
Relation idesc;
ScanKeyData skey[2];
@ -303,13 +304,13 @@ AggregateNameTypeIndexScan(Relation heapRelation, char *aggName, Oid aggType)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(aggName));
aggName);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(aggType));
aggType);
idesc = index_openr(AggregateNameTypeIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
@ -320,7 +321,7 @@ AggregateNameTypeIndexScan(Relation heapRelation, char *aggName, Oid aggType)
HeapTuple
AmNameIndexScan(Relation heapRelation, char *amName)
AmNameIndexScan(Relation heapRelation, Datum amName)
{
Relation idesc;
ScanKeyData skey[1];
@ -330,7 +331,7 @@ AmNameIndexScan(Relation heapRelation, char *amName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(amName));
amName);
idesc = index_openr(AmNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -342,9 +343,9 @@ AmNameIndexScan(Relation heapRelation, char *amName)
HeapTuple
AccessMethodOpidIndexScan(Relation heapRelation,
Oid claid,
Oid opopr,
Oid opid)
Datum claid,
Datum opopr,
Datum opid)
{
Relation idesc;
ScanKeyData skey[3];
@ -354,33 +355,32 @@ AccessMethodOpidIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(claid));
claid);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(opopr));
opopr);
ScanKeyEntryInitialize(&skey[2],
(bits16) 0x0,
(AttrNumber) 3,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(opid));
opid);
idesc = index_openr(AccessMethodOpidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
index_close(idesc);
return tuple;
}
HeapTuple
AccessMethodStrategyIndexScan(Relation heapRelation,
Oid opid,
Oid claid,
int2 opstrategy)
Datum opid,
Datum claid,
Datum opstrategy)
{
Relation idesc;
ScanKeyData skey[3];
@ -390,33 +390,32 @@ AccessMethodStrategyIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(opid));
opid);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(claid));
claid);
ScanKeyEntryInitialize(&skey[2],
(bits16) 0x0,
(AttrNumber) 3,
(RegProcedure) F_INT2EQ,
Int16GetDatum(opstrategy));
opstrategy);
idesc = index_openr(AccessMethodStrategyIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
index_close(idesc);
return tuple;
}
HeapTuple
AttributeRelidNameIndexScan(Relation heapRelation,
Oid relid,
char *attname)
Datum relid,
Datum attname)
{
Relation idesc;
ScanKeyData skey[2];
@ -426,27 +425,26 @@ AttributeRelidNameIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relid));
relid);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_NAMEEQ,
NameGetDatum(attname));
attname);
idesc = index_openr(AttributeRelidNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
index_close(idesc);
return tuple;
}
HeapTuple
AttributeRelidNumIndexScan(Relation heapRelation,
Oid relid,
AttrNumber attnum)
Datum relid,
Datum attnum)
{
Relation idesc;
ScanKeyData skey[2];
@ -456,25 +454,24 @@ AttributeRelidNumIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relid));
relid);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_INT2EQ,
Int16GetDatum(attnum));
attnum);
idesc = index_openr(AttributeRelidNumIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
index_close(idesc);
return tuple;
}
HeapTuple
OpclassDeftypeIndexScan(Relation heapRelation, Oid defType)
OpclassDeftypeIndexScan(Relation heapRelation, Datum defType)
{
Relation idesc;
ScanKeyData skey[1];
@ -484,19 +481,18 @@ OpclassDeftypeIndexScan(Relation heapRelation, Oid defType)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(defType));
defType);
idesc = index_openr(OpclassDeftypeIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
OpclassNameIndexScan(Relation heapRelation, char *opcName)
OpclassNameIndexScan(Relation heapRelation, Datum opcName)
{
Relation idesc;
ScanKeyData skey[1];
@ -506,7 +502,7 @@ OpclassNameIndexScan(Relation heapRelation, char *opcName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(opcName));
opcName);
idesc = index_openr(OpclassNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -517,7 +513,7 @@ OpclassNameIndexScan(Relation heapRelation, char *opcName)
HeapTuple
GroupNameIndexScan(Relation heapRelation, char *groName)
GroupNameIndexScan(Relation heapRelation, Datum groName)
{
Relation idesc;
ScanKeyData skey[1];
@ -527,7 +523,7 @@ GroupNameIndexScan(Relation heapRelation, char *groName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(groName));
groName);
idesc = index_openr(GroupNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -538,7 +534,7 @@ GroupNameIndexScan(Relation heapRelation, char *groName)
HeapTuple
GroupSysidIndexScan(Relation heapRelation, int4 sysId)
GroupSysidIndexScan(Relation heapRelation, Datum sysId)
{
Relation idesc;
ScanKeyData skey[1];
@ -548,7 +544,7 @@ GroupSysidIndexScan(Relation heapRelation, int4 sysId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_INT4EQ,
Int32GetDatum(sysId));
sysId);
idesc = index_openr(GroupSysidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -559,7 +555,7 @@ GroupSysidIndexScan(Relation heapRelation, int4 sysId)
HeapTuple
IndexRelidIndexScan(Relation heapRelation, Oid relid)
IndexRelidIndexScan(Relation heapRelation, Datum relid)
{
Relation idesc;
ScanKeyData skey[1];
@ -569,21 +565,20 @@ IndexRelidIndexScan(Relation heapRelation, Oid relid)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relid));
relid);
idesc = index_openr(IndexRelidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
InheritsRelidSeqnoIndexScan(Relation heapRelation,
Oid relid,
int4 seqno)
Datum relid,
Datum seqno)
{
Relation idesc;
ScanKeyData skey[2];
@ -593,25 +588,24 @@ InheritsRelidSeqnoIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relid));
relid);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_INT4EQ,
Int32GetDatum(seqno));
seqno);
idesc = index_openr(InheritsRelidSeqnoIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
index_close(idesc);
return tuple;
}
HeapTuple
LanguageNameIndexScan(Relation heapRelation, char *lanName)
LanguageNameIndexScan(Relation heapRelation, Datum lanName)
{
Relation idesc;
ScanKeyData skey[1];
@ -621,7 +615,7 @@ LanguageNameIndexScan(Relation heapRelation, char *lanName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(lanName));
lanName);
idesc = index_openr(LanguageNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -632,7 +626,7 @@ LanguageNameIndexScan(Relation heapRelation, char *lanName)
HeapTuple
LanguageOidIndexScan(Relation heapRelation, Oid lanId)
LanguageOidIndexScan(Relation heapRelation, Datum lanId)
{
Relation idesc;
ScanKeyData skey[1];
@ -642,19 +636,19 @@ LanguageOidIndexScan(Relation heapRelation, Oid lanId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(lanId));
lanId);
idesc = index_openr(LanguageOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName)
ListenerPidRelnameIndexScan(Relation heapRelation,
Datum pid, Datum relName)
{
Relation idesc;
ScanKeyData skey[2];
@ -664,13 +658,13 @@ ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_INT4EQ,
Int32GetDatum(pid));
pid);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(relName));
relName);
idesc = index_openr(ListenerPidRelnameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
@ -682,10 +676,10 @@ ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName)
HeapTuple
OperatorNameIndexScan(Relation heapRelation,
char *oprName,
Oid oprLeft,
Oid oprRight,
char oprKind)
Datum oprName,
Datum oprLeft,
Datum oprRight,
Datum oprKind)
{
Relation idesc;
ScanKeyData skey[4];
@ -695,37 +689,36 @@ OperatorNameIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(oprName));
oprName);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(oprLeft));
oprLeft);
ScanKeyEntryInitialize(&skey[2],
(bits16) 0x0,
(AttrNumber) 3,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(oprRight));
oprRight);
ScanKeyEntryInitialize(&skey[3],
(bits16) 0x0,
(AttrNumber) 4,
(RegProcedure) F_CHAREQ,
CharGetDatum(oprKind));
oprKind);
idesc = index_openr(OperatorNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 4);
index_close(idesc);
return tuple;
}
HeapTuple
OperatorOidIndexScan(Relation heapRelation, Oid oprId)
OperatorOidIndexScan(Relation heapRelation, Datum oprId)
{
Relation idesc;
ScanKeyData skey[1];
@ -735,22 +728,21 @@ OperatorOidIndexScan(Relation heapRelation, Oid oprId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(oprId));
oprId);
idesc = index_openr(OperatorOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
ProcedureNameIndexScan(Relation heapRelation,
char *procName,
int2 nargs,
Oid *argTypes)
Datum procName,
Datum nargs,
Datum argTypes)
{
Relation idesc;
ScanKeyData skey[3];
@ -760,31 +752,30 @@ ProcedureNameIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(procName));
procName);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_INT2EQ,
Int16GetDatum(nargs));
nargs);
ScanKeyEntryInitialize(&skey[2],
(bits16) 0x0,
(AttrNumber) 3,
(RegProcedure) F_OIDVECTOREQ,
PointerGetDatum(argTypes));
argTypes);
idesc = index_openr(ProcedureNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
index_close(idesc);
return tuple;
}
HeapTuple
ProcedureOidIndexScan(Relation heapRelation, Oid procId)
ProcedureOidIndexScan(Relation heapRelation, Datum procId)
{
Relation idesc;
ScanKeyData skey[1];
@ -794,19 +785,18 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(procId));
procId);
idesc = index_openr(ProcedureOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
ClassNameIndexScan(Relation heapRelation, char *relName)
ClassNameIndexScan(Relation heapRelation, Datum relName)
{
Relation idesc;
ScanKeyData skey[1];
@ -816,7 +806,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(relName));
relName);
idesc = index_openr(ClassNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -827,7 +817,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
HeapTuple
ClassOidIndexScan(Relation heapRelation, Oid relId)
ClassOidIndexScan(Relation heapRelation, Datum relId)
{
Relation idesc;
ScanKeyData skey[1];
@ -837,19 +827,18 @@ ClassOidIndexScan(Relation heapRelation, Oid relId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relId));
relId);
idesc = index_openr(ClassOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
RewriteRulenameIndexScan(Relation heapRelation, char *ruleName)
RewriteRulenameIndexScan(Relation heapRelation, Datum ruleName)
{
Relation idesc;
ScanKeyData skey[1];
@ -859,7 +848,7 @@ RewriteRulenameIndexScan(Relation heapRelation, char *ruleName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(ruleName));
ruleName);
idesc = index_openr(RewriteRulenameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -870,7 +859,7 @@ RewriteRulenameIndexScan(Relation heapRelation, char *ruleName)
HeapTuple
RewriteOidIndexScan(Relation heapRelation, Oid rewriteId)
RewriteOidIndexScan(Relation heapRelation, Datum rewriteId)
{
Relation idesc;
ScanKeyData skey[1];
@ -880,19 +869,18 @@ RewriteOidIndexScan(Relation heapRelation, Oid rewriteId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(rewriteId));
rewriteId);
idesc = index_openr(RewriteOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
ShadowNameIndexScan(Relation heapRelation, char *useName)
ShadowNameIndexScan(Relation heapRelation, Datum useName)
{
Relation idesc;
ScanKeyData skey[1];
@ -902,7 +890,7 @@ ShadowNameIndexScan(Relation heapRelation, char *useName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(useName));
useName);
idesc = index_openr(ShadowNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -913,7 +901,7 @@ ShadowNameIndexScan(Relation heapRelation, char *useName)
HeapTuple
ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
ShadowSysidIndexScan(Relation heapRelation, Datum sysId)
{
Relation idesc;
ScanKeyData skey[1];
@ -923,7 +911,7 @@ ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_INT4EQ,
Int32GetDatum(sysId));
sysId);
idesc = index_openr(ShadowSysidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -935,8 +923,8 @@ ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
HeapTuple
StatisticRelidAttnumIndexScan(Relation heapRelation,
Oid relId,
AttrNumber attNum)
Datum relId,
Datum attNum)
{
Relation idesc;
ScanKeyData skey[2];
@ -946,25 +934,24 @@ StatisticRelidAttnumIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relId));
relId);
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_INT2EQ,
Int16GetDatum(attNum));
attNum);
idesc = index_openr(StatisticRelidAttnumIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
index_close(idesc);
return tuple;
}
HeapTuple
TypeNameIndexScan(Relation heapRelation, char *typeName)
TypeNameIndexScan(Relation heapRelation, Datum typeName)
{
Relation idesc;
ScanKeyData skey[1];
@ -974,19 +961,18 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(typeName));
typeName);
idesc = index_openr(TypeNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
TypeOidIndexScan(Relation heapRelation, Oid typeId)
TypeOidIndexScan(Relation heapRelation, Datum typeId)
{
Relation idesc;
ScanKeyData skey[1];
@ -996,12 +982,11 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(typeId));
typeId);
idesc = index_openr(TypeOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}

View File

@ -8,7 +8,7 @@
*
*
* 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 @@
#include "utils/syscache.h"
static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
static Index CatalogCacheComputeHashIndex(CatCache *cacheInP);
static Index CatalogCacheComputeTupleHashIndex(CatCache *cacheInOutP,
Relation relation,
HeapTuple tuple);
static void CatalogCacheInitializeCache(struct catcache * cache,
Relation relation);
static void CatalogCacheInitializeCache(CatCache *cache,
Relation relation);
static Datum cc_hashname(PG_FUNCTION_ARGS);
/* ----------------
@ -168,7 +168,7 @@ do { \
#endif
static void
CatalogCacheInitializeCache(struct catcache * cache,
CatalogCacheInitializeCache(CatCache * cache,
Relation relation)
{
MemoryContext oldcxt;
@ -196,7 +196,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
*/
if (!RelationIsValid(relation))
{
struct catcache *cp;
CatCache *cp;
/* ----------------
* scan the caches to see if any other cache has opened the relation
@ -307,7 +307,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
* --------------------------------
*/
static Index
CatalogCacheComputeHashIndex(struct catcache * cacheInP)
CatalogCacheComputeHashIndex(CatCache * cacheInP)
{
uint32 hashIndex = 0;
@ -351,7 +351,7 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP)
* --------------------------------
*/
static Index
CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
CatalogCacheComputeTupleHashIndex(CatCache * cacheInOutP,
Relation relation,
HeapTuple tuple)
{
@ -543,7 +543,7 @@ void
ResetSystemCache()
{
MemoryContext oldcxt;
struct catcache *cache;
CatCache *cache;
CACHE1_elog(DEBUG, "ResetSystemCache called");
@ -632,7 +632,7 @@ SystemCacheRelationFlushed(Oid relId)
}
/* --------------------------------
* InitIndexedSysCache
* InitSysCache
*
* This allocates and initializes a cache for a system catalog relation.
* Actually, the cache is only partially initialized to avoid opening the
@ -666,7 +666,7 @@ InitSysCache(char *relname,
int id,
int nkeys,
int *key,
HeapTuple (*iScanfuncP) ())
ScanFunc iScanfuncP)
{
CatCache *cp;
int i;
@ -797,11 +797,11 @@ InitSysCache(char *relname,
* This code short-circuits the normal index lookup for cache loads
* in those cases and replaces it with a heap scan.
*
* cache should already be initailized
* cache should already be initialized
* --------------------------------
*/
static HeapTuple
SearchSelfReferences(struct catcache * cache)
SearchSelfReferences(CatCache * cache)
{
HeapTuple ntp;
Relation rel;
@ -896,7 +896,7 @@ SearchSelfReferences(struct catcache * cache)
* --------------------------------
*/
HeapTuple
SearchSysCache(struct catcache * cache,
SearchSysCache(CatCache * cache,
Datum v1,
Datum v2,
Datum v3,
@ -1035,34 +1035,22 @@ SearchSysCache(struct catcache * cache,
if ((RelationGetForm(relation))->relhasindex
&& !IsIgnoringSystemIndexes())
{
HeapTuple indextp;
/* ----------
* Switch back to old memory context so memory not freed
* in the scan function will go away at transaction end.
* wieck - 10/18/1996
* ----------
*/
HeapTuple indextp;
MemoryContextSwitchTo(oldcxt);
Assert(cache->cc_iscanfunc);
switch (cache->cc_nkeys)
{
case 4:
indextp = cache->cc_iscanfunc(relation, v1, v2, v3, v4);
break;
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;
}
/* We call the scanfunc with all four arguments to satisfy the
* declared prototype, even though the function will likely not
* use all four.
*/
indextp = cache->cc_iscanfunc(relation, v1, v2, v3, v4);
/* ----------
* Back to Cache context. If we got a tuple copy it
* into our context. wieck - 10/18/1996
@ -1200,7 +1188,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
HeapTuple tuple,
void (*function) (int, Index, ItemPointer))
{
struct catcache *ccp;
CatCache *ccp;
MemoryContext oldcxt;
Oid relationId;
@ -1251,6 +1239,4 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
* ----------------
*/
MemoryContextSwitchTo(oldcxt);
/* sendpm('I', "Invalidated tuple"); */
}

View File

@ -8,7 +8,7 @@
*
*
* 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)
switch (buildinfo.infotype)
{
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;
case INFO_RELNAME:
return_tuple = ClassNameIndexScan(pg_class_desc,
buildinfo.i.info_name);
PointerGetDatum(buildinfo.i.info_name));
break;
default:
@ -382,10 +383,17 @@ AllocateRelationDesc(Relation relation, u_int natts,
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);
@ -586,14 +594,16 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
bool columnDropped = false;
#endif /* _DROP_COLUMN_HACK__ */
atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel,
RelationGetRelid(relation), i);
atttup = AttributeRelidNumIndexScan(attrel,
ObjectIdGetDatum(RelationGetRelid(relation)),
Int32GetDatum(i));
if (!HeapTupleIsValid(atttup))
{
#ifdef _DROP_COLUMN_HACK__
atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel,
RelationGetRelid(relation), DROPPED_COLUMN_INDEX(i));
atttup = AttributeRelidNumIndexScan(attrel,
ObjectIdGetDatum(RelationGetRelid(relation)),
Int32GetDatum(DROPPED_COLUMN_INDEX(i)));
if (!HeapTupleIsValid(atttup))
#endif /* _DROP_COLUMN_HACK__ */
elog(ERROR, "cannot find attribute %d of relation %s", i,

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.53 2000/06/07 04:09:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.54 2000/06/17 04:56:33 tgl Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
@ -20,9 +20,11 @@
*/
#include "postgres.h"
#include "utils/builtins.h"
#include "access/heapam.h"
#include "access/transam.h"
#include "utils/builtins.h"
#include "catalog/catname.h"
#include "catalog/indexing.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_group.h"
@ -38,16 +40,10 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "utils/catcache.h"
#include "utils/syscache.h"
#include "utils/temprel.h"
#include "miscadmin.h"
extern bool AMI_OVERRIDE; /* XXX style */
#include "utils/syscache.h"
#include "catalog/indexing.h"
typedef HeapTuple (*ScanFunc) ();
/*---------------------------------------------------------------------------
@ -59,19 +55,18 @@ typedef HeapTuple (*ScanFunc) ();
Add your entry to the cacheinfo[] array below. All cache lists are
alphabetical, so add it in the proper place. Specify the relation
name, number of arguments, argument names, size of tuple, index lookup
function, and index name.
name, number of arguments, argument attribute numbers, index name,
and index lookup function.
In include/catalog/indexing.h, add a define for the number of indexes
in the relation, add a define for the index name, add an extern
on the relation, add define(s) for the index name(s), add an extern
array to hold the index names, define the index lookup function
prototype, and use DECLARE_UNIQUE_INDEX to define the index. Cache
lookups return only one row, so the index should be unique.
In backend/catalog/indexing.c, initialize the relation array with
the index names for the relation, fixed size of relation (or marking
first non-fixed length field), and create the index lookup function.
Pick one that has similar arguments and use that one, but keep the
the index names for the relation, and create the index lookup function.
Pick one that has similar arguments and copy that one, but keep the
function names in the same order as the cache list for clarity.
Finally, any place your relation gets heap_insert() or
@ -83,6 +78,19 @@ typedef HeapTuple (*ScanFunc) ();
---------------------------------------------------------------------------
*/
/* ----------------
* struct cachedesc: information defining a single syscache
* ----------------
*/
struct cachedesc
{
char *name; /* name of the relation being cached */
int nkeys; /* # of keys needed for cache lookup */
int key[4]; /* attribute numbers of key attrs */
char *indname; /* name of index relation for this cache */
ScanFunc iScanFunc; /* function to handle index scans */
};
static struct cachedesc cacheinfo[] = {
{AggregateRelationName, /* AGGNAME */
2,
@ -92,9 +100,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_aggregate, agginitval1),
AggregateNameTypeIndex,
AggregateNameTypeIndexScan},
AggregateNameTypeIndex,
(ScanFunc) AggregateNameTypeIndexScan},
{AccessMethodRelationName, /* AMNAME */
1,
{
@ -103,9 +110,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_am),
AmNameIndex,
AmNameIndexScan},
AmNameIndex,
(ScanFunc) AmNameIndexScan},
{AccessMethodOperatorRelationName, /* AMOPOPID */
3,
{
@ -114,9 +120,8 @@ static struct cachedesc cacheinfo[] = {
Anum_pg_amop_amopid,
0
},
sizeof(FormData_pg_amop),
AccessMethodOpidIndex,
AccessMethodOpidIndexScan},
AccessMethodOpidIndex,
(ScanFunc) AccessMethodOpidIndexScan},
{AccessMethodOperatorRelationName, /* AMOPSTRATEGY */
3,
{
@ -125,8 +130,7 @@ static struct cachedesc cacheinfo[] = {
Anum_pg_amop_amopstrategy,
0
},
sizeof(FormData_pg_amop),
AccessMethodStrategyIndex,
AccessMethodStrategyIndex,
(ScanFunc) AccessMethodStrategyIndexScan},
{AttributeRelationName, /* ATTNAME */
2,
@ -136,9 +140,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
ATTRIBUTE_TUPLE_SIZE,
AttributeRelidNameIndex,
AttributeRelidNameIndexScan},
AttributeRelidNameIndex,
(ScanFunc) AttributeRelidNameIndexScan},
{AttributeRelationName, /* ATTNUM */
2,
{
@ -147,8 +150,7 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
ATTRIBUTE_TUPLE_SIZE,
AttributeRelidNumIndex,
AttributeRelidNumIndex,
(ScanFunc) AttributeRelidNumIndexScan},
{OperatorClassRelationName, /* CLADEFTYPE */
1,
@ -158,9 +160,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_opclass),
OpclassDeftypeIndex,
OpclassDeftypeIndexScan},
OpclassDeftypeIndex,
(ScanFunc) OpclassDeftypeIndexScan},
{OperatorClassRelationName, /* CLANAME */
1,
{
@ -169,9 +170,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_opclass),
OpclassNameIndex,
OpclassNameIndexScan},
OpclassNameIndex,
(ScanFunc) OpclassNameIndexScan},
{GroupRelationName, /* GRONAME */
1,
{
@ -180,9 +180,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_group, grolist[0]),
GroupNameIndex,
GroupNameIndexScan},
GroupNameIndex,
(ScanFunc) GroupNameIndexScan},
{GroupRelationName, /* GROSYSID */
1,
{
@ -191,9 +190,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_group, grolist[0]),
GroupSysidIndex,
GroupSysidIndexScan},
GroupSysidIndex,
(ScanFunc) GroupSysidIndexScan},
{IndexRelationName, /* INDEXRELID */
1,
{
@ -202,9 +200,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_index, indpred),
IndexRelidIndex,
IndexRelidIndexScan},
IndexRelidIndex,
(ScanFunc) IndexRelidIndexScan},
{InheritsRelationName, /* INHRELID */
2,
{
@ -213,9 +210,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_inherits),
InheritsRelidSeqnoIndex,
InheritsRelidSeqnoIndexScan},
InheritsRelidSeqnoIndex,
(ScanFunc) InheritsRelidSeqnoIndexScan},
{LanguageRelationName, /* LANGNAME */
1,
{
@ -224,9 +220,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_language, lancompiler),
LanguageNameIndex,
LanguageNameIndexScan},
LanguageNameIndex,
(ScanFunc) LanguageNameIndexScan},
{LanguageRelationName, /* LANGOID */
1,
{
@ -235,9 +230,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_language, lancompiler),
LanguageOidIndex,
LanguageOidIndexScan},
LanguageOidIndex,
(ScanFunc) LanguageOidIndexScan},
{ListenerRelationName, /* LISTENREL */
2,
{
@ -246,9 +240,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_listener),
ListenerPidRelnameIndex,
ListenerPidRelnameIndexScan},
ListenerPidRelnameIndex,
(ScanFunc) ListenerPidRelnameIndexScan},
{OperatorRelationName, /* OPERNAME */
4,
{
@ -257,8 +250,7 @@ static struct cachedesc cacheinfo[] = {
Anum_pg_operator_oprright,
Anum_pg_operator_oprkind
},
sizeof(FormData_pg_operator),
OperatorNameIndex,
OperatorNameIndex,
(ScanFunc) OperatorNameIndexScan},
{OperatorRelationName, /* OPEROID */
1,
@ -268,9 +260,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_operator),
OperatorOidIndex,
OperatorOidIndexScan},
OperatorOidIndex,
(ScanFunc) OperatorOidIndexScan},
{ProcedureRelationName, /* PROCNAME */
3,
{
@ -279,8 +270,7 @@ static struct cachedesc cacheinfo[] = {
Anum_pg_proc_proargtypes,
0
},
offsetof(FormData_pg_proc, prosrc),
ProcedureNameIndex,
ProcedureNameIndex,
(ScanFunc) ProcedureNameIndexScan},
{ProcedureRelationName, /* PROCOID */
1,
@ -290,9 +280,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_proc, prosrc),
ProcedureOidIndex,
ProcedureOidIndexScan},
ProcedureOidIndex,
(ScanFunc) ProcedureOidIndexScan},
{RelationRelationName, /* RELNAME */
1,
{
@ -301,9 +290,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
CLASS_TUPLE_SIZE,
ClassNameIndex,
ClassNameIndexScan},
ClassNameIndex,
(ScanFunc) ClassNameIndexScan},
{RelationRelationName, /* RELOID */
1,
{
@ -312,9 +300,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
CLASS_TUPLE_SIZE,
ClassOidIndex,
ClassOidIndexScan},
ClassOidIndex,
(ScanFunc) ClassOidIndexScan},
{RewriteRelationName, /* REWRITENAME */
1,
{
@ -323,9 +310,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_rewrite, ev_qual),
RewriteRulenameIndex,
RewriteRulenameIndexScan},
RewriteRulenameIndex,
(ScanFunc) RewriteRulenameIndexScan},
{RewriteRelationName, /* RULEOID */
1,
{
@ -334,9 +320,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_rewrite, ev_qual),
RewriteOidIndex,
RewriteOidIndexScan},
RewriteOidIndex,
(ScanFunc) RewriteOidIndexScan},
{ShadowRelationName, /* SHADOWNAME */
1,
{
@ -345,9 +330,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_shadow),
ShadowNameIndex,
ShadowNameIndexScan},
ShadowNameIndex,
(ScanFunc) ShadowNameIndexScan},
{ShadowRelationName, /* SHADOWSYSID */
1,
{
@ -356,9 +340,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
sizeof(FormData_pg_shadow),
ShadowSysidIndex,
ShadowSysidIndexScan},
ShadowSysidIndex,
(ScanFunc) ShadowSysidIndexScan},
{StatisticRelationName, /* STATRELID */
2,
{
@ -367,8 +350,7 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_statistic, stacommonval),
StatisticRelidAttnumIndex,
StatisticRelidAttnumIndex,
(ScanFunc) StatisticRelidAttnumIndexScan},
{TypeRelationName, /* TYPENAME */
1,
@ -378,9 +360,8 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_type, typalign) +sizeof(char),
TypeNameIndex,
TypeNameIndexScan},
TypeNameIndex,
(ScanFunc) TypeNameIndexScan},
{TypeRelationName, /* TYPEOID */
1,
{
@ -389,16 +370,16 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_type, typalign) +sizeof(char),
TypeOidIndex,
TypeOidIndexScan}
TypeOidIndex,
(ScanFunc) TypeOidIndexScan}
};
static struct catcache *SysCache[
lengthof(cacheinfo)];
static CatCache *SysCache[lengthof(cacheinfo)];
static int32 SysCacheSize = lengthof(cacheinfo);
static bool CacheInitialized = false;
extern bool
bool
IsCacheInitialized(void)
{
return CacheInitialized;
@ -413,14 +394,12 @@ IsCacheInitialized(void)
void
zerocaches()
{
MemSet((char *) SysCache, 0, SysCacheSize * sizeof(struct catcache *));
MemSet((char *) SysCache, 0, SysCacheSize * sizeof(CatCache *));
}
/*
* Note:
* This function was written because the initialized catalog caches
* are used to determine which caches may contain tuples which need
* to be invalidated in other backends.
* InitCatalogCache - initialize the caches
*/
void
InitCatalogCache()
@ -431,8 +410,7 @@ InitCatalogCache()
{
for (cacheId = 0; cacheId < SysCacheSize; cacheId += 1)
{
Assert(!PointerIsValid((Pointer) SysCache[cacheId]));
Assert(!PointerIsValid(SysCache[cacheId]));
SysCache[cacheId] = InitSysCache(cacheinfo[cacheId].name,
cacheinfo[cacheId].indname,
@ -440,10 +418,10 @@ InitCatalogCache()
cacheinfo[cacheId].nkeys,
cacheinfo[cacheId].key,
cacheinfo[cacheId].iScanFunc);
if (!PointerIsValid((char *) SysCache[cacheId]))
if (!PointerIsValid(SysCache[cacheId]))
{
elog(ERROR,
"InitCatalogCache: Can't init cache %s(%d)",
"InitCatalogCache: Can't init cache %s (%d)",
cacheinfo[cacheId].name,
cacheId);
}
@ -453,30 +431,6 @@ InitCatalogCache()
CacheInitialized = true;
}
/*
* SearchSysCacheTupleCopy
*
* This is like SearchSysCacheTuple, except it returns a palloc'd copy of
* the tuple. The caller should heap_freetuple() the returned copy when
* done with it. This routine should be used when the caller intends to
* continue to access the tuple for more than a very short period of time.
*/
HeapTuple
SearchSysCacheTupleCopy(int cacheId, /* cache selection code */
Datum key1,
Datum key2,
Datum key3,
Datum key4)
{
HeapTuple cachetup;
cachetup = SearchSysCacheTuple(cacheId, key1, key2, key3, key4);
if (PointerIsValid(cachetup))
return heap_copytuple(cachetup);
else
return cachetup; /* NULL */
}
/*
* SearchSysCacheTuple
@ -492,6 +446,9 @@ SearchSysCacheTupleCopy(int cacheId, /* cache selection code */
* CAUTION: The returned tuple may be flushed from the cache during
* subsequent cache lookup operations, or by shared cache invalidation.
* Callers should not expect the pointer to remain valid for long.
*
* XXX we ought to have some kind of referencecount mechanism for
* cache entries, to ensure entries aren't deleted while in use.
*/
HeapTuple
SearchSysCacheTuple(int cacheId,/* cache selection code */
@ -550,6 +507,31 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */
}
/*
* SearchSysCacheTupleCopy
*
* This is like SearchSysCacheTuple, except it returns a palloc'd copy of
* the tuple. The caller should heap_freetuple() the returned copy when
* done with it. This routine should be used when the caller intends to
* continue to access the tuple for more than a very short period of time.
*/
HeapTuple
SearchSysCacheTupleCopy(int cacheId, /* cache selection code */
Datum key1,
Datum key2,
Datum key3,
Datum key4)
{
HeapTuple cachetup;
cachetup = SearchSysCacheTuple(cacheId, key1, key2, key3, key4);
if (PointerIsValid(cachetup))
return heap_copytuple(cachetup);
else
return cachetup; /* NULL */
}
/*
* SysCacheGetAttr
*
@ -569,13 +551,13 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */
Datum
SysCacheGetAttr(int cacheId, HeapTuple tup,
AttrNumber attributeNumber,
bool *isnull)
bool *isNull)
{
/*
* We just need to get the TupleDesc out of the cache entry, and then
* we can apply heap_getattr(). We expect that the cache control data
* is currently valid --- if the caller just fetched the tuple, then
* is currently valid --- if the caller recently fetched the tuple, then
* it should be.
*/
if (cacheId < 0 || cacheId >= SysCacheSize)
@ -587,5 +569,5 @@ SysCacheGetAttr(int cacheId, HeapTuple tup,
return heap_getattr(tup, attributeNumber,
SysCache[cacheId]->cc_tupdesc,
isnull);
isNull);
}

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 @@
#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_am_indices 1
@ -42,7 +42,6 @@
#define Num_pg_trigger_indices 3
#define Num_pg_type_indices 2
/*
* Names of indices on system catalogs
*/
@ -109,56 +108,58 @@ extern char *IndexedCatalogNames[];
/*
* 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 CatalogCloseIndices(int nIndices, Relation *idescs);
extern void CatalogIndexInsert(Relation *idescs,
int nIndices,
Relation heapRelation,
HeapTuple heapTuple);
extern void CatalogIndexInsert(Relation *idescs, int nIndices,
Relation heapRelation, HeapTuple heapTuple);
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,
Oid claid, Oid opopr, Oid opid);
Datum claid, Datum opopr, Datum opid);
extern HeapTuple AccessMethodStrategyIndexScan(Relation heapRelation,
Oid opid, Oid claid, int2 opstrategy);
Datum opid, Datum claid, Datum opstrategy);
extern HeapTuple AggregateNameTypeIndexScan(Relation heapRelation,
char *aggName, Oid aggType);
extern HeapTuple AmNameIndexScan(Relation heapRelation, char *amName);
Datum aggName, Datum aggType);
extern HeapTuple AmNameIndexScan(Relation heapRelation, Datum amName);
extern HeapTuple AttributeRelidNameIndexScan(Relation heapRelation,
Oid relid, char *attname);
Datum relid, Datum attname);
extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation,
Oid relid, AttrNumber attnum);
extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName);
extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName);
extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId);
extern HeapTuple GroupNameIndexScan(Relation heapRelation, char *groName);
extern HeapTuple GroupSysidIndexScan(Relation heapRelation, int4 sysId);
extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Oid relid);
extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid,
int4 seqno);
extern HeapTuple LanguageNameIndexScan(Relation heapRelation, char *lanName);
extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Oid lanId);
extern HeapTuple ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName);
extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Oid defType);
extern HeapTuple OpclassNameIndexScan(Relation heapRelation, char *opcName);
Datum relid, Datum attnum);
extern HeapTuple ClassNameIndexScan(Relation heapRelation, Datum relName);
extern HeapTuple ClassNameIndexScan(Relation heapRelation, Datum relName);
extern HeapTuple ClassOidIndexScan(Relation heapRelation, Datum relId);
extern HeapTuple GroupNameIndexScan(Relation heapRelation, Datum groName);
extern HeapTuple GroupSysidIndexScan(Relation heapRelation, Datum sysId);
extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Datum relid);
extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation,
Datum relid, Datum seqno);
extern HeapTuple LanguageNameIndexScan(Relation heapRelation, Datum lanName);
extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Datum lanId);
extern HeapTuple ListenerPidRelnameIndexScan(Relation heapRelation,
Datum pid, Datum relName);
extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Datum defType);
extern HeapTuple OpclassNameIndexScan(Relation heapRelation, Datum opcName);
extern HeapTuple OperatorNameIndexScan(Relation heapRelation,
char *oprName, Oid oprLeft, Oid oprRight, char oprKind);
extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Oid oprId);
Datum oprName, Datum oprLeft,
Datum oprRight, Datum oprKind);
extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Datum oprId);
extern HeapTuple ProcedureNameIndexScan(Relation heapRelation,
char *procName, int2 nargs, Oid *argTypes);
extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId);
extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Oid rewriteId);
Datum procName, Datum nargs, Datum argTypes);
extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Datum procId);
extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Datum rewriteId);
extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation,
char *ruleName);
extern HeapTuple ShadowNameIndexScan(Relation heapRelation, char *useName);
extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, int4 sysId);
Datum ruleName);
extern HeapTuple ShadowNameIndexScan(Relation heapRelation, Datum useName);
extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, Datum sysId);
extern HeapTuple StatisticRelidAttnumIndexScan(Relation heapRelation,
Oid relId, AttrNumber attNum);
extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName);
extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId);
Datum relId, Datum attNum);
extern HeapTuple TypeNameIndexScan(Relation heapRelation, Datum typeName);
extern HeapTuple TypeOidIndexScan(Relation heapRelation, Datum typeId);

View File

@ -8,21 +8,16 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
* ``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
* information from the DATA() statements.
*
*-------------------------------------------------------------------------
*/
#ifndef PG_RELATION_H
#define PG_RELATION_H
#ifndef PG_CLASS_H
#define PG_CLASS_H
/* ----------------
* postgres.h contains the system type definintions and the
@ -37,18 +32,16 @@
*
* Note: the #if 0, #endif around the BKI_BEGIN.. END block
* below keeps cpp from seeing what is meant for the
* genbki script: pg_relation is now called pg_class, but
* only in the catalogs -cim 2/26/90
* genbki script
* ----------------
*/
/* ----------------
* This structure is actually variable-length (the last attribute is
* a POSTGRES array). Hence, sizeof(FormData_pg_class) does not
* describe the fixed-length or actual size of the structure.
* FormData_pg_class.relacl may not be correctly aligned, either,
* if aclitem and struct varlena don't align together. Hence,
* you MUST use heap_getattr() to get the relacl field.
* necessarily match the actual length of the structure. Furthermore
* relacl may be a NULL field. Hence, you MUST use heap_getattr()
* to get the relacl field ... and don't forget to check isNull.
* ----------------
*/
CATALOG(pg_class) BOOTSTRAP
@ -64,24 +57,26 @@ CATALOG(pg_class) BOOTSTRAP
bool relisshared;
char relkind;
int2 relnatts;
/*
* relnatts is the number of user attributes this class has. There
* 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
* db? */
int2 relchecks; /* # of CHECK constraints for class */
int2 reltriggers; /* # of TRIGGERs */
int2 relukeys; /* # of Unique 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 relhasrules;
bool relhassubclass;
aclitem relacl[1]; /* this is here for the catalog */
bool relhasrules; /* has associated rules */
bool relhassubclass; /* has derived classes */
/*
* relacl may or may not be present, see note above!
*/
aclitem relacl[1]; /* we declare this just for the catalog */
} FormData_pg_class;
/* Size of fixed part of pg_class tuples, not counting relacl or padding */
#define CLASS_TUPLE_SIZE \
(offsetof(FormData_pg_class,relhassubclass) + sizeof(bool))
@ -123,7 +118,7 @@ typedef FormData_pg_class *Form_pg_class;
#define Anum_pg_class_relrefs 16
#define Anum_pg_class_relhaspkey 17
#define Anum_pg_class_relhasrules 18
#define Anum_pg_class_relhassubclass 19
#define Anum_pg_class_relhassubclass 19
#define Anum_pg_class_relacl 20
/* ----------------
@ -176,10 +171,10 @@ DESCR("");
#define RELKIND_INDEX 'i' /* secondary index */
#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_SEQUENCE 'S' /* SEQUENCE relation */
#define RELKIND_UNCATALOGED 'u' /* temporary heap */
#define RELKIND_LONGVALUE 'v' /* moved off huge values */
#endif /* PG_RELATION_H */
#endif /* PG_CLASS_H */

View File

@ -7,18 +7,29 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
#define CATCACHE_H
/* #define CACHEDEBUG turns DEBUG elogs on */
/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
#include "access/htup.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 catcache: information for managing a cache.
@ -26,8 +37,7 @@
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
* and one in the hashbucket list for its hash value. ct_node in each
@ -38,7 +48,7 @@ typedef struct catctup
/* voodoo constants */
#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
@ -47,7 +57,7 @@ typedef struct catcache
Oid indexId;
char *cc_relname; /* relation 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 */
int id; /* XXX could be improved -hirohama */
bool busy; /* for detecting recursive lookups */
@ -71,11 +81,14 @@ extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
ItemPointer pointer);
extern void ResetSystemCache(void);
extern void SystemCacheRelationFlushed(Oid relId);
extern CatCache *InitSysCache(char *relname, char *indname, int id, int nkeys,
int *key, HeapTuple (*iScanfuncP) ());
extern HeapTuple SearchSysCache(struct catcache * cache, Datum v1, Datum v2,
Datum v3, Datum v4);
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);
extern void RelationInvalidateCatalogCacheTuple(Relation relation,
HeapTuple tuple, void (*function) ());
HeapTuple tuple,
void (*function) (int, Index, ItemPointer));
#endif /* CATCACHE_H */

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 @@
#include "access/htup.h"
/* #define CACHEDEBUG *//* turns DEBUG elogs on */
/*
* Declarations for util/syscache.c.
*
* SysCache identifiers.
*
* The order of these must match the order
* they are entered into the structure cacheinfo[] in syscache.c
* Keep them in alphabeticall order.
* they are entered into the structure cacheinfo[] in syscache.c.
* Keep them in alphabetical order.
*/
#define AGGNAME 0
@ -60,30 +57,13 @@
#define TYPENAME 26
#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 InitCatalogCache(void);
extern HeapTuple SearchSysCacheTupleCopy(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4);
extern HeapTuple SearchSysCacheTuple(int cacheId,
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,
AttrNumber attributeNumber,
bool *isnull);
AttrNumber attributeNumber, bool *isNull);
#endif /* SYSCACHE_H */