Skip to content

Commit

Permalink
Replace uses of heap_open et al with the corresponding table_* function.
Browse files Browse the repository at this point in the history
Author: Andres Freund
Discussion: https://postgr.es/m/[email protected]
  • Loading branch information
anarazel committed Jan 21, 2019
1 parent 111944c commit e0c4ec0
Show file tree
Hide file tree
Showing 114 changed files with 1,259 additions and 1,259 deletions.
4 changes: 2 additions & 2 deletions contrib/amcheck/verify_nbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed)
*/
heapid = IndexGetRelation(indrelid, true);
if (OidIsValid(heapid))
heaprel = heap_open(heapid, lockmode);
heaprel = table_open(heapid, lockmode);
else
heaprel = NULL;

Expand Down Expand Up @@ -261,7 +261,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed)
*/
index_close(indrel, lockmode);
if (heaprel)
heap_close(heaprel, lockmode);
table_close(heaprel, lockmode);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions contrib/dblink/dblink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
tupdesc = rel->rd_att;

/* Prepare to scan pg_index for entries having indrelid = this rel. */
indexRelation = heap_open(IndexRelationId, AccessShareLock);
indexRelation = table_open(IndexRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_index_indrelid,
BTEqualStrategyNumber, F_OIDEQ,
Expand Down Expand Up @@ -2079,7 +2079,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
}

systable_endscan(scan);
heap_close(indexRelation, AccessShareLock);
table_close(indexRelation, AccessShareLock);

return result;
}
Expand Down Expand Up @@ -2503,7 +2503,7 @@ get_rel_from_relname(text *relname_text, LOCKMODE lockmode, AclMode aclmode)
AclResult aclresult;

relvar = makeRangeVarFromNameList(textToQualifiedNameList(relname_text));
rel = heap_openrv(relvar, lockmode);
rel = table_openrv(relvar, lockmode);

aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
aclmode);
Expand Down
8 changes: 4 additions & 4 deletions contrib/file_fdw/file_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ get_file_fdw_attribute_options(Oid relid)

List *options = NIL;

rel = heap_open(relid, AccessShareLock);
rel = table_open(relid, AccessShareLock);
tupleDesc = RelationGetDescr(rel);
natts = tupleDesc->natts;

Expand Down Expand Up @@ -481,7 +481,7 @@ get_file_fdw_attribute_options(Oid relid)
}
}

heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);

/*
* Return DefElem only when some column(s) have force_not_null /
Expand Down Expand Up @@ -892,7 +892,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
}

/* Convert attribute numbers to column names. */
rel = heap_open(foreigntableid, AccessShareLock);
rel = table_open(foreigntableid, AccessShareLock);
tupleDesc = RelationGetDescr(rel);

while ((attnum = bms_first_member(attrs_used)) >= 0)
Expand Down Expand Up @@ -934,7 +934,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
numattrs++;
}

heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);

/* If there's a whole-row reference, fail: we need all the columns. */
if (has_wholerow)
Expand Down
2 changes: 1 addition & 1 deletion contrib/pgrowlocks/pgrowlocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
}

heap_endscan(scan);
heap_close(mydata->rel, AccessShareLock);
table_close(mydata->rel, AccessShareLock);

SRF_RETURN_DONE(funcctx);
}
12 changes: 6 additions & 6 deletions contrib/postgres_fdw/deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,11 +1048,11 @@ deparseSelectSql(List *tlist, bool is_subquery, List **retrieved_attrs,
* Core code already has some lock on each rel being planned, so we
* can use NoLock here.
*/
Relation rel = heap_open(rte->relid, NoLock);
Relation rel = table_open(rte->relid, NoLock);

deparseTargetList(buf, rte, foreignrel->relid, rel, false,
fpinfo->attrs_used, false, retrieved_attrs);
heap_close(rel, NoLock);
table_close(rel, NoLock);
}
}

Expand Down Expand Up @@ -1543,7 +1543,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
* Core code already has some lock on each rel being planned, so we
* can use NoLock here.
*/
Relation rel = heap_open(rte->relid, NoLock);
Relation rel = table_open(rte->relid, NoLock);

