mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
heap_fetch requires buffer pointer, must be released; heap_getnext
no longer returns buffer pointer, can be gotten from scan; descriptor; bootstrap can create multi-key indexes; pg_procname index now is multi-key index; oidint2, oidint4, oidname are gone (must be removed from regression tests); use System Cache rather than sequential scan in many places; heap_modifytuple no longer takes buffer parameter; remove unused buffer parameter in a few other functions; oid8 is not index-able; remove some use of single-character variable names; cleanup Buffer variables usage and scan descriptor looping; cleaned up allocation and freeing of tuples; 18k lines of diff;
This commit is contained in:
18
src/backend/utils/cache/catcache.c
vendored
18
src/backend/utils/cache/catcache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.31 1998/07/27 19:38:22 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.32 1998/08/19 02:03:08 momjian Exp $
|
||||
*
|
||||
* Notes:
|
||||
* XXX This needs to use exception.h to handle recovery when
|
||||
@ -36,11 +36,9 @@
|
||||
|
||||
static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
|
||||
static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
|
||||
static Index
|
||||
CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
|
||||
static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
|
||||
Relation relation, HeapTuple tuple);
|
||||
static void
|
||||
CatalogCacheInitializeCache(struct catcache * cache,
|
||||
static void CatalogCacheInitializeCache(struct catcache * cache,
|
||||
Relation relation);
|
||||
static long comphash(long l, char *v);
|
||||
|
||||
@ -182,7 +180,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
|
||||
* ----------------
|
||||
*/
|
||||
Assert(RelationIsValid(relation));
|
||||
cache->relationId = RelationGetRelationId(relation);
|
||||
cache->relationId = RelationGetRelid(relation);
|
||||
tupdesc = cache->cc_tupdesc = RelationGetTupleDescriptor(relation);
|
||||
|
||||
CACHE3_elog(DEBUG, "CatalogCacheInitializeCache: relid %d, %d keys",
|
||||
@ -250,7 +248,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
|
||||
*/
|
||||
relation = index_openr(cache->cc_indname);
|
||||
Assert(relation);
|
||||
cache->indexId = RelationGetRelationId(relation);
|
||||
cache->indexId = RelationGetRelid(relation);
|
||||
index_close(relation);
|
||||
}
|
||||
else
|
||||
@ -827,7 +825,6 @@ SearchSysCache(struct catcache * cache,
|
||||
CatCTup *nct2;
|
||||
Dlelem *elt;
|
||||
HeapTuple ntp = 0;
|
||||
Buffer buffer;
|
||||
|
||||
Relation relation;
|
||||
MemoryContext oldcxt;
|
||||
@ -997,8 +994,7 @@ SearchSysCache(struct catcache * cache,
|
||||
sd = heap_beginscan(relation, 0, SnapshotNow,
|
||||
cache->cc_nkeys, cache->cc_skey);
|
||||
|
||||
/* should this buffer be ReleaseBuffer'd? --djm 8/20/96 */
|
||||
ntp = heap_getnext(sd, 0, &buffer);
|
||||
ntp = heap_getnext(sd, 0);
|
||||
|
||||
MemoryContextSwitchTo((MemoryContext) CacheCxt);
|
||||
|
||||
@ -1129,7 +1125,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
|
||||
* in the proper hash bucket
|
||||
* ----------------
|
||||
*/
|
||||
relationId = RelationGetRelationId(relation);
|
||||
relationId = RelationGetRelid(relation);
|
||||
|
||||
for (ccp = Caches; ccp; ccp = ccp->cc_next)
|
||||
{
|
||||
|
7
src/backend/utils/cache/fcache.c
vendored
7
src/backend/utils/cache/fcache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.14 1998/07/26 04:30:55 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.15 1998/08/19 02:03:09 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -72,7 +72,8 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext)
|
||||
relname = (char *) getrelname(rtid, econtext->ecxt_range_table);
|
||||
|
||||
|
||||
tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(relname),
|
||||
tup = SearchSysCacheTuple(TYPNAME,
|
||||
PointerGetDatum(relname),
|
||||
0, 0, 0);
|
||||
if (!tup)
|
||||
elog(ERROR, "Lookup failed on type tuple for class %s",
|
||||
@ -129,7 +130,7 @@ init_fcache(Oid foid,
|
||||
* ----------------
|
||||
*/
|
||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(procedureStruct->prorettype),
|
||||
ObjectIdGetDatum(procedureStruct->prorettype),
|
||||
0, 0, 0);
|
||||
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
|
6
src/backend/utils/cache/inval.c
vendored
6
src/backend/utils/cache/inval.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.11 1998/06/15 19:29:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.12 1998/08/19 02:03:11 momjian Exp $
|
||||
*
|
||||
* Note - this code is real crufty...
|
||||
*
|
||||
@ -267,7 +267,7 @@ getmyrelids()
|
||||
MyAMRelationId = tuple->t_oid;
|
||||
|
||||
tuple = SearchSysCacheTuple(RELNAME,
|
||||
PointerGetDatum(AccessMethodOperatorRelationName),
|
||||
PointerGetDatum(AccessMethodOperatorRelationName),
|
||||
0, 0, 0);
|
||||
Assert(HeapTupleIsValid(tuple));
|
||||
MyAMOPRelationId = tuple->t_oid;
|
||||
@ -476,7 +476,7 @@ RelationInvalidateRelationCache(Relation relation,
|
||||
* ----------------
|
||||
*/
|
||||
ValidateHacks(); /* XXX */
|
||||
relationId = RelationGetRelationId(relation);
|
||||
relationId = RelationGetRelid(relation);
|
||||
|
||||
/* ----------------
|
||||
*
|
||||
|
29
src/backend/utils/cache/lsyscache.c
vendored
29
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.19 1998/08/16 05:38:41 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.20 1998/08/19 02:03:12 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -47,8 +47,7 @@ op_class(Oid oprno, int32 opclass, Oid amopid)
|
||||
{
|
||||
FormData_pg_amop amoptup;
|
||||
|
||||
if (SearchSysCacheStruct(AMOPOPID,
|
||||
(char *) &amoptup,
|
||||
if (SearchSysCacheStruct(AMOPOPID, (char *) &amoptup,
|
||||
ObjectIdGetDatum(opclass),
|
||||
ObjectIdGetDatum(oprno),
|
||||
ObjectIdGetDatum(amopid),
|
||||
@ -72,8 +71,7 @@ get_attname(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
FormData_pg_attribute att_tup;
|
||||
|
||||
if (SearchSysCacheStruct(ATTNUM,
|
||||
(char *) &att_tup,
|
||||
if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup,
|
||||
ObjectIdGetDatum(relid),
|
||||
UInt16GetDatum(attnum),
|
||||
0, 0))
|
||||
@ -115,8 +113,7 @@ get_atttype(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
AttributeTupleForm att_tup = (AttributeTupleForm) palloc(sizeof(*att_tup));
|
||||
|
||||
if (SearchSysCacheStruct(ATTNUM,
|
||||
(char *) att_tup,
|
||||
if (SearchSysCacheStruct(ATTNUM, (char *) att_tup,
|
||||
ObjectIdGetDatum(relid),
|
||||
UInt16GetDatum(attnum),
|
||||
0, 0))
|
||||
@ -132,24 +129,24 @@ get_atttype(Oid relid, AttrNumber attnum)
|
||||
bool
|
||||
get_attisset(Oid relid, char *attname)
|
||||
{
|
||||
HeapTuple htup;
|
||||
HeapTuple tuple;
|
||||
AttrNumber attno;
|
||||
AttributeTupleForm att_tup;
|
||||
|
||||
attno = get_attnum(relid, attname);
|
||||
|
||||
htup = SearchSysCacheTuple(ATTNAME,
|
||||
tuple = SearchSysCacheTuple(ATTNAME,
|
||||
ObjectIdGetDatum(relid),
|
||||
PointerGetDatum(attname),
|
||||
0, 0);
|
||||
if (!HeapTupleIsValid(htup))
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "get_attisset: no attribute %s in relation %d",
|
||||
attname, relid);
|
||||
if (heap_attisnull(htup, attno))
|
||||
if (heap_attisnull(tuple, attno))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
att_tup = (AttributeTupleForm) GETSTRUCT(htup);
|
||||
att_tup = (AttributeTupleForm) GETSTRUCT(tuple);
|
||||
return att_tup->attisset;
|
||||
}
|
||||
}
|
||||
@ -166,10 +163,9 @@ get_atttypmod(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
FormData_pg_attribute att_tup;
|
||||
|
||||
if (SearchSysCacheStruct(ATTNUM,
|
||||
(char *) &att_tup,
|
||||
if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int32GetDatum(attnum),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0))
|
||||
return att_tup.atttypmod;
|
||||
else
|
||||
@ -400,8 +396,7 @@ get_rel_name(Oid relid)
|
||||
{
|
||||
FormData_pg_class reltup;
|
||||
|
||||
if ((SearchSysCacheStruct(RELOID,
|
||||
(char *) &reltup,
|
||||
if ((SearchSysCacheStruct(RELOID, (char *) &reltup,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0)))
|
||||
return pstrdup(reltup.relname.data);
|
||||
|
62
src/backend/utils/cache/relcache.c
vendored
62
src/backend/utils/cache/relcache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.46 1998/08/11 18:28:22 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.47 1998/08/19 02:03:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -337,7 +337,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
|
||||
Relation pg_class_desc;
|
||||
HeapScanDesc pg_class_scan;
|
||||
ScanKeyData key;
|
||||
Buffer buf;
|
||||
|
||||
/* ----------------
|
||||
* form a scan key
|
||||
@ -371,9 +370,8 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
|
||||
pg_class_desc = heap_openr(RelationRelationName);
|
||||
if (!IsInitProcessingMode())
|
||||
RelationSetLockForRead(pg_class_desc);
|
||||
pg_class_scan =
|
||||
heap_beginscan(pg_class_desc, 0, SnapshotNow, 1, &key);
|
||||
pg_class_tuple = heap_getnext(pg_class_scan, 0, &buf);
|
||||
pg_class_scan = heap_beginscan(pg_class_desc, 0, SnapshotNow, 1, &key);
|
||||
pg_class_tuple = heap_getnext(pg_class_scan, 0);
|
||||
|
||||
/* ----------------
|
||||
* get set to return tuple
|
||||
@ -394,7 +392,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
|
||||
memmove((char *) return_tuple,
|
||||
(char *) pg_class_tuple,
|
||||
(int) pg_class_tuple->t_len);
|
||||
ReleaseBuffer(buf);
|
||||
}
|
||||
|
||||
/* all done */
|
||||
@ -534,15 +531,14 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_attribute_attrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relation->rd_id));
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
/* ----------------
|
||||
* open pg_attribute and begin a scan
|
||||
* ----------------
|
||||
*/
|
||||
pg_attribute_desc = heap_openr(AttributeRelationName);
|
||||
pg_attribute_scan =
|
||||
heap_beginscan(pg_attribute_desc, 0, SnapshotNow, 1, &key);
|
||||
pg_attribute_scan = heap_beginscan(pg_attribute_desc, 0, SnapshotNow, 1, &key);
|
||||
|
||||
/* ----------------
|
||||
* add attribute data to relation->rd_att
|
||||
@ -550,7 +546,7 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
|
||||
*/
|
||||
need = natts;
|
||||
|
||||
pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0, (Buffer *) NULL);
|
||||
pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0);
|
||||
while (HeapTupleIsValid(pg_attribute_tuple) && need > 0)
|
||||
{
|
||||
attp = (AttributeTupleForm) GETSTRUCT(pg_attribute_tuple);
|
||||
@ -565,13 +561,12 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
|
||||
ATTRIBUTE_TUPLE_SIZE);
|
||||
need--;
|
||||
}
|
||||
pg_attribute_tuple = heap_getnext(pg_attribute_scan,
|
||||
0, (Buffer *) NULL);
|
||||
pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0);
|
||||
}
|
||||
|
||||
if (need > 0)
|
||||
elog(ERROR, "catalog is missing %d attribute%s for relid %d",
|
||||
need, (need == 1 ? "" : "s"), relation->rd_id);
|
||||
need, (need == 1 ? "" : "s"), RelationGetRelid(relation));
|
||||
|
||||
/* ----------------
|
||||
* end the scan and close the attribute relation
|
||||
@ -600,8 +595,8 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
|
||||
|
||||
for (i = 1; i <= relation->rd_rel->relnatts; i++)
|
||||
{
|
||||
|
||||
atttup = (HeapTuple) AttributeNumIndexScan(attrel, relation->rd_id, i);
|
||||
atttup = (HeapTuple) AttributeNumIndexScan(attrel,
|
||||
RelationGetRelid(relation), i);
|
||||
|
||||
if (!HeapTupleIsValid(atttup))
|
||||
elog(ERROR, "cannot find attribute %d of relation %s", i,
|
||||
@ -705,24 +700,21 @@ RelationBuildRuleLock(Relation relation)
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_rewrite_ev_class,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relation->rd_id));
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
/* ----------------
|
||||
* open pg_attribute and begin a scan
|
||||
* ----------------
|
||||
*/
|
||||
pg_rewrite_desc = heap_openr(RewriteRelationName);
|
||||
pg_rewrite_scan =
|
||||
heap_beginscan(pg_rewrite_desc, 0, SnapshotNow, 1, &key);
|
||||
pg_rewrite_tupdesc =
|
||||
RelationGetTupleDescriptor(pg_rewrite_desc);
|
||||
pg_rewrite_scan = heap_beginscan(pg_rewrite_desc, 0, SnapshotNow, 1, &key);
|
||||
pg_rewrite_tupdesc = RelationGetTupleDescriptor(pg_rewrite_desc);
|
||||
|
||||
/* ----------------
|
||||
* add attribute data to relation->rd_att
|
||||
* ----------------
|
||||
*/
|
||||
while ((pg_rewrite_tuple = heap_getnext(pg_rewrite_scan, 0,
|
||||
(Buffer *) NULL)) != NULL)
|
||||
while (HeapTupleIsValid(pg_rewrite_tuple=heap_getnext(pg_rewrite_scan, 0)))
|
||||
{
|
||||
bool isnull;
|
||||
Datum ruleaction;
|
||||
@ -867,7 +859,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
|
||||
* initialize the relation's relation id (relation->rd_id)
|
||||
* ----------------
|
||||
*/
|
||||
relation->rd_id = relid;
|
||||
RelationGetRelid(relation) = relid;
|
||||
|
||||
/* ----------------
|
||||
* initialize relation->rd_refcnt
|
||||
@ -1093,7 +1085,7 @@ formrdesc(char *relationName,
|
||||
* initialize relation id
|
||||
* ----------------
|
||||
*/
|
||||
relation->rd_id = relation->rd_att->attrs[0]->attrelid;
|
||||
RelationGetRelid(relation) = relation->rd_att->attrs[0]->attrelid;
|
||||
|
||||
/* ----------------
|
||||
* add new reldesc to relcache
|
||||
@ -1109,7 +1101,7 @@ formrdesc(char *relationName,
|
||||
* the check (and possible set) after cache insertion.
|
||||
*/
|
||||
relation->rd_rel->relhasindex =
|
||||
CatalogHasIndex(relationName, relation->rd_id);
|
||||
CatalogHasIndex(relationName, RelationGetRelid(relation));
|
||||
}
|
||||
|
||||
|
||||
@ -1328,7 +1320,7 @@ RelationFlushRelation(Relation *relationPtr,
|
||||
RelationCacheDelete(relation);
|
||||
|
||||
FreeTupleDesc(relation->rd_att);
|
||||
SystemCacheRelationFlushed(relation->rd_id);
|
||||
SystemCacheRelationFlushed(RelationGetRelid(relation));
|
||||
|
||||
FreeTriggerDesc(relation);
|
||||
|
||||
@ -1379,7 +1371,7 @@ RelationForgetRelation(Oid rid)
|
||||
Relation reln = lfirst(curr);
|
||||
|
||||
Assert(reln != NULL && reln->rd_islocal);
|
||||
if (reln->rd_id == rid)
|
||||
if (RelationGetRelid(reln) == rid)
|
||||
break;
|
||||
prev = curr;
|
||||
}
|
||||
@ -1678,7 +1670,6 @@ AttrDefaultFetch(Relation relation)
|
||||
Form_pg_attrdef adform;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
struct varlena *val;
|
||||
bool isnull;
|
||||
@ -1689,7 +1680,7 @@ AttrDefaultFetch(Relation relation)
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(relation->rd_id));
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
adrel = heap_openr(AttrDefaultRelationName);
|
||||
irel = index_openr(AttrDefaultIndex);
|
||||
@ -1698,6 +1689,8 @@ AttrDefaultFetch(Relation relation)
|
||||
|
||||
for (found = 0;;)
|
||||
{
|
||||
Buffer buffer;
|
||||
|
||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
||||
if (!indexRes)
|
||||
break;
|
||||
@ -1736,12 +1729,12 @@ AttrDefaultFetch(Relation relation)
|
||||
attrdef[i].adsrc = textout(val);
|
||||
break;
|
||||
}
|
||||
|
||||
ReleaseBuffer(buffer);
|
||||
|
||||
if (i >= ndef)
|
||||
elog(ERROR, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
|
||||
adform->adnum,
|
||||
relation->rd_rel->relname.data);
|
||||
ReleaseBuffer(buffer);
|
||||
}
|
||||
|
||||
if (found < ndef)
|
||||
@ -1752,7 +1745,6 @@ AttrDefaultFetch(Relation relation)
|
||||
pfree(sd);
|
||||
index_close(irel);
|
||||
heap_close(adrel);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1766,7 +1758,6 @@ RelCheckFetch(Relation relation)
|
||||
HeapTuple tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
Name rcname;
|
||||
struct varlena *val;
|
||||
@ -1777,7 +1768,7 @@ RelCheckFetch(Relation relation)
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(relation->rd_id));
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
rcrel = heap_openr(RelCheckRelationName);
|
||||
irel = index_openr(RelCheckIndex);
|
||||
@ -1786,6 +1777,8 @@ RelCheckFetch(Relation relation)
|
||||
|
||||
for (found = 0;;)
|
||||
{
|
||||
Buffer buffer;
|
||||
|
||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
||||
if (!indexRes)
|
||||
break;
|
||||
@ -1821,7 +1814,6 @@ RelCheckFetch(Relation relation)
|
||||
relation->rd_rel->relname.data);
|
||||
check[found].ccsrc = textout(val);
|
||||
found++;
|
||||
|
||||
ReleaseBuffer(buffer);
|
||||
}
|
||||
|
||||
|
211
src/backend/utils/cache/syscache.c
vendored
211
src/backend/utils/cache/syscache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.19 1998/07/20 16:57:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.20 1998/08/19 02:03:15 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@ -67,262 +67,320 @@ typedef HeapTuple (*ScanFunc) ();
|
||||
static struct cachedesc cacheinfo[] = {
|
||||
{AccessMethodOperatorRelationName, /* AMOPOPID */
|
||||
3,
|
||||
{Anum_pg_amop_amopclaid,
|
||||
{
|
||||
Anum_pg_amop_amopclaid,
|
||||
Anum_pg_amop_amopopr,
|
||||
Anum_pg_amop_amopid,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_amop),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{AccessMethodOperatorRelationName, /* AMOPSTRATEGY */
|
||||
3,
|
||||
{Anum_pg_amop_amopid,
|
||||
{
|
||||
Anum_pg_amop_amopid,
|
||||
Anum_pg_amop_amopclaid,
|
||||
Anum_pg_amop_amopstrategy,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_amop),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{AttributeRelationName, /* ATTNAME */
|
||||
2,
|
||||
{Anum_pg_attribute_attrelid,
|
||||
{
|
||||
Anum_pg_attribute_attrelid,
|
||||
Anum_pg_attribute_attname,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
ATTRIBUTE_TUPLE_SIZE,
|
||||
AttributeNameIndex,
|
||||
(ScanFunc) AttributeNameIndexScan},
|
||||
{AttributeRelationName, /* ATTNUM */
|
||||
2,
|
||||
{Anum_pg_attribute_attrelid,
|
||||
{
|
||||
Anum_pg_attribute_attrelid,
|
||||
Anum_pg_attribute_attnum,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
ATTRIBUTE_TUPLE_SIZE,
|
||||
AttributeNumIndex,
|
||||
(ScanFunc) AttributeNumIndexScan},
|
||||
{IndexRelationName, /* INDEXRELID */
|
||||
1,
|
||||
{Anum_pg_index_indexrelid,
|
||||
{
|
||||
Anum_pg_index_indexrelid,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_index, indpred),
|
||||
NULL,
|
||||
NULL},
|
||||
{LanguageRelationName, /* LANNAME */
|
||||
1,
|
||||
{Anum_pg_language_lanname,
|
||||
{
|
||||
Anum_pg_language_lanname,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_language, lancompiler),
|
||||
NULL,
|
||||
NULL},
|
||||
{OperatorRelationName, /* OPRNAME */
|
||||
4,
|
||||
{Anum_pg_operator_oprname,
|
||||
{
|
||||
Anum_pg_operator_oprname,
|
||||
Anum_pg_operator_oprleft,
|
||||
Anum_pg_operator_oprright,
|
||||
Anum_pg_operator_oprkind},
|
||||
Anum_pg_operator_oprkind
|
||||
},
|
||||
sizeof(FormData_pg_operator),
|
||||
NULL,
|
||||
NULL},
|
||||
{OperatorRelationName, /* OPROID */
|
||||
1,
|
||||
{ObjectIdAttributeNumber,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_operator),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{ProcedureRelationName, /* PRONAME */
|
||||
3,
|
||||
{Anum_pg_proc_proname,
|
||||
{
|
||||
Anum_pg_proc_proname,
|
||||
Anum_pg_proc_pronargs,
|
||||
Anum_pg_proc_proargtypes,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_proc, prosrc),
|
||||
ProcedureNameIndex,
|
||||
(ScanFunc) ProcedureNameIndexScan},
|
||||
{ProcedureRelationName, /* PROOID */
|
||||
1,
|
||||
{ObjectIdAttributeNumber,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_proc, prosrc),
|
||||
ProcedureOidIndex,
|
||||
(ScanFunc) ProcedureOidIndexScan},
|
||||
{RelationRelationName, /* RELNAME */
|
||||
1,
|
||||
{Anum_pg_class_relname,
|
||||
{
|
||||
Anum_pg_class_relname,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
CLASS_TUPLE_SIZE,
|
||||
ClassNameIndex,
|
||||
(ScanFunc) ClassNameIndexScan},
|
||||
{RelationRelationName, /* RELOID */
|
||||
1,
|
||||
{ObjectIdAttributeNumber,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
CLASS_TUPLE_SIZE,
|
||||
ClassOidIndex,
|
||||
(ScanFunc) ClassOidIndexScan},
|
||||
{TypeRelationName, /* TYPNAME */
|
||||
1,
|
||||
{Anum_pg_type_typname,
|
||||
{
|
||||
Anum_pg_type_typname,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(TypeTupleFormData, typalign) +sizeof(char),
|
||||
TypeNameIndex,
|
||||
TypeNameIndexScan},
|
||||
{TypeRelationName, /* TYPOID */
|
||||
1,
|
||||
{ObjectIdAttributeNumber,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(TypeTupleFormData, typalign) +sizeof(char),
|
||||
TypeOidIndex,
|
||||
TypeOidIndexScan},
|
||||
{AccessMethodRelationName, /* AMNAME */
|
||||
1,
|
||||
{Anum_pg_am_amname,
|
||||
{
|
||||
Anum_pg_am_amname,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_am),
|
||||
NULL,
|
||||
NULL},
|
||||
{OperatorClassRelationName, /* CLANAME */
|
||||
1,
|
||||
{Anum_pg_opclass_opcname,
|
||||
{
|
||||
Anum_pg_opclass_opcname,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_opclass),
|
||||
NULL,
|
||||
NULL},
|
||||
{IndexRelationName, /* INDRELIDKEY */
|
||||
{IndexRelationName, /* INDRELIDKEY */ /* never used */
|
||||
2,
|
||||
{Anum_pg_index_indrelid,
|
||||
{
|
||||
Anum_pg_index_indrelid,
|
||||
Anum_pg_index_indkey,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_index, indpred),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{InheritsRelationName, /* INHRELID */
|
||||
2,
|
||||
{Anum_pg_inherits_inhrel,
|
||||
{
|
||||
Anum_pg_inherits_inhrel,
|
||||
Anum_pg_inherits_inhseqno,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_inherits),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{RewriteRelationName, /* RULOID */
|
||||
1,
|
||||
{ObjectIdAttributeNumber,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_rewrite, ev_qual),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{AggregateRelationName, /* AGGNAME */
|
||||
2,
|
||||
{Anum_pg_aggregate_aggname,
|
||||
{
|
||||
Anum_pg_aggregate_aggname,
|
||||
Anum_pg_aggregate_aggbasetype,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_aggregate, agginitval1),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{ListenerRelationName, /* LISTENREL */
|
||||
2,
|
||||
{Anum_pg_listener_relname,
|
||||
{
|
||||
Anum_pg_listener_relname,
|
||||
Anum_pg_listener_pid,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_listener),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{ShadowRelationName, /* USENAME */
|
||||
1,
|
||||
{Anum_pg_shadow_usename,
|
||||
{
|
||||
Anum_pg_shadow_usename,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_shadow),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{ShadowRelationName, /* USESYSID */
|
||||
1,
|
||||
{Anum_pg_shadow_usesysid,
|
||||
{
|
||||
Anum_pg_shadow_usesysid,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_shadow),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{GroupRelationName, /* GRONAME */
|
||||
1,
|
||||
{Anum_pg_group_groname,
|
||||
{
|
||||
Anum_pg_group_groname,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_group, grolist[0]),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{GroupRelationName, /* GROSYSID */
|
||||
1,
|
||||
{Anum_pg_group_grosysid,
|
||||
{
|
||||
Anum_pg_group_grosysid,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_group, grolist[0]),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{RewriteRelationName, /* REWRITENAME */
|
||||
1,
|
||||
{Anum_pg_rewrite_rulename,
|
||||
{
|
||||
Anum_pg_rewrite_rulename,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_rewrite, ev_qual),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{ProcedureRelationName, /* PROSRC */
|
||||
1,
|
||||
{Anum_pg_proc_prosrc,
|
||||
{
|
||||
Anum_pg_proc_prosrc,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_proc, prosrc),
|
||||
ProcedureSrcIndex,
|
||||
(ScanFunc) ProcedureSrcIndexScan},
|
||||
{OperatorClassRelationName, /* CLADEFTYPE */
|
||||
1,
|
||||
{Anum_pg_opclass_opcdeftype,
|
||||
{
|
||||
Anum_pg_opclass_opcdeftype,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
sizeof(FormData_pg_opclass),
|
||||
NULL,
|
||||
(ScanFunc) NULL},
|
||||
{LanguageRelationName, /* LANOID */
|
||||
1,
|
||||
{ObjectIdAttributeNumber,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0},
|
||||
0
|
||||
},
|
||||
offsetof(FormData_pg_language, lancompiler),
|
||||
NULL,
|
||||
NULL}
|
||||
@ -380,16 +438,39 @@ InitCatalogCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* SearchSysCacheTupleCopy--
|
||||
*
|
||||
* THis is like SearchSysCacheTuple, except it returns a copy of the tuple
|
||||
* that the user is required to pfree().
|
||||
*/
|
||||
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--
|
||||
*
|
||||
* A layer on top of SearchSysCache that does the initialization and
|
||||
* key-setting for you.
|
||||
* A layer on top of SearchSysCache that does the initialization and
|
||||
* key-setting for you.
|
||||
*
|
||||
* Returns the tuple if one is found, NULL if not.
|
||||
* Returns the cache copy of the tuple if one is found, NULL if not.
|
||||
* The tuple is the 'cache' copy.
|
||||
*
|
||||
* XXX The tuple that is returned is NOT supposed to be pfree'd!
|
||||
* XXX The tuple that is returned is NOT supposed to be pfree'd!
|
||||
*/
|
||||
HeapTuple
|
||||
SearchSysCacheTuple(int cacheId,/* cache selection code */
|
||||
@ -542,7 +623,6 @@ SearchSysCacheGetAttribute(int cacheId,
|
||||
|
||||
if (isNull)
|
||||
{
|
||||
|
||||
/*
|
||||
* Used to be an elog(DEBUG, ...) here and a claim that it should
|
||||
* be a FATAL error, I don't think either is warranted -mer 6/9/92
|
||||
@ -622,7 +702,6 @@ TypeDefaultRetrieve(Oid typId)
|
||||
cacheinfo[TYPOID].name, TYPOID);
|
||||
#endif /* defined(CACHEDEBUG) */
|
||||
return (NULL);
|
||||
|
||||
}
|
||||
|
||||
dataSize = VARSIZE(typDefault) - VARHDRSZ;
|
||||
|
Reference in New Issue
Block a user