Skip to content

Commit e0c4ec0

Browse files
committed
Replace uses of heap_open et al with the corresponding table_* function.
Author: Andres Freund Discussion: https://postgr.es/m/[email protected]
1 parent 111944c commit e0c4ec0

File tree

114 files changed

+1259
-1259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1259
-1259
lines changed

contrib/amcheck/verify_nbtree.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed)
219219
*/
220220
heapid = IndexGetRelation(indrelid, true);
221221
if (OidIsValid(heapid))
222-
heaprel = heap_open(heapid, lockmode);
222+
heaprel = table_open(heapid, lockmode);
223223
else
224224
heaprel = NULL;
225225

@@ -261,7 +261,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed)
261261
*/
262262
index_close(indrel, lockmode);
263263
if (heaprel)
264-
heap_close(heaprel, lockmode);
264+
table_close(heaprel, lockmode);
265265
}
266266

267267
/*

contrib/dblink/dblink.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
20502050
tupdesc = rel->rd_att;
20512051

20522052
/* Prepare to scan pg_index for entries having indrelid = this rel. */
2053-
indexRelation = heap_open(IndexRelationId, AccessShareLock);
2053+
indexRelation = table_open(IndexRelationId, AccessShareLock);
20542054
ScanKeyInit(&skey,
20552055
Anum_pg_index_indrelid,
20562056
BTEqualStrategyNumber, F_OIDEQ,
@@ -2079,7 +2079,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
20792079
}
20802080

20812081
systable_endscan(scan);
2082-
heap_close(indexRelation, AccessShareLock);
2082+
table_close(indexRelation, AccessShareLock);
20832083

20842084
return result;
20852085
}
@@ -2503,7 +2503,7 @@ get_rel_from_relname(text *relname_text, LOCKMODE lockmode, AclMode aclmode)
25032503
AclResult aclresult;
25042504

25052505
relvar = makeRangeVarFromNameList(textToQualifiedNameList(relname_text));
2506-
rel = heap_openrv(relvar, lockmode);
2506+
rel = table_openrv(relvar, lockmode);
25072507

25082508
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
25092509
aclmode);

contrib/file_fdw/file_fdw.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ get_file_fdw_attribute_options(Oid relid)
439439

440440
List *options = NIL;
441441

442-
rel = heap_open(relid, AccessShareLock);
442+
rel = table_open(relid, AccessShareLock);
443443
tupleDesc = RelationGetDescr(rel);
444444
natts = tupleDesc->natts;
445445

@@ -481,7 +481,7 @@ get_file_fdw_attribute_options(Oid relid)
481481
}
482482
}
483483

484-
heap_close(rel, AccessShareLock);
484+
table_close(rel, AccessShareLock);
485485

486486
/*
487487
* Return DefElem only when some column(s) have force_not_null /
@@ -892,7 +892,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
892892
}
893893

894894
/* Convert attribute numbers to column names. */
895-
rel = heap_open(foreigntableid, AccessShareLock);
895+
rel = table_open(foreigntableid, AccessShareLock);
896896
tupleDesc = RelationGetDescr(rel);
897897

898898
while ((attnum = bms_first_member(attrs_used)) >= 0)
@@ -934,7 +934,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
934934
numattrs++;
935935
}
936936

937-
heap_close(rel, AccessShareLock);
937+
table_close(rel, AccessShareLock);
938938

939939
/* If there's a whole-row reference, fail: we need all the columns. */
940940
if (has_wholerow)

contrib/pgrowlocks/pgrowlocks.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
307307
}
308308

309309
heap_endscan(scan);
310-
heap_close(mydata->rel, AccessShareLock);
310+
table_close(mydata->rel, AccessShareLock);
311311

312312
SRF_RETURN_DONE(funcctx);
313313
}

contrib/postgres_fdw/deparse.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1048,11 +1048,11 @@ deparseSelectSql(List *tlist, bool is_subquery, List **retrieved_attrs,
10481048
* Core code already has some lock on each rel being planned, so we
10491049
* can use NoLock here.
10501050
*/
1051-
Relation rel = heap_open(rte->relid, NoLock);
1051+
Relation rel = table_open(rte->relid, NoLock);
10521052

10531053
deparseTargetList(buf, rte, foreignrel->relid, rel, false,
10541054
fpinfo->attrs_used, false, retrieved_attrs);
1055-
heap_close(rel, NoLock);
1055+
table_close(rel, NoLock);
10561056
}
10571057
}
10581058

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

