mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Replace uses of heap_open et al with the corresponding table_* function.
Author: Andres Freund Discussion: https://postgr.es/m/20190111000539.xbv7s6w7ilcvm7dp@alap3.anarazel.de
This commit is contained in:
14
src/backend/utils/cache/catcache.c
vendored
14
src/backend/utils/cache/catcache.c
vendored
@ -938,7 +938,7 @@ CatalogCacheInitializeCache(CatCache *cache)
|
||||
|
||||
CatalogCacheInitializeCache_DEBUG1;
|
||||
|
||||
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
||||
relation = table_open(cache->cc_reloid, AccessShareLock);
|
||||
|
||||
/*
|
||||
* switch to the cache context so our allocations do not vanish at the end
|
||||
@ -965,7 +965,7 @@ CatalogCacheInitializeCache(CatCache *cache)
|
||||
*/
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
CACHE3_elog(DEBUG2, "CatalogCacheInitializeCache: %s, %d keys",
|
||||
cache->cc_relname, cache->cc_nkeys);
|
||||
@ -1357,7 +1357,7 @@ SearchCatCacheMiss(CatCache *cache,
|
||||
*
|
||||
* NOTE: it is possible for recursive cache lookups to occur while reading
|
||||
* the relation --- for example, due to shared-cache-inval messages being
|
||||
* processed during heap_open(). This is OK. It's even possible for one
|
||||
* processed during table_open(). This is OK. It's even possible for one
|
||||
* of those lookups to find and enter the very same tuple we are trying to
|
||||
* fetch here. If that happens, we will enter a second copy of the tuple
|
||||
* into the cache. The first copy will never be referenced again, and
|
||||
@ -1365,7 +1365,7 @@ SearchCatCacheMiss(CatCache *cache,
|
||||
* This case is rare enough that it's not worth expending extra cycles to
|
||||
* detect.
|
||||
*/
|
||||
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
||||
relation = table_open(cache->cc_reloid, AccessShareLock);
|
||||
|
||||
scandesc = systable_beginscan(relation,
|
||||
cache->cc_indexoid,
|
||||
@ -1390,7 +1390,7 @@ SearchCatCacheMiss(CatCache *cache,
|
||||
|
||||
systable_endscan(scandesc);
|
||||
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
/*
|
||||
* If tuple was not found, we need to build a negative cache entry
|
||||
@ -1638,7 +1638,7 @@ SearchCatCacheList(CatCache *cache,
|
||||
cur_skey[2].sk_argument = v3;
|
||||
cur_skey[3].sk_argument = v4;
|
||||
|
||||
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
||||
relation = table_open(cache->cc_reloid, AccessShareLock);
|
||||
|
||||
scandesc = systable_beginscan(relation,
|
||||
cache->cc_indexoid,
|
||||
@ -1705,7 +1705,7 @@ SearchCatCacheList(CatCache *cache,
|
||||
|
||||
systable_endscan(scandesc);
|
||||
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
/* Now we can build the CatCList entry. */
|
||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||
|
48
src/backend/utils/cache/relcache.c
vendored
48
src/backend/utils/cache/relcache.c
vendored
@ -336,7 +336,7 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
|
||||
* without a pg_internal.init file). The caller can also force a heap
|
||||
* scan by setting indexOK == false.
|
||||
*/
|
||||
pg_class_desc = heap_open(RelationRelationId, AccessShareLock);
|
||||
pg_class_desc = table_open(RelationRelationId, AccessShareLock);
|
||||
|
||||
/*
|
||||
* The caller might need a tuple that's newer than the one the historic
|
||||
@ -363,7 +363,7 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
|
||||
|
||||
/* all done */
|
||||
systable_endscan(pg_class_scan);
|
||||
heap_close(pg_class_desc, AccessShareLock);
|
||||
table_close(pg_class_desc, AccessShareLock);
|
||||
|
||||
return pg_class_tuple;
|
||||
}
|
||||
@ -526,7 +526,7 @@ RelationBuildTupleDesc(Relation relation)
|
||||
* built the critical relcache entries (this includes initdb and startup
|
||||
* without a pg_internal.init file).
|
||||
*/
|
||||
pg_attribute_desc = heap_open(AttributeRelationId, AccessShareLock);
|
||||
pg_attribute_desc = table_open(AttributeRelationId, AccessShareLock);
|
||||
pg_attribute_scan = systable_beginscan(pg_attribute_desc,
|
||||
AttributeRelidNumIndexId,
|
||||
criticalRelcachesBuilt,
|
||||
@ -633,7 +633,7 @@ RelationBuildTupleDesc(Relation relation)
|
||||
* end the scan and close the attribute relation
|
||||
*/
|
||||
systable_endscan(pg_attribute_scan);
|
||||
heap_close(pg_attribute_desc, AccessShareLock);
|
||||
table_close(pg_attribute_desc, AccessShareLock);
|
||||
|
||||
if (need != 0)
|
||||
elog(ERROR, "catalog is missing %d attribute(s) for relid %u",
|
||||
@ -767,7 +767,7 @@ RelationBuildRuleLock(Relation relation)
|
||||
* emergency-recovery operations (ie, IgnoreSystemIndexes). This in turn
|
||||
* ensures that rules will be fired in name order.
|
||||
*/
|
||||
rewrite_desc = heap_open(RewriteRelationId, AccessShareLock);
|
||||
rewrite_desc = table_open(RewriteRelationId, AccessShareLock);
|
||||
rewrite_tupdesc = RelationGetDescr(rewrite_desc);
|
||||
rewrite_scan = systable_beginscan(rewrite_desc,
|
||||
RewriteRelRulenameIndexId,
|
||||
@ -848,7 +848,7 @@ RelationBuildRuleLock(Relation relation)
|
||||
* end the scan and close the attribute relation
|
||||
*/
|
||||
systable_endscan(rewrite_scan);
|
||||
heap_close(rewrite_desc, AccessShareLock);
|
||||
table_close(rewrite_desc, AccessShareLock);
|
||||
|
||||
/*
|
||||
* there might not be any rules (if relhasrules is out-of-date)
|
||||
@ -1644,7 +1644,7 @@ LookupOpclassInfo(Oid operatorClassOid,
|
||||
Anum_pg_opclass_oid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(operatorClassOid));
|
||||
rel = heap_open(OperatorClassRelationId, AccessShareLock);
|
||||
rel = table_open(OperatorClassRelationId, AccessShareLock);
|
||||
scan = systable_beginscan(rel, OpclassOidIndexId, indexOK,
|
||||
NULL, 1, skey);
|
||||
|
||||
@ -1659,7 +1659,7 @@ LookupOpclassInfo(Oid operatorClassOid,
|
||||
elog(ERROR, "could not find tuple for opclass %u", operatorClassOid);
|
||||
|
||||
systable_endscan(scan);
|
||||
heap_close(rel, AccessShareLock);
|
||||
table_close(rel, AccessShareLock);
|
||||
|
||||
/*
|
||||
* Scan pg_amproc to obtain support procs for the opclass. We only fetch
|
||||
@ -1679,7 +1679,7 @@ LookupOpclassInfo(Oid operatorClassOid,
|
||||
Anum_pg_amproc_amprocrighttype,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opcentry->opcintype));
|
||||
rel = heap_open(AccessMethodProcedureRelationId, AccessShareLock);
|
||||
rel = table_open(AccessMethodProcedureRelationId, AccessShareLock);
|
||||
scan = systable_beginscan(rel, AccessMethodProcedureIndexId, indexOK,
|
||||
NULL, 3, skey);
|
||||
|
||||
@ -1697,7 +1697,7 @@ LookupOpclassInfo(Oid operatorClassOid,
|
||||
}
|
||||
|
||||
systable_endscan(scan);
|
||||
heap_close(rel, AccessShareLock);
|
||||
table_close(rel, AccessShareLock);
|
||||
}
|
||||
|
||||
opcentry->valid = true;
|
||||
@ -3348,7 +3348,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence,
|
||||
/*
|
||||
* Get a writable copy of the pg_class tuple for the given relation.
|
||||
*/
|
||||
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||
pg_class = table_open(RelationRelationId, RowExclusiveLock);
|
||||
|
||||
tuple = SearchSysCacheCopy1(RELOID,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
@ -3402,7 +3402,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence,
|
||||
|
||||
heap_freetuple(tuple);
|
||||
|
||||
heap_close(pg_class, RowExclusiveLock);
|
||||
table_close(pg_class, RowExclusiveLock);
|
||||
|
||||
/*
|
||||
* Make the pg_class row change visible, as well as the relation map
|
||||
@ -3938,7 +3938,7 @@ AttrDefaultFetch(Relation relation)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
adrel = heap_open(AttrDefaultRelationId, AccessShareLock);
|
||||
adrel = table_open(AttrDefaultRelationId, AccessShareLock);
|
||||
adscan = systable_beginscan(adrel, AttrDefaultIndexId, true,
|
||||
NULL, 1, &skey);
|
||||
found = 0;
|
||||
@ -3983,7 +3983,7 @@ AttrDefaultFetch(Relation relation)
|
||||
}
|
||||
|
||||
systable_endscan(adscan);
|
||||
heap_close(adrel, AccessShareLock);
|
||||
table_close(adrel, AccessShareLock);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4005,7 +4005,7 @@ CheckConstraintFetch(Relation relation)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
conrel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||
conrel = table_open(ConstraintRelationId, AccessShareLock);
|
||||
conscan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
|
||||
NULL, 1, skey);
|
||||
|
||||
@ -4046,7 +4046,7 @@ CheckConstraintFetch(Relation relation)
|
||||
}
|
||||
|
||||
systable_endscan(conscan);
|
||||
heap_close(conrel, AccessShareLock);
|
||||
table_close(conrel, AccessShareLock);
|
||||
|
||||
if (found != ncheck)
|
||||
elog(ERROR, "%d constraint record(s) missing for rel %s",
|
||||
@ -4117,7 +4117,7 @@ RelationGetFKeyList(Relation relation)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
conrel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||
conrel = table_open(ConstraintRelationId, AccessShareLock);
|
||||
conscan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
|
||||
NULL, 1, &skey);
|
||||
|
||||
@ -4146,7 +4146,7 @@ RelationGetFKeyList(Relation relation)
|
||||
}
|
||||
|
||||
systable_endscan(conscan);
|
||||
heap_close(conrel, AccessShareLock);
|
||||
table_close(conrel, AccessShareLock);
|
||||
|
||||
/* Now save a copy of the completed list in the relcache entry. */
|
||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||
@ -4224,7 +4224,7 @@ RelationGetIndexList(Relation relation)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
indrel = heap_open(IndexRelationId, AccessShareLock);
|
||||
indrel = table_open(IndexRelationId, AccessShareLock);
|
||||
indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true,
|
||||
NULL, 1, &skey);
|
||||
|
||||
@ -4265,7 +4265,7 @@ RelationGetIndexList(Relation relation)
|
||||
|
||||
systable_endscan(indscan);
|
||||
|
||||
heap_close(indrel, AccessShareLock);
|
||||
table_close(indrel, AccessShareLock);
|
||||
|
||||
/* Now save a copy of the completed list in the relcache entry. */
|
||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||
@ -4340,7 +4340,7 @@ RelationGetStatExtList(Relation relation)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
|
||||
indrel = heap_open(StatisticExtRelationId, AccessShareLock);
|
||||
indrel = table_open(StatisticExtRelationId, AccessShareLock);
|
||||
indscan = systable_beginscan(indrel, StatisticExtRelidIndexId, true,
|
||||
NULL, 1, &skey);
|
||||
|
||||
@ -4353,7 +4353,7 @@ RelationGetStatExtList(Relation relation)
|
||||
|
||||
systable_endscan(indscan);
|
||||
|
||||
heap_close(indrel, AccessShareLock);
|
||||
table_close(indrel, AccessShareLock);
|
||||
|
||||
/* Now save a copy of the completed list in the relcache entry. */
|
||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||
@ -4907,7 +4907,7 @@ RelationGetExclusionInfo(Relation indexRelation,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(indexRelation->rd_index->indrelid));
|
||||
|
||||
conrel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||
conrel = table_open(ConstraintRelationId, AccessShareLock);
|
||||
conscan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
|
||||
NULL, 1, skey);
|
||||
found = false;
|
||||
@ -4951,7 +4951,7 @@ RelationGetExclusionInfo(Relation indexRelation,
|
||||
}
|
||||
|
||||
systable_endscan(conscan);
|
||||
heap_close(conrel, AccessShareLock);
|
||||
table_close(conrel, AccessShareLock);
|
||||
|
||||
if (!found)
|
||||
elog(ERROR, "exclusion constraint record missing for rel %s",
|
||||
|
4
src/backend/utils/cache/relfilenodemap.c
vendored
4
src/backend/utils/cache/relfilenodemap.c
vendored
@ -192,7 +192,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
||||
*/
|
||||
|
||||
/* check for plain relations by looking in pg_class */
|
||||
relation = heap_open(RelationRelationId, AccessShareLock);
|
||||
relation = table_open(RelationRelationId, AccessShareLock);
|
||||
|
||||
/* copy scankey to local copy, it will be modified during the scan */
|
||||
memcpy(skey, relfilenode_skey, sizeof(skey));
|
||||
@ -226,7 +226,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
||||
}
|
||||
|
||||
systable_endscan(scandesc);
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
/* check for tables that are mapped but not shared */
|
||||
if (!found)
|
||||
|
4
src/backend/utils/cache/ts_cache.c
vendored
4
src/backend/utils/cache/ts_cache.c
vendored
@ -481,7 +481,7 @@ lookup_ts_config_cache(Oid cfgId)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(cfgId));
|
||||
|
||||
maprel = heap_open(TSConfigMapRelationId, AccessShareLock);
|
||||
maprel = table_open(TSConfigMapRelationId, AccessShareLock);
|
||||
mapidx = index_open(TSConfigMapIndexId, AccessShareLock);
|
||||
mapscan = systable_beginscan_ordered(maprel, mapidx,
|
||||
NULL, 1, &mapskey);
|
||||
@ -522,7 +522,7 @@ lookup_ts_config_cache(Oid cfgId)
|
||||
|
||||
systable_endscan_ordered(mapscan);
|
||||
index_close(mapidx, AccessShareLock);
|
||||
heap_close(maprel, AccessShareLock);
|
||||
table_close(maprel, AccessShareLock);
|
||||
|
||||
if (ndicts > 0)
|
||||
{
|
||||
|
8
src/backend/utils/cache/typcache.c
vendored
8
src/backend/utils/cache/typcache.c
vendored
@ -915,7 +915,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
|
||||
* constraints for not just this domain, but any ancestor domains, so the
|
||||
* outer loop crawls up the domain stack.
|
||||
*/
|
||||
conRel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||
conRel = table_open(ConstraintRelationId, AccessShareLock);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -1056,7 +1056,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
|
||||
ReleaseSysCache(tup);
|
||||
}
|
||||
|
||||
heap_close(conRel, AccessShareLock);
|
||||
table_close(conRel, AccessShareLock);
|
||||
|
||||
/*
|
||||
* Only need to add one NOT NULL check regardless of how many domains in
|
||||
@ -2347,7 +2347,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(tcache->type_id));
|
||||
|
||||
enum_rel = heap_open(EnumRelationId, AccessShareLock);
|
||||
enum_rel = table_open(EnumRelationId, AccessShareLock);
|
||||
enum_scan = systable_beginscan(enum_rel,
|
||||
EnumTypIdLabelIndexId,
|
||||
true, NULL,
|
||||
@ -2368,7 +2368,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
|
||||
}
|
||||
|
||||
systable_endscan(enum_scan);
|
||||
heap_close(enum_rel, AccessShareLock);
|
||||
table_close(enum_rel, AccessShareLock);
|
||||
|
||||
/* Sort the items into OID order */
|
||||
qsort(items, numitems, sizeof(EnumItem), enum_oid_cmp);
|
||||
|
Reference in New Issue
Block a user