deparseRelation(buf, rel);

Expand All @@ -1555,7 +1555,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
if (use_alias)
appendStringInfo(buf, " %s%d", REL_ALIAS_PREFIX, foreignrel->relid);

heap_close(rel, NoLock);
table_close(rel, NoLock);
}
}

Expand Down Expand Up @@ -2097,7 +2097,7 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte,
* The lock on the relation will be held by upper callers, so it's
* fine to open it with no lock here.
*/
rel = heap_open(rte->relid, NoLock);
rel = table_open(rte->relid, NoLock);

/*
* The local name of the foreign table can not be recognized by the
Expand Down Expand Up @@ -2132,7 +2132,7 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte,
if (qualify_col)
appendStringInfoString(buf, " END");

heap_close(rel, NoLock);
table_close(rel, NoLock);
bms_free(attrs_used);
}
else
Expand Down
8 changes: 4 additions & 4 deletions contrib/postgres_fdw/postgres_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ postgresPlanForeignModify(PlannerInfo *root,
* Core code already has some lock on each rel being planned, so we can
* use NoLock here.
*/
rel = heap_open(rte->relid, NoLock);
rel = table_open(rte->relid, NoLock);

/*
* In an INSERT, we transmit all columns that are defined in the foreign
Expand Down Expand Up @@ -1706,7 +1706,7 @@ postgresPlanForeignModify(PlannerInfo *root,
break;
}

heap_close(rel, NoLock);
table_close(rel, NoLock);

/*
* Build the fdw_private list that will be available to the executor.
Expand Down Expand Up @@ -2121,7 +2121,7 @@ postgresPlanDirectModify(PlannerInfo *root,
* Core code already has some lock on each rel being planned, so we can
* use NoLock here.
*/
rel = heap_open(rte->relid, NoLock);
rel = table_open(rte->relid, NoLock);

/*
* Recall the qual clauses that must be evaluated remotely. (These are
Expand Down Expand Up @@ -2207,7 +2207,7 @@ postgresPlanDirectModify(PlannerInfo *root,
rebuild_fdw_scan_tlist(fscan, returningList);
}

heap_close(rel, NoLock);
table_close(rel, NoLock);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions contrib/sepgsql/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
* XXX - uncoming version of libselinux supports to take object name to
* handle special treatment on default security label.
*/
rel = heap_open(DatabaseRelationId, AccessShareLock);
rel = table_open(DatabaseRelationId, AccessShareLock);

ScanKeyInit(&skey,
Anum_pg_database_oid,
Expand Down Expand Up @@ -110,7 +110,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
true);

systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);

/*
* Assign the default security label on the new database
Expand Down
4 changes: 2 additions & 2 deletions contrib/sepgsql/label.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
* Open the target catalog. We don't want to allow writable accesses by
* other session during initial labeling.
*/
rel = heap_open(catalogId, AccessShareLock);
rel = table_open(catalogId, AccessShareLock);

sscan = systable_beginscan(rel, InvalidOid, false,
NULL, 0, NULL);
Expand Down Expand Up @@ -881,7 +881,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
}
systable_endscan(sscan);

heap_close(rel, NoLock);
table_close(rel, NoLock);
}

/*
Expand Down
8 changes: 4 additions & 4 deletions contrib/sepgsql/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sepgsql_proc_post_create(Oid functionId)
* Fetch namespace of the new procedure. Because pg_proc entry is not
* visible right now, we need to scan the catalog using SnapshotSelf.
*/
rel = heap_open(ProcedureRelationId, AccessShareLock);
rel = table_open(ProcedureRelationId, AccessShareLock);

ScanKeyInit(&skey,
Anum_pg_proc_oid,
Expand Down Expand Up @@ -141,7 +141,7 @@ sepgsql_proc_post_create(Oid functionId)
* Cleanup
*/
systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);

pfree(audit_name.data);
pfree(tcontext);
Expand Down Expand Up @@ -250,7 +250,7 @@ sepgsql_proc_setattr(Oid functionId)
/*
* Fetch newer catalog
*/
rel = heap_open(ProcedureRelationId, AccessShareLock);
rel = table_open(ProcedureRelationId, AccessShareLock);