15481548
deparseRelation(buf, rel);
15491549

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

1558-
heap_close(rel, NoLock);
1558+
table_close(rel, NoLock);
15591559
}
15601560
}
15611561

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

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

2135-
heap_close(rel, NoLock);
2135+
table_close(rel, NoLock);
21362136
bms_free(attrs_used);
21372137
}
21382138
else

contrib/postgres_fdw/postgres_fdw.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ postgresPlanForeignModify(PlannerInfo *root,
16161616
* Core code already has some lock on each rel being planned, so we can
16171617
* use NoLock here.
16181618
*/
1619-
rel = heap_open(rte->relid, NoLock);
1619+
rel = table_open(rte->relid, NoLock);
16201620

16211621
/*
16221622
* In an INSERT, we transmit all columns that are defined in the foreign
@@ -1706,7 +1706,7 @@ postgresPlanForeignModify(PlannerInfo *root,
17061706
break;
17071707
}
17081708

1709-
heap_close(rel, NoLock);
1709+
table_close(rel, NoLock);
17101710

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

21262126
/*
21272127
* Recall the qual clauses that must be evaluated remotely. (These are
@@ -2207,7 +2207,7 @@ postgresPlanDirectModify(PlannerInfo *root,
22072207
rebuild_fdw_scan_tlist(fscan, returningList);
22082208
}
22092209

2210-
heap_close(rel, NoLock);
2210+
table_close(rel, NoLock);
22112211
return true;
22122212
}
22132213

contrib/sepgsql/database.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
7777
* XXX - uncoming version of libselinux supports to take object name to
7878
* handle special treatment on default security label.
7979
*/
80-
rel = heap_open(DatabaseRelationId, AccessShareLock);
80+
rel = table_open(DatabaseRelationId, AccessShareLock);
8181

8282
ScanKeyInit(&skey,
8383
Anum_pg_database_oid,
@@ -110,7 +110,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
110110
true);
111111

112112
systable_endscan(sscan);
113-
heap_close(rel, AccessShareLock);
113+
table_close(rel, AccessShareLock);
114114

115115
/*
116116
* Assign the default security label on the new database

contrib/sepgsql/label.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
727727
* Open the target catalog. We don't want to allow writable accesses by
728728
* other session during initial labeling.
729729
*/
730-
rel = heap_open(catalogId, AccessShareLock);
730+
rel = table_open(catalogId, AccessShareLock);
731731

732732
sscan = systable_beginscan(rel, InvalidOid, false,
733733
NULL, 0, NULL);
@@ -881,7 +881,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
881881
}
882882
systable_endscan(sscan);
883883

884-
heap_close(rel, NoLock);
884+
table_close(rel, NoLock);
885885
}
886886

887887
/*

contrib/sepgsql/proc.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ sepgsql_proc_post_create(Oid functionId)
5656
* Fetch namespace of the new procedure. Because pg_proc entry is not
5757
* visible right now, we need to scan the catalog using SnapshotSelf.
5858
*/
59-
rel = heap_open(ProcedureRelationId, AccessShareLock);
59+
rel = table_open(ProcedureRelationId, AccessShareLock);
6060

