summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c388
1 files changed, 194 insertions, 194 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 1a1ac698e54..ffb86ab139a 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -833,7 +833,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
defaultRel = NULL;
/* Already have strong enough lock on the parent */
- parent = heap_open(parentId, NoLock);
+ parent = table_open(parentId, NoLock);
/*
* We are going to try to validate the partition bound specification
@@ -867,7 +867,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
defaultPartOid =
get_default_oid_from_partdesc(RelationGetPartitionDesc(parent));
if (OidIsValid(defaultPartOid))
- defaultRel = heap_open(defaultPartOid, AccessExclusiveLock);
+ defaultRel = table_open(defaultPartOid, AccessExclusiveLock);
/* Transform the bound values */
pstate = make_parsestate(NULL);
@@ -892,13 +892,13 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
{
check_default_partition_contents(parent, defaultRel, bound);
/* Keep the lock until commit. */
- heap_close(defaultRel, NoLock);
+ table_close(defaultRel, NoLock);
}
/* Update the pg_class entry. */
StorePartitionBound(rel, parent, bound);
- heap_close(parent, NoLock);
+ table_close(parent, NoLock);
}
/* Store inheritance information for new rel. */
@@ -965,7 +965,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
ListCell *cell;
/* Already have strong enough lock on the parent */
- parent = heap_open(parentId, NoLock);
+ parent = table_open(parentId, NoLock);
idxlist = RelationGetIndexList(parent);
/*
@@ -1010,7 +1010,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
*/
CloneForeignKeyConstraints(parentId, relationId, NULL);
- heap_close(parent, NoLock);
+ table_close(parent, NoLock);
}
/*
@@ -1384,12 +1384,12 @@ ExecuteTruncate(TruncateStmt *stmt)
NULL);
/* open the relation, we already hold a lock on it */
- rel = heap_open(myrelid, NoLock);
+ rel = table_open(myrelid, NoLock);
/* don't throw error for "TRUNCATE foo, foo" */
if (list_member_oid(relids, myrelid))
{
- heap_close(rel, lockmode);
+ table_close(rel, lockmode);
continue;
}
@@ -1420,7 +1420,7 @@ ExecuteTruncate(TruncateStmt *stmt)
continue;
/* find_all_inheritors already got lock */
- rel = heap_open(childrelid, NoLock);
+ rel = table_open(childrelid, NoLock);
/*
* It is possible that the parent table has children that are
@@ -1433,7 +1433,7 @@ ExecuteTruncate(TruncateStmt *stmt)
*/
if (RELATION_IS_OTHER_TEMP(rel))
{
- heap_close(rel, lockmode);
+ table_close(rel, lockmode);
continue;
}
@@ -1462,7 +1462,7 @@ ExecuteTruncate(TruncateStmt *stmt)
{
Relation rel = (Relation) lfirst(cell);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -1518,7 +1518,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
Oid relid = lfirst_oid(cell);
Relation rel;
- rel = heap_open(relid, AccessExclusiveLock);
+ rel = table_open(relid, AccessExclusiveLock);
ereport(NOTICE,
(errmsg("truncate cascades to table \"%s\"",
RelationGetRelationName(rel))));
@@ -1687,7 +1687,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
RecentXmin, minmulti);
if (toastrel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
heap_create_init_fork(toastrel);
- heap_close(toastrel, NoLock);
+ table_close(toastrel, NoLock);
}
/*
@@ -1771,7 +1771,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
{
Relation rel = (Relation) lfirst(cell);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -2026,7 +2026,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
AttrNumber parent_attno;
/* caller already got lock */
- relation = heap_open(parent, NoLock);
+ relation = table_open(parent, NoLock);
/*
* Check for active uses of the parent partitioned table in the
@@ -2317,7 +2317,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
* That will prevent someone else from deleting or ALTERing the parent
* before the child is committed.
*/
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
}
/*
@@ -2595,7 +2595,7 @@ StoreCatalogInheritance(Oid relationId, List *supers,
* and then entered into pg_ipl. Since that catalog doesn't exist
* anymore, there's no need to look for indirect ancestors.)
*/
- relation = heap_open(InheritsRelationId, RowExclusiveLock);
+ relation = table_open(InheritsRelationId, RowExclusiveLock);
seqNumber = 1;
foreach(entry, supers)
@@ -2607,7 +2607,7 @@ StoreCatalogInheritance(Oid relationId, List *supers,
seqNumber++;
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/*
@@ -2701,7 +2701,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
/*
* Fetch a modifiable copy of the tuple, modify it, update pg_class.
*/
- 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);
@@ -2719,7 +2719,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
}
heap_freetuple(tuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
}
/*
@@ -2864,7 +2864,7 @@ renameatt_internal(Oid myrelid,
renameatt_internal(lfirst_oid(lo), oldattname, newattname, true, true, 0, behavior);
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
atttup = SearchSysCacheCopyAttName(myrelid, oldattname);
if (!HeapTupleIsValid(atttup))
@@ -2908,7 +2908,7 @@ renameatt_internal(Oid myrelid,
heap_freetuple(atttup);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
relation_close(targetrelation, NoLock); /* close rel but keep lock */
@@ -3094,13 +3094,13 @@ RenameConstraint(RenameStmt *stmt)
HeapTuple tup;
typid = typenameTypeId(NULL, makeTypeNameFromNameList(castNode(List, stmt->object)));
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
checkDomainOwner(tup);
ReleaseSysCache(tup);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
else
{
@@ -3198,7 +3198,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
/*
* Find relation's pg_class tuple, and make sure newrelname isn't in use.
*/
- relrelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relrelation = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
@@ -3223,7 +3223,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
InvalidOid, is_internal);
heap_freetuple(reltup);
- heap_close(relrelation, RowExclusiveLock);
+ table_close(relrelation, RowExclusiveLock);
/*
* Also rename the associated type, if any.
@@ -4372,9 +4372,9 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
{
Relation rel;
- rel = heap_open(tab->relid, NoLock);
+ rel = table_open(tab->relid, NoLock);
find_composite_type_dependencies(rel->rd_rel->reltype, rel, NULL);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -4397,7 +4397,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
Oid NewTableSpace;
char persistence;
- OldHeap = heap_open(tab->relid, NoLock);
+ OldHeap = table_open(tab->relid, NoLock);
/*
* We don't support rewriting of system catalogs; there are too
@@ -4441,7 +4441,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
persistence = tab->chgPersistence ?
tab->newrelpersistence : OldHeap->rd_rel->relpersistence;
- heap_close(OldHeap, NoLock);
+ table_close(OldHeap, NoLock);
/*
* Fire off an Event Trigger now, before actually rewriting the
@@ -4542,10 +4542,10 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
if (rel == NULL)
{
/* Long since locked, no need for another */
- rel = heap_open(tab->relid, NoLock);
+ rel = table_open(tab->relid, NoLock);
}
- refrel = heap_open(con->refrelid, RowShareLock);
+ refrel = table_open(con->refrelid, RowShareLock);
validateForeignKeyConstraint(fkconstraint->conname, rel, refrel,
con->refindid,
@@ -4556,12 +4556,12 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
* that when we inserted the row earlier.
*/
- heap_close(refrel, NoLock);
+ table_close(refrel, NoLock);
}
}
if (rel)
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -4591,12 +4591,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
* Open the relation(s). We have surely already locked the existing
* table.
*/
- oldrel = heap_open(tab->relid, NoLock);
+ oldrel = table_open(tab->relid, NoLock);
oldTupDesc = tab->oldDesc;
newTupDesc = RelationGetDescr(oldrel); /* includes all mods */
if (OidIsValid(OIDNewHeap))
- newrel = heap_open(OIDNewHeap, lockmode);
+ newrel = table_open(OIDNewHeap, lockmode);
else
newrel = NULL;
@@ -4872,7 +4872,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
FreeExecutorState(estate);
- heap_close(oldrel, NoLock);
+ table_close(oldrel, NoLock);
if (newrel)
{
FreeBulkInsertState(bistate);
@@ -4881,7 +4881,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (hi_options & HEAP_INSERT_SKIP_WAL)
heap_sync(newrel);
- heap_close(newrel, NoLock);
+ table_close(newrel, NoLock);
}
}
@@ -5151,7 +5151,7 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
* We scan pg_depend to find those things that depend on the given type.
* (We assume we can ignore refobjsubid for a type.)
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -5262,7 +5262,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
HeapTuple tuple;
List *result = NIL;
- classRel = heap_open(RelationRelationId, AccessShareLock);
+ classRel = table_open(RelationRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_class_reloftype,
@@ -5286,7 +5286,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
}
heap_endscan(scan);
- heap_close(classRel, AccessShareLock);
+ table_close(classRel, AccessShareLock);
return result;
}
@@ -5398,7 +5398,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot add column to a partition")));
- attrdesc = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrdesc = table_open(AttributeRelationId, RowExclusiveLock);
/*
* Are we adding the column to a recursion child? If so, check whether to
@@ -5448,12 +5448,12 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
(errmsg("merging definition of column \"%s\" for child \"%s\"",
colDef->colname, RelationGetRelationName(rel))));
- heap_close(attrdesc, RowExclusiveLock);
+ table_close(attrdesc, RowExclusiveLock);
return InvalidObjectAddress;
}
}
- pgclass = heap_open(RelationRelationId, RowExclusiveLock);
+ pgclass = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
@@ -5474,9 +5474,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* skip if the name already exists and if_not_exists is true */
if (!check_for_column_name_collision(rel, colDef->colname, if_not_exists))
{
- heap_close(attrdesc, RowExclusiveLock);
+ table_close(attrdesc, RowExclusiveLock);
heap_freetuple(reltup);
- heap_close(pgclass, RowExclusiveLock);
+ table_close(pgclass, RowExclusiveLock);
return InvalidObjectAddress;
}
@@ -5529,7 +5529,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
InsertPgAttributeTuple(attrdesc, &attribute, NULL);
- heap_close(attrdesc, RowExclusiveLock);
+ table_close(attrdesc, RowExclusiveLock);
/*
* Update pg_class tuple as appropriate
@@ -5543,7 +5543,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* Post creation hook for new attribute */
InvokeObjectPostCreateHook(RelationRelationId, myrelid, newattnum);
- heap_close(pgclass, RowExclusiveLock);
+ table_close(pgclass, RowExclusiveLock);
/* Make the attribute's catalog entry visible */
CommandCounterIncrement();
@@ -5719,7 +5719,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
AlteredTableInfo *childtab;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
/* Find or create work queue entry for this table */
@@ -5730,7 +5730,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
colDef, recurse, true,
if_not_exists, lockmode);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
ObjectAddressSubSet(address, RelationRelationId, myrelid, newattnum);
@@ -5871,7 +5871,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
/*
* lookup the attribute
*/
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
@@ -5942,7 +5942,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
if (rel->rd_rel->relispartition)
{
Oid parentId = get_partition_parent(RelationGetRelid(rel));
- Relation parent = heap_open(parentId, AccessShareLock);
+ Relation parent = table_open(parentId, AccessShareLock);
TupleDesc tupDesc = RelationGetDescr(parent);
AttrNumber parent_attnum;
@@ -5952,7 +5952,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("column \"%s\" is marked NOT NULL in parent table",
colName)));
- heap_close(parent, AccessShareLock);
+ table_close(parent, AccessShareLock);
}
/*
@@ -5973,7 +5973,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel), attnum);
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
return address;
}
@@ -6018,7 +6018,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/*
* lookup the attribute
*/
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
@@ -6058,7 +6058,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel), attnum);
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
return address;
}
@@ -6151,7 +6151,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
ObjectAddress address;
ColumnDef *cdef = castNode(ColumnDef, def);
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
@@ -6202,7 +6202,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
RelationGetRelid(rel), attnum);
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6246,7 +6246,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
* there.
*/
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -6284,7 +6284,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
address = InvalidObjectAddress;
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6305,7 +6305,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
Oid seqid;
ObjectAddress seqaddress;
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -6335,7 +6335,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
(errmsg("column \"%s\" of relation \"%s\" is not an identity column, skipping",
colName, RelationGetRelationName(rel))));
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return InvalidObjectAddress;
}
}
@@ -6350,7 +6350,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
RelationGetRelid(rel), attnum);
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
/* drop the internal sequence */
seqid = getOwnedSequence(RelationGetRelid(rel), attnum);
@@ -6440,7 +6440,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
newtarget)));
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
if (colName)
{
@@ -6499,7 +6499,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
RelationGetRelid(rel), attnum);
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6524,7 +6524,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
@@ -6575,7 +6575,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
ReleaseSysCache(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6616,7 +6616,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
newstorage = 0; /* keep compiler quiet */
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
@@ -6654,7 +6654,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
ObjectAddressSubSet(address, RelationRelationId,
RelationGetRelid(rel), attnum);
@@ -6785,7 +6785,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
errmsg("cannot drop column from only the partitioned table when partitions exist"),
errhint("Do not specify the ONLY keyword.")));
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
foreach(child, children)
{
Oid childrelid = lfirst_oid(child);
@@ -6793,7 +6793,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
Form_pg_attribute childatt;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
tuple = SearchSysCacheCopyAttName(childrelid, colName);
@@ -6849,9 +6849,9 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
heap_freetuple(tuple);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
}
/*
@@ -7206,7 +7206,7 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
AlteredTableInfo *childtab;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
/* Find or create work queue entry for this table */
@@ -7216,7 +7216,7 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
ATAddCheckConstraint(wqueue, childtab, childrel,
constr, recurse, true, is_readd, lockmode);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
return address;
@@ -7258,9 +7258,9 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
* delete rows out from under us.
*/
if (OidIsValid(fkconstraint->old_pktable_oid))
- pkrel = heap_open(fkconstraint->old_pktable_oid, ShareRowExclusiveLock);
+ pkrel = table_open(fkconstraint->old_pktable_oid, ShareRowExclusiveLock);
else
- pkrel = heap_openrv(fkconstraint->pktable, ShareRowExclusiveLock);
+ pkrel = table_openrv(fkconstraint->pktable, ShareRowExclusiveLock);
/*
* Validity checks (permission checks wait till we have the column
@@ -7662,13 +7662,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
List *cloned = NIL;
ListCell *cell;
- pg_constraint = heap_open(ConstraintRelationId, RowExclusiveLock);
+ pg_constraint = table_open(ConstraintRelationId, RowExclusiveLock);
partdesc = RelationGetPartitionDesc(rel);
for (i = 0; i < partdesc->nparts; i++)
{
Oid partitionId = partdesc->oids[i];
- Relation partition = heap_open(partitionId, lockmode);
+ Relation partition = table_open(partitionId, lockmode);
CheckTableNotInUse(partition, "ALTER TABLE");
@@ -7676,14 +7676,14 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
list_make1_oid(constrOid),
&cloned);
- heap_close(partition, NoLock);
+ table_close(partition, NoLock);
}
- heap_close(pg_constraint, RowExclusiveLock);
+ table_close(pg_constraint, RowExclusiveLock);
foreach(cell, cloned)
{
ClonedConstraint *cc = (ClonedConstraint *) lfirst(cell);
- Relation partition = heap_open(cc->relid, lockmode);
+ Relation partition = table_open(cc->relid, lockmode);
AlteredTableInfo *childtab;
NewConstraint *newcon;
@@ -7700,14 +7700,14 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
childtab->constraints = lappend(childtab->constraints, newcon);
- heap_close(partition, lockmode);
+ table_close(partition, lockmode);
}
}
/*
* Close pk table, but keep lock until we've committed.
*/
- heap_close(pkrel, NoLock);
+ table_close(pkrel, NoLock);
return address;
}
@@ -7736,10 +7736,10 @@ CloneForeignKeyConstraints(Oid parentId, Oid relationId, List **cloned)
HeapTuple tuple;
List *clone = NIL;
- parentRel = heap_open(parentId, NoLock); /* already got lock */
+ parentRel = table_open(parentId, NoLock); /* already got lock */
/* see ATAddForeignKeyConstraint about lock level */
- rel = heap_open(relationId, AccessExclusiveLock);
- pg_constraint = heap_open(ConstraintRelationId, RowShareLock);
+ rel = table_open(relationId, AccessExclusiveLock);
+ pg_constraint = table_open(ConstraintRelationId, RowShareLock);
/* Obtain the list of constraints to clone or attach */
ScanKeyInit(&key,
@@ -7759,9 +7759,9 @@ CloneForeignKeyConstraints(Oid parentId, Oid relationId, List **cloned)
CloneFkReferencing(pg_constraint, parentRel, rel, clone, cloned);
/* We're done. Clean up */
- heap_close(parentRel, NoLock);
- heap_close(rel, NoLock); /* keep lock till commit */
- heap_close(pg_constraint, RowShareLock);
+ table_close(parentRel, NoLock);
+ table_close(rel, NoLock); /* keep lock till commit */
+ table_close(pg_constraint, RowShareLock);
}
/*
@@ -8003,13 +8003,13 @@ CloneFkReferencing(Relation pg_constraint, Relation parentRel,
{
Relation childRel;
- childRel = heap_open(partdesc->oids[i], AccessExclusiveLock);
+ childRel = table_open(partdesc->oids[i], AccessExclusiveLock);
CloneFkReferencing(pg_constraint,
partRel,
childRel,
subclone,
cloned);
- heap_close(childRel, NoLock); /* keep lock till commit */
+ table_close(childRel, NoLock); /* keep lock till commit */
}
}
}
@@ -8041,7 +8041,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
cmdcon = castNode(Constraint, cmd->def);
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/*
* Find and check the target constraint
@@ -8105,7 +8105,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
* Now we need to update the multiple entries in pg_trigger that
* implement the constraint.
*/
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(TriggerRelationId, RowExclusiveLock);
ScanKeyInit(&tgkey,
Anum_pg_trigger_tgconstraint,
@@ -8156,7 +8156,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
systable_endscan(tgscan);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
/*
* Invalidate relcache so that others see the new attributes. We must
@@ -8177,7 +8177,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
systable_endscan(scan);
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
return address;
}
@@ -8204,7 +8204,7 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
Form_pg_constraint con;
ObjectAddress address;
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/*
* Find and check the target constraint
@@ -8256,12 +8256,12 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
* might need to fire triggers to perform the check, so we take a
* lock at RowShareLock level just in case.
*/
- refrel = heap_open(con->confrelid, RowShareLock);
+ refrel = table_open(con->confrelid, RowShareLock);
validateForeignKeyConstraint(constrName, rel, refrel,
con->conindid,
con->oid);
- heap_close(refrel, NoLock);
+ table_close(refrel, NoLock);
/*
* We disallow creating invalid foreign keys to or from
@@ -8309,11 +8309,11 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
errmsg("constraint must be validated on child tables too")));
/* find_all_inheritors already got lock */
- childrel = heap_open(childoid, NoLock);
+ childrel = table_open(childoid, NoLock);
ATExecValidateConstraint(childrel, constrName, false,
true, lockmode);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
validateCheckConstraint(rel, tuple);
@@ -8344,7 +8344,7 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
systable_endscan(scan);
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
return address;
}
@@ -9101,7 +9101,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
if (recursing)
ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/*
* Find and drop the target constraint
@@ -9150,9 +9150,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
Relation frel;
/* Must match lock taken by RemoveTriggerById: */
- frel = heap_open(con->confrelid, AccessExclusiveLock);
+ frel = table_open(con->confrelid, AccessExclusiveLock);
CheckTableNotInUse(frel, "ALTER TABLE");
- heap_close(frel, NoLock);
+ table_close(frel, NoLock);
}
/*
@@ -9183,7 +9183,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
ereport(NOTICE,
(errmsg("constraint \"%s\" of relation \"%s\" does not exist, skipping",
constrName, RelationGetRelationName(rel))));
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
return;
}
}
@@ -9217,7 +9217,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
HeapTuple copy_tuple;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
ScanKeyInit(&skey[0],
@@ -9298,10 +9298,10 @@ ATExecDropConstraint(Relation rel, const char *constrName,
heap_freetuple(copy_tuple);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
}
/*
@@ -9618,14 +9618,14 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
{
Relation newrel;
- newrel = heap_open(RelationGetRelid(rel), NoLock);
+ newrel = table_open(RelationGetRelid(rel), NoLock);
RelationClearMissing(newrel);
relation_close(newrel, NoLock);
/* make sure we don't conflict with later attribute modifications */
CommandCounterIncrement();
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
/* Look up the target column */
heapTup = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
@@ -9699,7 +9699,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
* that implements a constraint will not show a direct dependency on the
* column.
*/
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -9936,7 +9936,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
systable_endscan(scan);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
/*
* Here we go --- change the recorded column type and collation. (Note
@@ -10020,7 +10020,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
CatalogTupleUpdate(attrelation, &heapTup->t_self, heapTup);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
/* Install dependencies on new datatype and collation */
add_column_datatype_dependency(RelationGetRelid(rel), attnum, targettype);
@@ -10094,7 +10094,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
return InvalidObjectAddress;
/* First, determine FDW validator associated to the foreign table. */
- ftrel = heap_open(ForeignTableRelationId, AccessShareLock);
+ ftrel = table_open(ForeignTableRelationId, AccessShareLock);
tuple = SearchSysCache1(FOREIGNTABLEREL, rel->rd_id);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -10105,10 +10105,10 @@ ATExecAlterColumnGenericOptions(Relation rel,
server = GetForeignServer(fttableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
- heap_close(ftrel, AccessShareLock);
+ table_close(ftrel, AccessShareLock);
ReleaseSysCache(tuple);
- attrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -10166,7 +10166,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
ReleaseSysCache(tuple);
- heap_close(attrel, RowExclusiveLock);
+ table_close(attrel, RowExclusiveLock);
heap_freetuple(newtuple);
@@ -10595,7 +10595,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
target_rel = relation_open(relationOid, lockmode);
/* Get its pg_class tuple, too */
- class_rel = heap_open(RelationRelationId, RowExclusiveLock);
+ class_rel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid));
if (!HeapTupleIsValid(tuple))
@@ -10809,7 +10809,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);
ReleaseSysCache(tuple);
- heap_close(class_rel, RowExclusiveLock);
+ table_close(class_rel, RowExclusiveLock);
relation_close(target_rel, NoLock);
}
@@ -10827,7 +10827,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
ScanKeyData key[1];
HeapTuple attributeTuple;
- attRelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attRelation = table_open(AttributeRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -10874,7 +10874,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
heap_freetuple(newtuple);
}
systable_endscan(scan);
- heap_close(attRelation, RowExclusiveLock);
+ table_close(attRelation, RowExclusiveLock);
}
/*
@@ -10896,7 +10896,7 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lock
* SERIAL sequences are those having an auto dependency on one of the
* table's columns (we don't care *which* column, exactly).
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -11043,7 +11043,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
if (defList == NIL && operation != AT_ReplaceRelOptions)
return; /* nothing to do */
- pgclass = heap_open(RelationRelationId, RowExclusiveLock);
+ pgclass = table_open(RelationRelationId, RowExclusiveLock);
/* Fetch heap tuple */
relid = RelationGetRelid(rel);
@@ -11161,7 +11161,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
Relation toastrel;
Oid toastid = rel->rd_rel->reltoastrelid;
- toastrel = heap_open(toastid, lockmode);
+ toastrel = table_open(toastid, lockmode);
/* Fetch heap tuple */
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(toastid));
@@ -11214,10 +11214,10 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
ReleaseSysCache(tuple);
- heap_close(toastrel, NoLock);
+ table_close(toastrel, NoLock);
}
- heap_close(pgclass, RowExclusiveLock);
+ table_close(pgclass, RowExclusiveLock);
}
/*
@@ -11295,7 +11295,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
}
/* Get a modifiable copy of the relation's pg_class row */
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(tableOid));
if (!HeapTupleIsValid(tuple))
@@ -11371,7 +11371,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
heap_freetuple(tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
relation_close(rel, NoLock);
@@ -11428,7 +11428,7 @@ ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
}
/* Get a modifiable copy of the relation's pg_class row */
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid));
if (!HeapTupleIsValid(tuple))
@@ -11443,7 +11443,7 @@ ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
heap_freetuple(tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
/* Make sure the reltablespace change is visible */
CommandCounterIncrement();
@@ -11532,7 +11532,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(orig_tablespaceoid));
- rel = heap_open(RelationRelationId, AccessShareLock);
+ rel = table_open(RelationRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
@@ -11593,7 +11593,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
if (relations == NIL)
ereport(NOTICE,
@@ -11773,7 +11773,7 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
* A self-exclusive lock is needed here. See the similar case in
* MergeAttributes() for a full explanation.
*/
- parent_rel = heap_openrv(parent, ShareUpdateExclusiveLock);
+ parent_rel = table_openrv(parent, ShareUpdateExclusiveLock);
/*
* Must be owner of both parent and child -- child was checked by
@@ -11861,7 +11861,7 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
RelationGetRelid(parent_rel));
/* keep our lock on the parent relation until commit */
- heap_close(parent_rel, NoLock);
+ table_close(parent_rel, NoLock);
return address;
}
@@ -11883,7 +11883,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
int32 inhseqno;
/* Note: get RowExclusiveLock because we will write pg_inherits below. */
- catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+ catalogRelation = table_open(InheritsRelationId, RowExclusiveLock);
/*
* Check for duplicates in the list of parents, and determine the highest
@@ -11935,7 +11935,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
RELKIND_PARTITIONED_TABLE);
/* Now we're done with pg_inherits */
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
}
/*
@@ -12006,7 +12006,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
HeapTuple tuple;
bool child_is_partition = false;
- attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrrel = table_open(AttributeRelationId, RowExclusiveLock);
tupleDesc = RelationGetDescr(parent_rel);
parent_natts = tupleDesc->natts;
@@ -12087,7 +12087,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
}
}
- heap_close(attrrel, RowExclusiveLock);
+ table_close(attrrel, RowExclusiveLock);
}
/*
@@ -12117,7 +12117,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
HeapTuple parent_tuple;
bool child_is_partition = false;
- catalog_relation = heap_open(ConstraintRelationId, RowExclusiveLock);
+ catalog_relation = table_open(ConstraintRelationId, RowExclusiveLock);
tuple_desc = RelationGetDescr(catalog_relation);
/* If parent_rel is a partitioned table, child_rel must be a partition */
@@ -12229,7 +12229,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
}
systable_endscan(parent_scan);
- heap_close(catalog_relation, RowExclusiveLock);
+ table_close(catalog_relation, RowExclusiveLock);
}
/*
@@ -12253,7 +12253,7 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
* TABLE doesn't lock parent tables at all. We need some lock since we'll
* be inspecting the parent's schema.
*/
- parent_rel = heap_openrv(parent, AccessShareLock);
+ parent_rel = table_openrv(parent, AccessShareLock);
/*
* We don't bother to check ownership of the parent table --- ownership of
@@ -12267,7 +12267,7 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
RelationGetRelid(parent_rel));
/* keep our lock on the parent relation until commit */
- heap_close(parent_rel, NoLock);
+ table_close(parent_rel, NoLock);
return address;
}
@@ -12327,7 +12327,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
/*
* Search through child columns looking for ones matching parent rel
*/
- catalogRelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ catalogRelation = table_open(AttributeRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -12360,7 +12360,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
}
}
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
/*
* Likewise, find inherited check constraints and disinherit them. To do
@@ -12368,7 +12368,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
* constraints. (We cheat a bit by only checking for name matches,
* assuming that the expressions will match.)
*/
- catalogRelation = heap_open(ConstraintRelationId, RowExclusiveLock);
+ catalogRelation = table_open(ConstraintRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -12435,7 +12435,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
}
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
drop_parent_dependency(RelationGetRelid(child_rel),
RelationRelationId,
@@ -12468,7 +12468,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
ScanKeyData key[3];
HeapTuple depTuple;
- catalogRelation = heap_open(DependRelationId, RowExclusiveLock);
+ catalogRelation = table_open(DependRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -12498,7 +12498,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
}
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
}
/*
@@ -12537,7 +12537,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
typeid = typeform->oid;
/* Fail if the table has any inheritance parents. */
- inheritsRelation = heap_open(InheritsRelationId, AccessShareLock);
+ inheritsRelation = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -12549,7 +12549,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("typed tables cannot inherit")));
systable_endscan(scan);
- heap_close(inheritsRelation, AccessShareLock);
+ table_close(inheritsRelation, AccessShareLock);
/*
* Check the tuple descriptors for compatibility. Unlike inheritance, we
@@ -12630,7 +12630,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
recordDependencyOn(&tableobj, &typeobj, DEPENDENCY_NORMAL);
/* Update pg_class.reloftype */
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
classtuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classtuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
@@ -12640,7 +12640,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
heap_freetuple(classtuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
ReleaseSysCache(typetuple);
@@ -12675,7 +12675,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
DEPENDENCY_NORMAL);
/* Clear pg_class.reloftype */
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
@@ -12685,7 +12685,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
heap_freetuple(tuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
}
/*
@@ -12710,7 +12710,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
/*
* Check whether relreplident has changed, and update it if so.
*/
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
pg_class_tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(pg_class_tuple))
@@ -12722,7 +12722,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
pg_class_form->relreplident = ri_type;
CatalogTupleUpdate(pg_class, &pg_class_tuple->t_self, pg_class_tuple);
}
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(pg_class_tuple);
/*
@@ -12750,7 +12750,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
* Clear the indisreplident flag from any index that had it previously,
* and set it for any index that should have it now.
*/
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
foreach(index, RelationGetIndexList(rel))
{
Oid thisIndexOid = lfirst_oid(index);
@@ -12786,7 +12786,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
heap_freetuple(pg_index_tuple);
}
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
/*
@@ -12916,7 +12916,7 @@ ATExecEnableRowSecurity(Relation rel)
relid = RelationGetRelid(rel);
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -12926,7 +12926,7 @@ ATExecEnableRowSecurity(Relation rel)
((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = true;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -12940,7 +12940,7 @@ ATExecDisableRowSecurity(Relation rel)
relid = RelationGetRelid(rel);
/* Pull the record for this relation and update it */
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -12950,7 +12950,7 @@ ATExecDisableRowSecurity(Relation rel)
((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = false;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -12966,7 +12966,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
relid = RelationGetRelid(rel);
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -12976,7 +12976,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
((Form_pg_class) GETSTRUCT(tuple))->relforcerowsecurity = force_rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -13000,7 +13000,7 @@ ATExecGenericOptions(Relation rel, List *options)
if (options == NIL)
return;
- ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+ ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(FOREIGNTABLEREL, rel->rd_id);
if (!HeapTupleIsValid(tuple))
@@ -13053,7 +13053,7 @@ ATExecGenericOptions(Relation rel, List *options)
InvokeObjectPostAlterHook(ForeignTableRelationId,
RelationGetRelid(rel), 0);
- heap_close(ftrel, RowExclusiveLock);
+ table_close(ftrel, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -13119,7 +13119,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
* permanent tables cannot reference unlogged ones. Self-referencing
* foreign keys can safely be ignored.
*/
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
/*
* Scan conrelid if changing to permanent, else confrelid. This also
@@ -13179,7 +13179,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
systable_endscan(scan);
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return true;
}
@@ -13267,7 +13267,7 @@ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,
Assert(objsMoved != NULL);
/* OK, modify the pg_class row and pg_depend entry */
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
AlterRelationNamespaceInternal(classRel, RelationGetRelid(rel), oldNspOid,
nspOid, true, objsMoved);
@@ -13288,7 +13288,7 @@ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,
false, objsMoved);
}
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
}
/*
@@ -13425,7 +13425,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
* SERIAL sequences are those having an auto dependency on one of the
* table's columns (we don't care *which* column, exactly).
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -14380,7 +14380,7 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
/*
* This is the minimum lock we need to prevent deadlocks.
*/
- part_rel = heap_open(partdesc->oids[i], AccessExclusiveLock);
+ part_rel = table_open(partdesc->oids[i], AccessExclusiveLock);
/*
* Adjust the constraint for scanrel so that it matches this
@@ -14396,7 +14396,7 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
QueuePartitionConstraintValidation(wqueue, part_rel,
thisPartConstraint,
validate_default);
- heap_close(part_rel, NoLock); /* keep lock till commit */
+ table_close(part_rel, NoLock); /* keep lock till commit */
}
}
}
@@ -14435,7 +14435,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
if (OidIsValid(defaultPartOid))
LockRelationOid(defaultPartOid, AccessExclusiveLock);
- attachrel = heap_openrv(cmd->name, AccessExclusiveLock);
+ attachrel = table_openrv(cmd->name, AccessExclusiveLock);
/*
* XXX I think it'd be a good idea to grab locks on all tables referenced
@@ -14464,7 +14464,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
* Table being attached should not already be part of inheritance; either
* as a child table...
*/
- catalog = heap_open(InheritsRelationId, AccessShareLock);
+ catalog = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -14490,7 +14490,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot attach inheritance parent as partition")));
systable_endscan(scan);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
/*
* Prevent circularity by seeing if rel is a partition of attachrel. (In
@@ -14688,20 +14688,20 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
Assert(!cmd->bound->is_default);
/* we already hold a lock on the default partition */
- defaultrel = heap_open(defaultPartOid, NoLock);
+ defaultrel = table_open(defaultPartOid, NoLock);
defPartConstraint =
get_proposed_default_constraint(partBoundConstraint);
QueuePartitionConstraintValidation(wqueue, defaultrel,
defPartConstraint, true);
/* keep our lock until commit. */
- heap_close(defaultrel, NoLock);
+ table_close(defaultrel, NoLock);
}
ObjectAddressSet(address, RelationRelationId, RelationGetRelid(attachrel));
/* keep our lock until commit */
- heap_close(attachrel, NoLock);
+ table_close(attachrel, NoLock);
return address;
}
@@ -14871,7 +14871,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
ScanKeyInit(&key, Anum_pg_trigger_tgrelid, BTEqualStrategyNumber,
F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(parent)));
- pg_trigger = heap_open(TriggerRelationId, RowExclusiveLock);
+ pg_trigger = table_open(TriggerRelationId, RowExclusiveLock);
scan = systable_beginscan(pg_trigger, TriggerRelidNameIndexId,
true, NULL, 1, &key);
@@ -14977,7 +14977,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
MemoryContextDelete(perTupCxt);
systable_endscan(scan);
- heap_close(pg_trigger, RowExclusiveLock);
+ table_close(pg_trigger, RowExclusiveLock);
}
/*
@@ -15010,13 +15010,13 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
if (OidIsValid(defaultPartOid))
LockRelationOid(defaultPartOid, AccessExclusiveLock);
- partRel = heap_openrv(name, ShareUpdateExclusiveLock);
+ partRel = table_openrv(name, ShareUpdateExclusiveLock);
/* All inheritance related checks are performed within the function */
RemoveInheritance(partRel, rel);
/* Update pg_class tuple */
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(partRel)));
if (!HeapTupleIsValid(tuple))
@@ -15072,7 +15072,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
update_relispartition(classRel, idxid, false);
index_close(idx, NoLock);
}
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
/* Detach foreign keys */
fks = copyObject(RelationGetFKeyList(partRel));
@@ -15100,7 +15100,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
ObjectAddressSet(address, RelationRelationId, RelationGetRelid(partRel));
/* keep our lock until commit */
- heap_close(partRel, NoLock);
+ table_close(partRel, NoLock);
return address;
}
@@ -15333,7 +15333,7 @@ refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTb
HeapTuple tuple;
SysScanDesc scan;
- pg_inherits = heap_open(InheritsRelationId, AccessShareLock);
+ pg_inherits = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key, Anum_pg_inherits_inhparent,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(parentIdx)));
@@ -15357,7 +15357,7 @@ refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTb
}
systable_endscan(scan);
- heap_close(pg_inherits, AccessShareLock);
+ table_close(pg_inherits, AccessShareLock);
}
/*
@@ -15383,7 +15383,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
* (verifying the pg_index entry for each), and if we reach the total
* amount we expect, we can mark this parent index as valid.
*/
- inheritsRel = heap_open(InheritsRelationId, AccessShareLock);
+ inheritsRel = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key, Anum_pg_inherits_inhparent,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(partedIdx)));
@@ -15408,7 +15408,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
/* Done with pg_inherits */
systable_endscan(scan);
- heap_close(inheritsRel, AccessShareLock);
+ table_close(inheritsRel, AccessShareLock);
/*
* If we found as many inherited indexes as the partitioned table has
@@ -15419,7 +15419,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
Relation idxRel;
HeapTuple newtup;
- idxRel = heap_open(IndexRelationId, RowExclusiveLock);
+ idxRel = table_open(IndexRelationId, RowExclusiveLock);
newtup = heap_copytuple(partedIdx->rd_indextuple);
((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true;
@@ -15427,7 +15427,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup);
- heap_close(idxRel, RowExclusiveLock);
+ table_close(idxRel, RowExclusiveLock);
}
/*
@@ -15473,7 +15473,7 @@ update_relispartition(Relation classRel, Oid relationId, bool newval)
if (classRel == NULL)
{
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
opened = true;
}
@@ -15486,5 +15486,5 @@ update_relispartition(Relation classRel, Oid relationId, bool newval)
ReleaseSysCache(tup);
if (opened)
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
}