1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +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:
Andres Freund
2019-01-21 10:32:19 -08:00
parent 111944c5ee
commit e0c4ec0728
114 changed files with 1259 additions and 1259 deletions

View File

@@ -95,7 +95,7 @@ InsertRule(const char *rulname,
/*
* Ready to store new pg_rewrite tuple
*/
pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
/*
* Check to see if we are replacing an existing tuple
@@ -186,7 +186,7 @@ InsertRule(const char *rulname,
/* Post creation hook for new rule */
InvokeObjectPostCreateHook(RewriteRelationId, rewriteObjectId, 0);
heap_close(pg_rewrite_desc, RowExclusiveLock);
table_close(pg_rewrite_desc, RowExclusiveLock);
return rewriteObjectId;
}
@@ -255,7 +255,7 @@ DefineQueryRewrite(const char *rulename,
*
* Note that this lock level should match the one used in DefineRule.
*/
event_relation = heap_open(event_relid, AccessExclusiveLock);
event_relation = table_open(event_relid, AccessExclusiveLock);
/*
* Verify relation is of a type that rules can sensibly be applied to.
@@ -565,7 +565,7 @@ DefineQueryRewrite(const char *rulename,
HeapTuple classTup;
Form_pg_class classForm;
relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
relationRelation = table_open(RelationRelationId, RowExclusiveLock);
toastrelid = event_relation->rd_rel->reltoastrelid;
/* drop storage while table still looks like a table */
@@ -629,13 +629,13 @@ DefineQueryRewrite(const char *rulename,
CatalogTupleUpdate(relationRelation, &classTup->t_self, classTup);
heap_freetuple(classTup);
heap_close(relationRelation, RowExclusiveLock);
table_close(relationRelation, RowExclusiveLock);
}
ObjectAddressSet(address, RewriteRelationId, ruleId);
/* Close rel, but keep lock till commit... */
heap_close(event_relation, NoLock);
table_close(event_relation, NoLock);
return address;
}
@@ -852,7 +852,7 @@ EnableDisableRule(Relation rel, const char *rulename,
/*
* Find the rule tuple to change.
*/
pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
ruletup = SearchSysCacheCopy2(RULERELNAME,
ObjectIdGetDatum(owningRel),
PointerGetDatum(rulename));
@@ -888,7 +888,7 @@ EnableDisableRule(Relation rel, const char *rulename,
InvokeObjectPostAlterHook(RewriteRelationId, ruleform->oid, 0);
heap_freetuple(ruletup);
heap_close(pg_rewrite_desc, RowExclusiveLock);
table_close(pg_rewrite_desc, RowExclusiveLock);
/*
* If we changed anything, broadcast a SI inval message to force each
@@ -964,7 +964,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
targetrel = relation_open(relid, NoLock);
/* Prepare to modify pg_rewrite */
pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
/* Fetch the rule's entry (it had better exist) */
ruletup = SearchSysCacheCopy2(RULERELNAME,
@@ -1000,7 +1000,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
heap_freetuple(ruletup);
heap_close(pg_rewrite_desc, RowExclusiveLock);
table_close(pg_rewrite_desc, RowExclusiveLock);
/*
* Invalidate relation's relcache entry so that other backends (and this

View File

@@ -180,7 +180,7 @@ AcquireRewriteLocks(Query *parsetree,
else
lockmode = rte->rellockmode;
rel = heap_open(rte->relid, lockmode);
rel = table_open(rte->relid, lockmode);
/*
* While we have the relation open, update the RTE's relkind,
@@ -188,7 +188,7 @@ AcquireRewriteLocks(Query *parsetree,
*/
rte->relkind = rel->rd_rel->relkind;
heap_close(rel, NoLock);
table_close(rel, NoLock);
break;
case RTE_JOIN:
@@ -1813,7 +1813,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
* We can use NoLock here since either the parser or
* AcquireRewriteLocks should have locked the rel already.
*/
rel = heap_open(rte->relid, NoLock);
rel = table_open(rte->relid, NoLock);
/*
* Collect the RIR rules that we must apply
@@ -1860,7 +1860,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
}
}
heap_close(rel, NoLock);
table_close(rel, NoLock);
}
/* Recurse into subqueries in WITH */
@@ -1904,7 +1904,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
rte->relkind != RELKIND_PARTITIONED_TABLE))
continue;
rel = heap_open(rte->relid, NoLock);
rel = table_open(rte->relid, NoLock);
/*
* Fetch any new security quals that must be applied to this RTE.
@@ -1979,7 +1979,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
if (hasSubLinks)
parsetree->hasSubLinks = true;
heap_close(rel, NoLock);
table_close(rel, NoLock);
}
return parsetree;
@@ -2896,7 +2896,7 @@ rewriteTargetView(Query *parsetree, Relation view)
* already have the right lock!) Since it will become the query target
* relation, RowExclusiveLock is always the right thing.
*/
base_rel = heap_open(base_rte->relid, RowExclusiveLock);
base_rel = table_open(base_rte->relid, RowExclusiveLock);
/*
* While we have the relation open, update the RTE's relkind, just in case
@@ -3281,7 +3281,7 @@ rewriteTargetView(Query *parsetree, Relation view)
}
}
heap_close(base_rel, NoLock);
table_close(base_rel, NoLock);
return parsetree;
}
@@ -3391,7 +3391,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
* We can use NoLock here since either the parser or
* AcquireRewriteLocks should have locked the rel already.
*/
rt_entry_relation = heap_open(rt_entry->relid, NoLock);
rt_entry_relation = table_open(rt_entry->relid, NoLock);
/*
* Rewrite the targetlist as needed for the command type.
@@ -3616,7 +3616,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("INSERT with ON CONFLICT clause cannot be used with table that has INSERT or UPDATE rules")));
heap_close(rt_entry_relation, NoLock);
table_close(rt_entry_relation, NoLock);
}
/*

View File

@@ -47,7 +47,7 @@ RemoveRewriteRuleById(Oid ruleOid)
/*
* Open the pg_rewrite relation.
*/
RewriteRelation = heap_open(RewriteRelationId, RowExclusiveLock);
RewriteRelation = table_open(RewriteRelationId, RowExclusiveLock);
/*
* Find the tuple for the target rule.
@@ -71,7 +71,7 @@ RemoveRewriteRuleById(Oid ruleOid)
* suffice if it's not an ON SELECT rule.)
*/
eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
event_relation = heap_open(eventRelationOid, AccessExclusiveLock);
event_relation = table_open(eventRelationOid, AccessExclusiveLock);
/*
* Now delete the pg_rewrite tuple for the rule
@@ -80,7 +80,7 @@ RemoveRewriteRuleById(Oid ruleOid)
systable_endscan(rcscan);
heap_close(RewriteRelation, RowExclusiveLock);
table_close(RewriteRelation, RowExclusiveLock);
/*
* Issue shared-inval notice to force all backends (including me!) to
@@ -89,5 +89,5 @@ RemoveRewriteRuleById(Oid ruleOid)
CacheInvalidateRelcache(event_relation);
/* Close rel, but keep lock till commit... */
heap_close(event_relation, NoLock);
table_close(event_relation, NoLock);
}

View File

@@ -61,7 +61,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
/*
* Find the tuple to update in pg_class, using syscache for the lookup.
*/
relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
relationRelation = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
@@ -81,7 +81,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
}
heap_freetuple(tuple);
heap_close(relationRelation, RowExclusiveLock);
table_close(relationRelation, RowExclusiveLock);
}
/*

View File

@@ -162,7 +162,7 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
* for example in UPDATE t1 ... FROM t2 we need to apply t1's UPDATE
* policies and t2's SELECT policies.
*/
rel = heap_open(rte->relid, NoLock);
rel = table_open(rte->relid, NoLock);
commandType = rt_index == root->resultRelation ?
root->commandType : CMD_SELECT;
@@ -379,7 +379,7 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
}
}
heap_close(rel, NoLock);
table_close(rel, NoLock);
/*
* Mark this query as having row security, so plancache can invalidate it