6161
ScanKeyInit(&skey,
6262
Anum_pg_proc_oid,
@@ -141,7 +141,7 @@ sepgsql_proc_post_create(Oid functionId)
141141
* Cleanup
142142
*/
143143
systable_endscan(sscan);
144-
heap_close(rel, AccessShareLock);
144+
table_close(rel, AccessShareLock);
145145

146146
pfree(audit_name.data);
147147
pfree(tcontext);
@@ -250,7 +250,7 @@ sepgsql_proc_setattr(Oid functionId)
250250
/*
251251
* Fetch newer catalog
252252
*/
253-
rel = heap_open(ProcedureRelationId, AccessShareLock);
253+
rel = table_open(ProcedureRelationId, AccessShareLock);
254254

255255
ScanKeyInit(&skey,
256256
Anum_pg_proc_oid,
@@ -305,7 +305,7 @@ sepgsql_proc_setattr(Oid functionId)
305305

306306
ReleaseSysCache(oldtup);
307307
systable_endscan(sscan);
308-
heap_close(rel, AccessShareLock);
308+
table_close(rel, AccessShareLock);
309309
}
310310

311311
/*

contrib/sepgsql/relation.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
6767
* Compute a default security label of the new column underlying the
6868
* specified relation, and check permission to create it.
6969
*/
70-
rel = heap_open(AttributeRelationId, AccessShareLock);
70+
rel = table_open(AttributeRelationId, AccessShareLock);
7171

7272
ScanKeyInit(&skey[0],
7373
Anum_pg_attribute_attrelid,
@@ -120,7 +120,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
120120
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext);
121121

122122
systable_endscan(sscan);
123-
heap_close(rel, AccessShareLock);
123+
table_close(rel, AccessShareLock);
124124

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

264264
ScanKeyInit(&skey,
265265
Anum_pg_class_oid,
@@ -358,7 +358,7 @@ sepgsql_relation_post_create(Oid relOid)
358358
HeapTuple atup;
359359
Form_pg_attribute attForm;
360360

361-
arel = heap_open(AttributeRelationId, AccessShareLock);
361+
arel = table_open(AttributeRelationId, AccessShareLock);
362362

363363
ScanKeyInit(&akey,
364364
Anum_pg_attribute_attrelid,
@@ -400,13 +400,13 @@ sepgsql_relation_post_create(Oid relOid)
400400
pfree(ccontext);
401401
}
402402
systable_endscan(ascan);
403-
heap_close(arel, AccessShareLock);
403+
table_close(arel, AccessShareLock);
404404
}
405405
pfree(rcontext);
406406

407407
out:
408408
systable_endscan(sscan);
409-
heap_close(rel, AccessShareLock);
409+
table_close(rel, AccessShareLock);
410410
}
411411

412412
/*
@@ -611,7 +611,7 @@ sepgsql_relation_setattr(Oid relOid)
611611
/*
612612
* Fetch newer catalog
613613
*/
614-
rel = heap_open(RelationRelationId, AccessShareLock);
614+
rel = table_open(RelationRelationId, AccessShareLock);
615615

616616
ScanKeyInit(&skey,
617617
Anum_pg_class_oid,
@@ -667,7 +667,7 @@ sepgsql_relation_setattr(Oid relOid)
667667

668668
ReleaseSysCache(oldtup);
669669
systable_endscan(sscan);
670-
heap_close(rel, AccessShareLock);
670+
table_close(rel, AccessShareLock);
671671
}
672672

673673
/*
@@ -723,13 +723,13 @@ sepgsql_relation_setattr_extra(Relation catalog,
723723
static void
724724
sepgsql_index_modify(Oid indexOid)
725725
{
726-
Relation catalog = heap_open(IndexRelationId, AccessShareLock);
726+
Relation catalog = table_open(IndexRelationId, AccessShareLock);
727727

728728
/* check db_table:{setattr} permission of the table being indexed */
729729
sepgsql_relation_setattr_extra(catalog,
730730
IndexRelidIndexId,
731731
indexOid,
732732
Anum_pg_index_indrelid,
733733
Anum_pg_index_indexrelid);
734-
heap_close(catalog, AccessShareLock);
734+
table_close(catalog, AccessShareLock);
735735
}

contrib/sepgsql/schema.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ sepgsql_schema_post_create(Oid namespaceId)
5656
* handle special treatment on default security label; such as special
5757
* label on "pg_temp" schema.
5858
*/
59-
rel = heap_open(NamespaceRelationId, AccessShareLock);
59+
rel = table_open(NamespaceRelationId, AccessShareLock);
6060

6161
ScanKeyInit(&skey,
6262
Anum_pg_namespace_oid,
@@ -93,7 +93,7 @@ sepgsql_schema_post_create(Oid namespaceId)
9393
audit_name.data,
9494
true);
9595
systable_endscan(sscan);
96-
heap_close(rel, AccessShareLock);
96+
table_close(rel, AccessShareLock);
9797

9898
/*
9999
* Assign the default security label on a new procedure

0 commit comments

Comments
 (0)