ScanKeyInit(&skey,
Anum_pg_proc_oid,
Expand Down Expand Up @@ -305,7 +305,7 @@ sepgsql_proc_setattr(Oid functionId)

ReleaseSysCache(oldtup);
systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);
}

/*
Expand Down
20 changes: 10 additions & 10 deletions contrib/sepgsql/relation.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
* Compute a default security label of the new column underlying the
* specified relation, and check permission to create it.
*/
rel = heap_open(AttributeRelationId, AccessShareLock);
rel = table_open(AttributeRelationId, AccessShareLock);

ScanKeyInit(&skey[0],
Anum_pg_attribute_attrelid,
Expand Down Expand Up @@ -120,7 +120,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext);

systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);

pfree(tcontext);
pfree(ncontext);
Expand Down Expand Up @@ -259,7 +259,7 @@ sepgsql_relation_post_create(Oid relOid)
* Fetch catalog record of the new relation. Because pg_class entry is not
* visible right now, we need to scan the catalog using SnapshotSelf.
*/
rel = heap_open(RelationRelationId, AccessShareLock);
rel = table_open(RelationRelationId, AccessShareLock);

ScanKeyInit(&skey,
Anum_pg_class_oid,
Expand Down Expand Up @@ -358,7 +358,7 @@ sepgsql_relation_post_create(Oid relOid)
HeapTuple atup;
Form_pg_attribute attForm;

arel = heap_open(AttributeRelationId, AccessShareLock);
arel = table_open(AttributeRelationId, AccessShareLock);

ScanKeyInit(&akey,
Anum_pg_attribute_attrelid,
Expand Down Expand Up @@ -400,13 +400,13 @@ sepgsql_relation_post_create(Oid relOid)
pfree(ccontext);
}
systable_endscan(ascan);
heap_close(arel, AccessShareLock);
table_close(arel, AccessShareLock);
}
pfree(rcontext);

out:
systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);
}

/*
Expand Down Expand Up @@ -611,7 +611,7 @@ sepgsql_relation_setattr(Oid relOid)
/*
* Fetch newer catalog
*/
rel = heap_open(RelationRelationId, AccessShareLock);
rel = table_open(RelationRelationId, AccessShareLock);

ScanKeyInit(&skey,
Anum_pg_class_oid,
Expand Down Expand Up @@ -667,7 +667,7 @@ sepgsql_relation_setattr(Oid relOid)

ReleaseSysCache(oldtup);
systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);
}

/*
Expand Down Expand Up @@ -723,13 +723,13 @@ sepgsql_relation_setattr_extra(Relation catalog,
static void
sepgsql_index_modify(Oid indexOid)
{
Relation catalog = heap_open(IndexRelationId, AccessShareLock);
Relation catalog = table_open(IndexRelationId, AccessShareLock);

/* check db_table:{setattr} permission of the table being indexed */
sepgsql_relation_setattr_extra(catalog,
IndexRelidIndexId,
indexOid,
Anum_pg_index_indrelid,
Anum_pg_index_indexrelid);
heap_close(catalog, AccessShareLock);
table_close(catalog, AccessShareLock);
}
4 changes: 2 additions & 2 deletions contrib/sepgsql/schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sepgsql_schema_post_create(Oid namespaceId)
* handle special treatment on default security label; such as special
* label on "pg_temp" schema.
*/
rel = heap_open(NamespaceRelationId, AccessShareLock);
rel = table_open(NamespaceRelationId, AccessShareLock);

ScanKeyInit(&skey,
Anum_pg_namespace_oid,
Expand Down Expand Up @@ -93,7 +93,7 @@ sepgsql_schema_post_create(Oid namespaceId)
audit_name.data,
true);
systable_endscan(sscan);
heap_close(rel, AccessShareLock);
table_close(rel, AccessShareLock);

/*
* Assign the default security label on a new procedure
Expand Down
Loading

0 comments on commit e0c4ec0

Please sign in to comment.