*/
    heapid = IndexGetRelation(indrelid, true);
    if (OidIsValid(heapid))
-       heaprel = heap_open(heapid, lockmode);
+       heaprel = table_open(heapid, lockmode);
    else
        heaprel = NULL;
 
     */
    index_close(indrel, lockmode);
    if (heaprel)
-       heap_close(heaprel, lockmode);
+       table_close(heaprel, lockmode);
 }
 
 /*
 
    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,
    }
 
    systable_endscan(scan);
-   heap_close(indexRelation, AccessShareLock);
+   table_close(indexRelation, AccessShareLock);
 
    return result;
 }
    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);
 
 
    List       *options = NIL;
 
-   rel = heap_open(relid, AccessShareLock);
+   rel = table_open(relid, AccessShareLock);
    tupleDesc = RelationGetDescr(rel);
    natts = tupleDesc->natts;
 
        }
    }
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    /*
     * Return DefElem only when some column(s) have force_not_null /
    }
 
    /* 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)
        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)
 
    }
 
    heap_endscan(scan);
-   heap_close(mydata->rel, AccessShareLock);
+   table_close(mydata->rel, AccessShareLock);
 
    SRF_RETURN_DONE(funcctx);
 }
 
         * 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);
    }
 }
 
         * 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);
 
        if (use_alias)
            appendStringInfo(buf, " %s%d", REL_ALIAS_PREFIX, foreignrel->relid);
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 }
 
         * 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
        if (qualify_col)
            appendStringInfoString(buf, " END");
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
        bms_free(attrs_used);
    }
    else
 
     * 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
            break;
    }
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /*
     * Build the fdw_private list that will be available to the executor.
     * 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
            rebuild_fdw_scan_tlist(fscan, returningList);
    }
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
    return true;
 }
 
 
     * 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,
                                  true);
 
    systable_endscan(sscan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    /*
     * Assign the default security label on the new database
 
     * 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);
    }
    systable_endscan(sscan);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
 
     * 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,
     * Cleanup
     */
    systable_endscan(sscan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    pfree(audit_name.data);
    pfree(tcontext);
    /*
     * Fetch newer catalog
     */
-   rel = heap_open(ProcedureRelationId, AccessShareLock);
+   rel = table_open(ProcedureRelationId, AccessShareLock);
 
    ScanKeyInit(&skey,
                Anum_pg_proc_oid,
 
    ReleaseSysCache(oldtup);
    systable_endscan(sscan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 }
 
 /*
 
     * 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,
    SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext);
 
    systable_endscan(sscan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    pfree(tcontext);
    pfree(ncontext);
     * 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,
        HeapTuple   atup;
        Form_pg_attribute attForm;
 
-       arel = heap_open(AttributeRelationId, AccessShareLock);
+       arel = table_open(AttributeRelationId, AccessShareLock);
 
        ScanKeyInit(&akey,
                    Anum_pg_attribute_attrelid,
            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);
 }
 
 /*
    /*
     * Fetch newer catalog
     */
-   rel = heap_open(RelationRelationId, AccessShareLock);
+   rel = table_open(RelationRelationId, AccessShareLock);
 
    ScanKeyInit(&skey,
                Anum_pg_class_oid,
 
    ReleaseSysCache(oldtup);
    systable_endscan(sscan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 }
 
 /*
 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,
                                   indexOid,
                                   Anum_pg_index_indrelid,
                                   Anum_pg_index_indexrelid);
-   heap_close(catalog, AccessShareLock);
+   table_close(catalog, AccessShareLock);
 }
 
     * 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,
                                  audit_name.data,
                                  true);
    systable_endscan(sscan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    /*
     * Assign the default security label on a new procedure
 
     * iterate on the revmap.
     */
    heapOid = IndexGetRelation(RelationGetRelid(idxRel), false);
-   heapRel = heap_open(heapOid, AccessShareLock);
+   heapRel = table_open(heapOid, AccessShareLock);
    nblocks = RelationGetNumberOfBlocks(heapRel);
-   heap_close(heapRel, AccessShareLock);
+   table_close(heapRel, AccessShareLock);
 
    /*
     * Make room for the consistent support procedures of indexed columns.  We
    stats->num_pages = RelationGetNumberOfBlocks(info->index);
    /* rest of stats is initialized by zeroing */
 
-   heapRel = heap_open(IndexGetRelation(RelationGetRelid(info->index), false),
-                       AccessShareLock);
+   heapRel = table_open(IndexGetRelation(RelationGetRelid(info->index), false),
+                        AccessShareLock);
 
    brin_vacuum_scan(info->index, info->strategy);
 
    brinsummarize(info->index, heapRel, BRIN_ALL_BLOCKRANGES, false,
                  &stats->num_index_tuples, &stats->num_index_tuples);
 
-   heap_close(heapRel, AccessShareLock);
+   table_close(heapRel, AccessShareLock);
 
    return stats;
 }
     */
    heapoid = IndexGetRelation(indexoid, true);
    if (OidIsValid(heapoid))
-       heapRel = heap_open(heapoid, ShareUpdateExclusiveLock);
+       heapRel = table_open(heapoid, ShareUpdateExclusiveLock);
    else
        heapRel = NULL;
 
     */
    heapoid = IndexGetRelation(indexoid, true);
    if (OidIsValid(heapoid))
-       heapRel = heap_open(heapoid, ShareUpdateExclusiveLock);
+       heapRel = table_open(heapoid, ShareUpdateExclusiveLock);
    else
        heapRel = NULL;
 
 
    {
        Relation    toastrel;
 
-       toastrel = heap_open(rel->rd_rel->reltoastrelid, AccessShareLock);
+       toastrel = table_open(rel->rd_rel->reltoastrelid, AccessShareLock);
        FlushRelationBuffers(toastrel);
        smgrimmedsync(toastrel->rd_smgr, MAIN_FORKNUM);
-       heap_close(toastrel, AccessShareLock);
+       table_close(toastrel, AccessShareLock);
    }
 }
 
 
    Relation    toastrel;
 
    /* Open the toast relation */
-   toastrel = heap_open(toastoid, lock);
+   toastrel = table_open(toastoid, lock);
 
    /* Look for the valid index of the toast relation */
    validIndex = toast_open_indexes(toastrel,
 
    /* Close the toast relation and all its indexes */
    toast_close_indexes(toastidxs, num_indexes, lock);
-   heap_close(toastrel, lock);
+   table_close(toastrel, lock);
 
    return validIndexOid;
 }
     * uniqueness of the OID we assign to the toasted item, even though it has
     * additional columns besides OID.
     */
-   toastrel = heap_open(rel->rd_rel->reltoastrelid, RowExclusiveLock);
+   toastrel = table_open(rel->rd_rel->reltoastrelid, RowExclusiveLock);
    toasttupDesc = toastrel->rd_att;
 
    /* Open all the toast indexes and look for the valid one */
     * Done - close toast relation and its indexes
     */
    toast_close_indexes(toastidxs, num_indexes, RowExclusiveLock);
-   heap_close(toastrel, RowExclusiveLock);
+   table_close(toastrel, RowExclusiveLock);
 
    /*
     * Create the TOAST pointer value that we'll return
    /*
     * Open the toast relation and its indexes
     */
-   toastrel = heap_open(toast_pointer.va_toastrelid, RowExclusiveLock);
+   toastrel = table_open(toast_pointer.va_toastrelid, RowExclusiveLock);
 
    /* Fetch valid relation used for process */
    validIndex = toast_open_indexes(toastrel,
     */
    systable_endscan_ordered(toastscan);
    toast_close_indexes(toastidxs, num_indexes, RowExclusiveLock);
-   heap_close(toastrel, RowExclusiveLock);
+   table_close(toastrel, RowExclusiveLock);
 }
 
 
    bool        result;
    Relation    toastrel;
 
-   toastrel = heap_open(toastrelid, AccessShareLock);
+   toastrel = table_open(toastrelid, AccessShareLock);
 
    result = toastrel_valueid_exists(toastrel, valueid);
 
-   heap_close(toastrel, AccessShareLock);
+   table_close(toastrel, AccessShareLock);
 
    return result;
 }
    /*
     * Open the toast relation and its indexes
     */
-   toastrel = heap_open(toast_pointer.va_toastrelid, AccessShareLock);
+   toastrel = table_open(toast_pointer.va_toastrelid, AccessShareLock);
    toasttupDesc = toastrel->rd_att;
 
    /* Look for the valid index of the toast relation */
     */
    systable_endscan_ordered(toastscan);
    toast_close_indexes(toastidxs, num_indexes, AccessShareLock);
-   heap_close(toastrel, AccessShareLock);
+   table_close(toastrel, AccessShareLock);
 
    return result;
 }
    /*
     * Open the toast relation and its indexes
     */
-   toastrel = heap_open(toast_pointer.va_toastrelid, AccessShareLock);
+   toastrel = table_open(toast_pointer.va_toastrelid, AccessShareLock);
    toasttupDesc = toastrel->rd_att;
 
    /* Look for the valid index of toast relation */
     */
    systable_endscan_ordered(toastscan);
    toast_close_indexes(toastidxs, num_indexes, AccessShareLock);
-   heap_close(toastrel, AccessShareLock);
+   table_close(toastrel, AccessShareLock);
 
    return result;
 }
 
    }
 
    /* Open relations within worker */
-   heapRel = heap_open(btshared->heaprelid, heapLockmode);
+   heapRel = table_open(btshared->heaprelid, heapLockmode);
    indexRel = index_open(btshared->indexrelid, indexLockmode);
 
    /* Initialize worker's own spool */
 #endif                         /* BTREE_BUILD_STATS */
 
    index_close(indexRel, indexLockmode);
-   heap_close(heapRel, heapLockmode);
+   table_close(heapRel, heapLockmode);
 }
 
 /*
 
    if (Typ == NULL)
    {
        /* We can now load the pg_type data */
-       rel = heap_open(TypeRelationId, NoLock);
+       rel = table_open(TypeRelationId, NoLock);
        scan = heap_beginscan_catalog(rel, 0, NULL);
        i = 0;
        while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
            app++;
        }
        heap_endscan(scan);
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 
    if (boot_reldesc != NULL)
    elog(DEBUG4, "open relation %s, attrsize %d",
         relname, (int) ATTRIBUTE_FIXED_PART_SIZE);
 
-   boot_reldesc = heap_openrv(makeRangeVar(NULL, relname, -1), NoLock);
+   boot_reldesc = table_openrv(makeRangeVar(NULL, relname, -1), NoLock);
    numattr = RelationGetNumberOfAttributes(boot_reldesc);
    for (i = 0; i < numattr; i++)
    {
    {
        elog(DEBUG4, "close relation %s",
             RelationGetRelationName(boot_reldesc));
-       heap_close(boot_reldesc, NoLock);
+       table_close(boot_reldesc, NoLock);
        boot_reldesc = NULL;
    }
 }
                return i;
        }
        elog(DEBUG4, "external type: %s", type);
-       rel = heap_open(TypeRelationId, NoLock);
+       rel = table_open(TypeRelationId, NoLock);
        scan = heap_beginscan_catalog(rel, 0, NULL);
        i = 0;
        while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
                    sizeof((*app)->am_typ));
        }
        heap_endscan(scan);
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
        return gettype(type);
    }
    elog(ERROR, "unrecognized type \"%s\"", type);
        Relation    ind;
 
        /* need not bother with locks during bootstrap */
-       heap = heap_open(ILHead->il_heap, NoLock);
+       heap = table_open(ILHead->il_heap, NoLock);
        ind = index_open(ILHead->il_ind, NoLock);
 
        index_build(heap, ind, ILHead->il_info, false, false, false);
 
        index_close(ind, NoLock);
-       heap_close(heap, NoLock);
+       table_close(heap, NoLock);
    }
 }
 
                                    BTEqualStrategyNumber, F_CHAREQ,
                                    CharGetDatum(PROKIND_PROCEDURE));
 
-                   rel = heap_open(ProcedureRelationId, AccessShareLock);
+                   rel = table_open(ProcedureRelationId, AccessShareLock);
                    scan = heap_beginscan_catalog(rel, keycount, key);
 
                    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
                    }
 
                    heap_endscan(scan);
-                   heap_close(rel, AccessShareLock);
+                   table_close(rel, AccessShareLock);
                }
                break;
            default:
                BTEqualStrategyNumber, F_CHAREQ,
                CharGetDatum(relkind));
 
-   rel = heap_open(RelationRelationId, AccessShareLock);
+   rel = table_open(RelationRelationId, AccessShareLock);
    scan = heap_beginscan_catalog(rel, 2, key);
 
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    }
 
    heap_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return relations;
 }
    Oid        *oldmembers;
    Oid        *newmembers;
 
-   rel = heap_open(DefaultAclRelationId, RowExclusiveLock);
+   rel = table_open(DefaultAclRelationId, RowExclusiveLock);
 
    /*
     * The default for a global entry is the hard-wired default ACL for the
    if (HeapTupleIsValid(tuple))
        ReleaseSysCache(tuple);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
        HeapTuple   tuple;
 
        /* first fetch info needed by SetDefaultACL */
-       rel = heap_open(DefaultAclRelationId, AccessShareLock);
+       rel = table_open(DefaultAclRelationId, AccessShareLock);
 
        ScanKeyInit(&skey[0],
                    Anum_pg_default_acl_oid,
        }
 
        systable_endscan(scan);
-       heap_close(rel, AccessShareLock);
+       table_close(rel, AccessShareLock);
 
        iacls.is_grant = false;
        iacls.all_privs = true;
    SysScanDesc scan;
    HeapTuple   tuple;
 
-   rel = heap_open(DefaultAclRelationId, RowExclusiveLock);
+   rel = table_open(DefaultAclRelationId, RowExclusiveLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_default_acl_oid,
    CatalogTupleDelete(rel, &tuple->t_self);
 
    systable_endscan(scan);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
    Relation    attRelation;
    ListCell   *cell;
 
-   relation = heap_open(RelationRelationId, RowExclusiveLock);
-   attRelation = heap_open(AttributeRelationId, RowExclusiveLock);
+   relation = table_open(RelationRelationId, RowExclusiveLock);
+   attRelation = table_open(AttributeRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(attRelation, RowExclusiveLock);
-   heap_close(relation, RowExclusiveLock);
+   table_close(attRelation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_DATABASE;
 
-   relation = heap_open(DatabaseRelationId, RowExclusiveLock);
+   relation = table_open(DatabaseRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_FDW;
 
-   relation = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+   relation = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_FOREIGN_SERVER;
 
-   relation = heap_open(ForeignServerRelationId, RowExclusiveLock);
+   relation = table_open(ForeignServerRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_FUNCTION;
 
-   relation = heap_open(ProcedureRelationId, RowExclusiveLock);
+   relation = table_open(ProcedureRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_LANGUAGE;
 
-   relation = heap_open(LanguageRelationId, RowExclusiveLock);
+   relation = table_open(LanguageRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_LARGEOBJECT;
 
-   relation = heap_open(LargeObjectMetadataRelationId,
-                        RowExclusiveLock);
+   relation = table_open(LargeObjectMetadataRelationId,
+                         RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_SCHEMA;
 
-   relation = heap_open(NamespaceRelationId, RowExclusiveLock);
+   relation = table_open(NamespaceRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_TABLESPACE;
 
-   relation = heap_open(TableSpaceRelationId, RowExclusiveLock);
+   relation = table_open(TableSpaceRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 static void
    if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
        istmt->privileges = ACL_ALL_RIGHTS_TYPE;
 
-   relation = heap_open(TypeRelationId, RowExclusiveLock);
+   relation = table_open(TypeRelationId, RowExclusiveLock);
 
    foreach(cell, istmt->objects)
    {
        CommandCounterIncrement();
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 
    /*
     * Get the largeobject's ACL from pg_language_metadata
     */
-   pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
-                          AccessShareLock);
+   pg_lo_meta = table_open(LargeObjectMetadataRelationId,
+                           AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_largeobject_metadata_oid,
 
    systable_endscan(scan);
 
-   heap_close(pg_lo_meta, AccessShareLock);
+   table_close(pg_lo_meta, AccessShareLock);
 
    return result;
 }
        return true;
 
    /* There's no syscache for pg_largeobject_metadata */
-   pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
-                          AccessShareLock);
+   pg_lo_meta = table_open(LargeObjectMetadataRelationId,
+                           AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_largeobject_metadata_oid,
    ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
 
    systable_endscan(scan);
-   heap_close(pg_lo_meta, AccessShareLock);
+   table_close(pg_lo_meta, AccessShareLock);
 
    return has_privs_of_role(roleid, ownerId);
 }
        return true;
 
    /* There's no syscache for pg_extension, so do it the hard way */
-   pg_extension = heap_open(ExtensionRelationId, AccessShareLock);
+   pg_extension = table_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_extension_oid,
    ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner;
 
    systable_endscan(scan);
-   heap_close(pg_extension, AccessShareLock);
+   table_close(pg_extension, AccessShareLock);
 
    return has_privs_of_role(roleid, ownerId);
 }
        SysScanDesc scan;
        Relation    relation;
 
-       relation = heap_open(LargeObjectMetadataRelationId, RowExclusiveLock);
+       relation = table_open(LargeObjectMetadataRelationId, RowExclusiveLock);
 
        /* There's no syscache for pg_largeobject_metadata */
        ScanKeyInit(&entry[0],
    HeapTuple   tuple;
    HeapTuple   oldtuple;
 
-   relation = heap_open(InitPrivsRelationId, RowExclusiveLock);
+   relation = table_open(InitPrivsRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_init_privs_objoid,
    /* prevent error when processing objects multiple times */
    CommandCounterIncrement();
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to call pg_nextoid")));
 
-   rel = heap_open(reloid, RowExclusiveLock);
+   rel = table_open(reloid, RowExclusiveLock);
    idx = index_open(idxoid, RowExclusiveLock);
 
    if (!IsSystemRelation(rel))
    newoid = GetNewOidWithIndex(rel, idxoid, attno);
 
    ReleaseSysCache(atttuple);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
    index_close(idx, RowExclusiveLock);
 
    return newoid;
 
     * We save some cycles by opening pg_depend just once and passing the
     * Relation pointer down to all the recursive deletion steps.
     */
-   depRel = heap_open(DependRelationId, RowExclusiveLock);
+   depRel = table_open(DependRelationId, RowExclusiveLock);
 
    /*
     * Acquire deletion lock on the target object.  (Ideally the caller has
    /* And clean up */
    free_object_addresses(targetObjects);
 
-   heap_close(depRel, RowExclusiveLock);
+   table_close(depRel, RowExclusiveLock);
 }
 
 /*
     * We save some cycles by opening pg_depend just once and passing the
     * Relation pointer down to all the recursive deletion steps.
     */
-   depRel = heap_open(DependRelationId, RowExclusiveLock);
+   depRel = table_open(DependRelationId, RowExclusiveLock);
 
    /*
     * Construct a list of objects to delete (ie, the given objects plus
    /* And clean up */
    free_object_addresses(targetObjects);
 
-   heap_close(depRel, RowExclusiveLock);
+   table_close(depRel, RowExclusiveLock);
 }
 
 /*
     * relation open across doDeletion().
     */
    if (flags & PERFORM_DELETION_CONCURRENTLY)
-       heap_close(*depRel, RowExclusiveLock);
+       table_close(*depRel, RowExclusiveLock);
 
    /*
     * Delete the object itself, in an object-type-dependent way.
     * Reopen depRel if we closed it above
     */
    if (flags & PERFORM_DELETION_CONCURRENTLY)
-       *depRel = heap_open(DependRelationId, RowExclusiveLock);
+       *depRel = table_open(DependRelationId, RowExclusiveLock);
 
    /*
     * Now remove any pg_depend records that link from this object to others.
    SysScanDesc scan;
    HeapTuple   oldtuple;
 
-   relation = heap_open(InitPrivsRelationId, RowExclusiveLock);
+   relation = table_open(InitPrivsRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_init_privs_objoid,
 
    systable_endscan(scan);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
    /*
     * open pg_attribute and its indexes.
     */
-   rel = heap_open(AttributeRelationId, RowExclusiveLock);
+   rel = table_open(AttributeRelationId, RowExclusiveLock);
 
    indstate = CatalogOpenIndexes(rel);
 
     */
    CatalogCloseIndexes(indstate);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /* --------------------------------
    ObjectAddress new_type_addr;
    Oid         new_array_oid = InvalidOid;
 
-   pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock);
+   pg_class_desc = table_open(RelationRelationId, RowExclusiveLock);
 
    /*
     * sanity checks
     * ok, the relation has been cataloged, so close our relations and return
     * the OID of the newly created relation.
     */
-   heap_close(new_rel_desc, NoLock);   /* do not unlock till end of xact */
-   heap_close(pg_class_desc, RowExclusiveLock);
+   table_close(new_rel_desc, NoLock);  /* do not unlock till end of xact */
+   table_close(pg_class_desc, RowExclusiveLock);
 
    return relid;
 }
    ScanKeyData key;
    HeapTuple   tuple;
 
-   catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+   catalogRelation = table_open(InheritsRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key,
                Anum_pg_inherits_inhrelid,
        CatalogTupleDelete(catalogRelation, &tuple->t_self);
 
    systable_endscan(scan);
-   heap_close(catalogRelation, RowExclusiveLock);
+   table_close(catalogRelation, RowExclusiveLock);
 }
 
 /*
    HeapTuple   tup;
 
    /* Grab an appropriate lock on the pg_class relation */
-   pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock);
+   pg_class_desc = table_open(RelationRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
    if (!HeapTupleIsValid(tup))
 
    ReleaseSysCache(tup);
 
-   heap_close(pg_class_desc, RowExclusiveLock);
+   table_close(pg_class_desc, RowExclusiveLock);
 }
 
 /*
    HeapTuple   atttup;
 
    /* Grab an appropriate lock on the pg_attribute relation */
-   attrel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrel = table_open(AttributeRelationId, RowExclusiveLock);
 
    /* Use the index to scan only attributes of the target relation */
    ScanKeyInit(&key[0],
 
    /* Clean up after the scan */
    systable_endscan(scan);
-   heap_close(attrel, RowExclusiveLock);
+   table_close(attrel, RowExclusiveLock);
 }
 
 /*
    HeapTuple   atttup;
 
    /* Grab an appropriate lock on the pg_attribute relation */
-   attrel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrel = table_open(AttributeRelationId, RowExclusiveLock);
 
    /* Use the index to scan only system attributes of the target relation */
    ScanKeyInit(&key[0],
 
    /* Clean up after the scan */
    systable_endscan(scan);
-   heap_close(attrel, RowExclusiveLock);
+   table_close(attrel, RowExclusiveLock);
 }
 
 /*
     */
    rel = relation_open(relid, AccessExclusiveLock);
 
-   attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy2(ATTNUM,
                                ObjectIdGetDatum(relid),
     * backends of the change.
     */
 
-   heap_close(attr_rel, RowExclusiveLock);
+   table_close(attr_rel, RowExclusiveLock);
 
    if (attnum > 0)
        RemoveStatistics(relid, attnum);
    HeapTuple   tuple;
    bool        found = false;
 
-   attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+   attrdef_rel = table_open(AttrDefaultRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scankeys[0],
                Anum_pg_attrdef_adrelid,
    }
 
    systable_endscan(scan);
-   heap_close(attrdef_rel, RowExclusiveLock);
+   table_close(attrdef_rel, RowExclusiveLock);
 
    if (complain && !found)
        elog(ERROR, "could not find attrdef tuple for relation %u attnum %d",
    AttrNumber  myattnum;
 
    /* Grab an appropriate lock on the pg_attrdef relation */
-   attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+   attrdef_rel = table_open(AttrDefaultRelationId, RowExclusiveLock);
 
    /* Find the pg_attrdef tuple */
    ScanKeyInit(&scankeys[0],
    CatalogTupleDelete(attrdef_rel, &tuple->t_self);
 
    systable_endscan(scan);
-   heap_close(attrdef_rel, RowExclusiveLock);
+   table_close(attrdef_rel, RowExclusiveLock);
 
    /* Fix the pg_attribute row */
-   attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy2(ATTNUM,
                                ObjectIdGetDatum(myrelid),
     * Our update of the pg_attribute row will force a relcache rebuild, so
     * there's nothing else to do here.
     */
-   heap_close(attr_rel, RowExclusiveLock);
+   table_close(attr_rel, RowExclusiveLock);
 
    /* Keep lock on attribute's rel until end of xact */
    relation_close(myrel, NoLock);
        Relation    rel;
        HeapTuple   tuple;
 
-       rel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+       rel = table_open(ForeignTableRelationId, RowExclusiveLock);
 
        tuple = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
        if (!HeapTupleIsValid(tuple))
        CatalogTupleDelete(rel, &tuple->t_self);
 
        ReleaseSysCache(tuple);
-       heap_close(rel, RowExclusiveLock);
+       table_close(rel, RowExclusiveLock);
    }
 
    /*
 
 
    /* Get a lock on pg_attribute */
-   attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
 
    /* process each non-system attribute, including any dropped columns */
    for (attnum = 1; attnum <= natts; attnum++)
     * Our update of the pg_attribute rows will force a relcache rebuild, so
     * there's nothing else to do here.
     */
-   heap_close(attr_rel, RowExclusiveLock);
+   table_close(attr_rel, RowExclusiveLock);
 }
 
 /*
                newtup;
 
    /* lock the table the attribute belongs to */
-   tablerel = heap_open(relid, AccessExclusiveLock);
+   tablerel = table_open(relid, AccessExclusiveLock);
 
    /* Lock the attribute row and get the data */
-   attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrrel = table_open(AttributeRelationId, RowExclusiveLock);
    atttup = SearchSysCacheAttName(relid, attname);
    if (!HeapTupleIsValid(atttup))
        elog(ERROR, "cache lookup failed for attribute %s of relation %u",
 
    /* clean up */
    ReleaseSysCache(atttup);
-   heap_close(attrrel, RowExclusiveLock);
-   heap_close(tablerel, AccessExclusiveLock);
+   table_close(attrrel, RowExclusiveLock);
+   table_close(tablerel, AccessExclusiveLock);
 }
 
 /*
    ObjectAddress colobject,
                defobject;
 
-   adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+   adrel = table_open(AttrDefaultRelationId, RowExclusiveLock);
 
    /*
     * Flatten expression to string form for storage.
    defobject.objectId = attrdefOid;
    defobject.objectSubId = 0;
 
-   heap_close(adrel, RowExclusiveLock);
+   table_close(adrel, RowExclusiveLock);
 
    /* now can free some of the stuff allocated above */
    pfree(DatumGetPointer(values[Anum_pg_attrdef_adbin - 1]));
     * Update the pg_attribute entry for the column to show that a default
     * exists.
     */
-   attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrrel = table_open(AttributeRelationId, RowExclusiveLock);
    atttup = SearchSysCacheCopy2(ATTNUM,
                                 ObjectIdGetDatum(RelationGetRelid(rel)),
                                 Int16GetDatum(attnum));
            pfree(DatumGetPointer(missingval));
 
    }
-   heap_close(attrrel, RowExclusiveLock);
+   table_close(attrrel, RowExclusiveLock);
    heap_freetuple(atttup);
 
    /*
    HeapTuple   tup;
 
    /* Search for a pg_constraint entry with same name and relation */
-   conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
 
    found = false;
 
    }
 
    systable_endscan(conscan);
-   heap_close(conDesc, RowExclusiveLock);
+   table_close(conDesc, RowExclusiveLock);
 
    return found;
 }
    HeapTuple   reltup;
    Form_pg_class relStruct;
 
-   relrel = heap_open(RelationRelationId, RowExclusiveLock);
+   relrel = table_open(RelationRelationId, RowExclusiveLock);
    reltup = SearchSysCacheCopy1(RELOID,
                                 ObjectIdGetDatum(RelationGetRelid(rel)));
    if (!HeapTupleIsValid(reltup))
    }
 
    heap_freetuple(reltup);
-   heap_close(relrel, RowExclusiveLock);
+   table_close(relrel, RowExclusiveLock);
 }
 
 /*
    int         nkeys;
    HeapTuple   tuple;
 
-   pgstatistic = heap_open(StatisticRelationId, RowExclusiveLock);
+   pgstatistic = table_open(StatisticRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_statistic_starelid,
 
    systable_endscan(scan);
 
-   heap_close(pgstatistic, RowExclusiveLock);
+   table_close(pgstatistic, RowExclusiveLock);
 }
 
 
        Oid         rid = lfirst_oid(cell);
        Relation    rel;
 
-       rel = heap_open(rid, AccessExclusiveLock);
+       rel = table_open(rid, AccessExclusiveLock);
        relations = lappend(relations, rel);
    }
 
        heap_truncate_one_rel(rel);
 
        /* Close the relation, but keep exclusive lock on it until commit */
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 }
 
    toastrelid = rel->rd_rel->reltoastrelid;
    if (OidIsValid(toastrelid))
    {
-       Relation    toastrel = heap_open(toastrelid, AccessExclusiveLock);
+       Relation    toastrel = table_open(toastrelid, AccessExclusiveLock);
 
        RelationTruncate(toastrel, 0);
        RelationTruncateIndexes(toastrel);
        /* keep the lock... */
-       heap_close(toastrel, NoLock);
+       table_close(toastrel, NoLock);
    }
 }
 
     * Must scan pg_constraint.  Right now, it is a seqscan because there is
     * no available index on confrelid.
     */
-   fkeyRel = heap_open(ConstraintRelationId, AccessShareLock);
+   fkeyRel = table_open(ConstraintRelationId, AccessShareLock);
 
    fkeyScan = systable_beginscan(fkeyRel, InvalidOid, false,
                                  NULL, 0, NULL);
    }
 
    systable_endscan(fkeyScan);
-   heap_close(fkeyRel, AccessShareLock);
+   table_close(fkeyRel, AccessShareLock);
 
    return result;
 }
    else
        partexprDatum = (Datum) 0;
 
-   pg_partitioned_table = heap_open(PartitionedRelationId, RowExclusiveLock);
+   pg_partitioned_table = table_open(PartitionedRelationId, RowExclusiveLock);
 
    MemSet(nulls, false, sizeof(nulls));
 
    tuple = heap_form_tuple(RelationGetDescr(pg_partitioned_table), values, nulls);
 
    CatalogTupleInsert(pg_partitioned_table, tuple);
-   heap_close(pg_partitioned_table, RowExclusiveLock);
+   table_close(pg_partitioned_table, RowExclusiveLock);
 
    /* Mark this relation as dependent on a few things as follows */
    myself.classId = RelationRelationId;
    Relation    rel;
    HeapTuple   tuple;
 
-   rel = heap_open(PartitionedRelationId, RowExclusiveLock);
+   rel = table_open(PartitionedRelationId, RowExclusiveLock);
 
    tuple = SearchSysCache1(PARTRELID, ObjectIdGetDatum(relid));
    if (!HeapTupleIsValid(tuple))
    CatalogTupleDelete(rel, &tuple->t_self);
 
    ReleaseSysCache(tuple);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    Oid         defaultPartOid;
 
    /* Update pg_class tuple */
-   classRel = heap_open(RelationRelationId, RowExclusiveLock);
+   classRel = table_open(RelationRelationId, RowExclusiveLock);
    tuple = SearchSysCacheCopy1(RELOID,
                                ObjectIdGetDatum(RelationGetRelid(rel)));
    if (!HeapTupleIsValid(tuple))
    ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true;
    CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
    heap_freetuple(newtuple);
-   heap_close(classRel, RowExclusiveLock);
+   table_close(classRel, RowExclusiveLock);
 
    /*
     * If we're storing bounds for the default partition, update
 
    /*
     * open the attribute relation and its indexes
     */
-   pg_attribute = heap_open(AttributeRelationId, RowExclusiveLock);
+   pg_attribute = table_open(AttributeRelationId, RowExclusiveLock);
 
    indstate = CatalogOpenIndexes(pg_attribute);
 
 
    CatalogCloseIndexes(indstate);
 
-   heap_close(pg_attribute, RowExclusiveLock);
+   table_close(pg_attribute, RowExclusiveLock);
 }
 
 /* ----------------------------------------------------------------
    /*
     * open the system catalog index relation
     */
-   pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+   pg_index = table_open(IndexRelationId, RowExclusiveLock);
 
    /*
     * Build a pg_index tuple
    /*
     * close the relation and free the tuple
     */
-   heap_close(pg_index, RowExclusiveLock);
+   table_close(pg_index, RowExclusiveLock);
    heap_freetuple(tuple);
 }
 
    relkind = partitioned ? RELKIND_PARTITIONED_INDEX : RELKIND_INDEX;
    is_exclusion = (indexInfo->ii_ExclusionOps != NULL);
 
-   pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+   pg_class = table_open(RelationRelationId, RowExclusiveLock);
 
    /*
     * The index will be in the same namespace as its parent table, and is
                    (errcode(ERRCODE_DUPLICATE_TABLE),
                     errmsg("relation \"%s\" already exists, skipping",
                            indexRelationName)));
-           heap_close(pg_class, RowExclusiveLock);
+           table_close(pg_class, RowExclusiveLock);
            return InvalidOid;
        }
 
                       reloptions);
 
    /* done with pg_class */
-   heap_close(pg_class, RowExclusiveLock);
+   table_close(pg_class, RowExclusiveLock);
 
    /*
     * now update the object id's of all the attribute tuple forms in the
        Form_pg_index indexForm;
        bool        dirty = false;
 
-       pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+       pg_index = table_open(IndexRelationId, RowExclusiveLock);
 
        indexTuple = SearchSysCacheCopy1(INDEXRELID,
                                         ObjectIdGetDatum(indexRelationId));
        }
 
        heap_freetuple(indexTuple);
-       heap_close(pg_index, RowExclusiveLock);
+       table_close(pg_index, RowExclusiveLock);
    }
 
    return referenced;
     */
    heapId = IndexGetRelation(indexId, false);
    lockmode = concurrent ? ShareUpdateExclusiveLock : AccessExclusiveLock;
-   userHeapRelation = heap_open(heapId, lockmode);
+   userHeapRelation = table_open(heapId, lockmode);
    userIndexRelation = index_open(indexId, lockmode);
 
    /*
        SET_LOCKTAG_RELATION(heaplocktag, heaprelid.dbId, heaprelid.relId);
        indexrelid = userIndexRelation->rd_lockInfo.lockRelId;
 
-       heap_close(userHeapRelation, NoLock);
+       table_close(userHeapRelation, NoLock);
        index_close(userIndexRelation, NoLock);
 
        /*
         * conflicts with existing predicate locks, so now is the time to move
         * them to the heap relation.
         */
-       userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+       userHeapRelation = table_open(heapId, ShareUpdateExclusiveLock);
        userIndexRelation = index_open(indexId, ShareUpdateExclusiveLock);
        TransferPredicateLocksToHeapRelation(userIndexRelation);
 
        /*
         * Close the relations again, though still holding session lock.
         */
-       heap_close(userHeapRelation, NoLock);
+       table_close(userHeapRelation, NoLock);
        index_close(userIndexRelation, NoLock);
 
        /*
         * leave nothing to chance and grab AccessExclusiveLock on the index
         * before the physical deletion.
         */
-       userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+       userHeapRelation = table_open(heapId, ShareUpdateExclusiveLock);
        userIndexRelation = index_open(indexId, AccessExclusiveLock);
    }
    else
    /*
     * fix INDEX relation, and check for expressional index
     */
-   indexRelation = heap_open(IndexRelationId, RowExclusiveLock);
+   indexRelation = table_open(IndexRelationId, RowExclusiveLock);
 
    tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexId));
    if (!HeapTupleIsValid(tuple))
    CatalogTupleDelete(indexRelation, &tuple->t_self);
 
    ReleaseSysCache(tuple);
-   heap_close(indexRelation, RowExclusiveLock);
+   table_close(indexRelation, RowExclusiveLock);
 
    /*
     * if it has any expression columns, we might have stored statistics about
    /*
     * Close owning rel, but keep lock
     */
-   heap_close(userHeapRelation, NoLock);
+   table_close(userHeapRelation, NoLock);
 
    /*
     * Release the session locks before we go.
     * what's really important.
     */
 
-   pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+   pg_class = table_open(RelationRelationId, RowExclusiveLock);
 
    /*
     * Make a copy of the tuple to update.  Normally we use the syscache, but
 
    heap_freetuple(tuple);
 
-   heap_close(pg_class, RowExclusiveLock);
+   table_close(pg_class, RowExclusiveLock);
 }
 
 
        HeapTuple   indexTuple;
        Form_pg_index indexForm;
 
-       pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+       pg_index = table_open(IndexRelationId, RowExclusiveLock);
 
        indexTuple = SearchSysCacheCopy1(INDEXRELID,
                                         ObjectIdGetDatum(indexId));
        CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple);
 
        heap_freetuple(indexTuple);
-       heap_close(pg_index, RowExclusiveLock);
+       table_close(pg_index, RowExclusiveLock);
    }
 
    /*
    int         save_nestlevel;
 
    /* Open and lock the parent heap relation */
-   heapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+   heapRelation = table_open(heapId, ShareUpdateExclusiveLock);
    /* And the target index relation */
    indexRelation = index_open(indexId, RowExclusiveLock);
 
 
    /* Close rels, but keep locks */
    index_close(indexRelation, NoLock);
-   heap_close(heapRelation, NoLock);
+   table_close(heapRelation, NoLock);
 }
 
 /*
    Assert(GetTopTransactionIdIfAny() == InvalidTransactionId);
 
    /* Open pg_index and fetch a writable copy of the index's tuple */
-   pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+   pg_index = table_open(IndexRelationId, RowExclusiveLock);
 
    indexTuple = SearchSysCacheCopy1(INDEXRELID,
                                     ObjectIdGetDatum(indexId));
    /* ... and write it back in-place */
    heap_inplace_update(pg_index, indexTuple);
 
-   heap_close(pg_index, RowExclusiveLock);
+   table_close(pg_index, RowExclusiveLock);
 }
 
 
     * we only need to be sure no schema or data changes are going on.
     */
    heapId = IndexGetRelation(indexId, false);
-   heapRelation = heap_open(heapId, ShareLock);
+   heapRelation = table_open(heapId, ShareLock);
 
    /*
     * Open the target index relation and get an exclusive lock on it, to
        bool        index_bad;
        bool        early_pruning_enabled = EarlyPruningEnabled(heapRelation);
 
-       pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+       pg_index = table_open(IndexRelationId, RowExclusiveLock);
 
        indexTuple = SearchSysCacheCopy1(INDEXRELID,
                                         ObjectIdGetDatum(indexId));
            CacheInvalidateRelcache(heapRelation);
        }
 
-       heap_close(pg_index, RowExclusiveLock);
+       table_close(pg_index, RowExclusiveLock);
    }
 
    /* Log what we did */
 
    /* Close rels, but keep locks */
    index_close(iRel, NoLock);
-   heap_close(heapRelation, NoLock);
+   table_close(heapRelation, NoLock);
 }
 
 /*
     * to prevent schema and data changes in it.  The lock level used here
     * should match ReindexTable().
     */
-   rel = heap_open(relid, ShareLock);
+   rel = table_open(relid, ShareLock);
 
    /*
     * This may be useful when implemented someday; but that day is not today.
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("REINDEX of partitioned tables is not yet implemented, skipping \"%s\"",
                        RelationGetRelationName(rel))));
-       heap_close(rel, ShareLock);
+       table_close(rel, ShareLock);
        return false;
    }
 
    /*
     * Close rel, but continue to hold the lock.
     */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    result = (indexIds != NIL);
 
 
 
    /* Extract relation name and open relation. */
    relname = list_truncate(list_copy(object), nnames - 1);
-   relation = heap_openrv_extended(makeRangeVarFromNameList(relname),
-                                   AccessShareLock,
-                                   missing_ok);
+   relation = table_openrv_extended(makeRangeVarFromNameList(relname),
+                                    AccessShareLock,
+                                    missing_ok);
 
    reloid = relation ? RelationGetRelid(relation) : InvalidOid;
 
    if (!OidIsValid(address.objectId))
    {
        if (relation != NULL)
-           heap_close(relation, AccessShareLock);
+           table_close(relation, AccessShareLock);
 
        relation = NULL;        /* department of accident prevention */
        return address;
                HeapTuple   tup;
                Form_pg_cast castForm;
 
-               castDesc = heap_open(CastRelationId, AccessShareLock);
+               castDesc = table_open(CastRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_cast_oid,
                                 format_type_be(castForm->casttarget));
 
                systable_endscan(rcscan);
-               heap_close(castDesc, AccessShareLock);
+               table_close(castDesc, AccessShareLock);
                break;
            }
 
                Form_pg_attrdef attrdef;
                ObjectAddress colobject;
 
-               attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
+               attrdefDesc = table_open(AttrDefaultRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_attrdef_oid,
                                 getObjectDescription(&colobject));
 
                systable_endscan(adscan);
-               heap_close(attrdefDesc, AccessShareLock);
+               table_close(attrdefDesc, AccessShareLock);
                break;
            }
 
                Form_pg_amop amopForm;
                StringInfoData opfam;
 
-               amopDesc = heap_open(AccessMethodOperatorRelationId,
-                                    AccessShareLock);
+               amopDesc = table_open(AccessMethodOperatorRelationId,
+                                     AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_amop_oid,
                pfree(opfam.data);
 
                systable_endscan(amscan);
-               heap_close(amopDesc, AccessShareLock);
+               table_close(amopDesc, AccessShareLock);
                break;
            }
 
                Form_pg_amproc amprocForm;
                StringInfoData opfam;
 
-               amprocDesc = heap_open(AccessMethodProcedureRelationId,
+               amprocDesc = table_open(AccessMethodProcedureRelationId,
                                       AccessShareLock);
 
                ScanKeyInit(&skey[0],
                pfree(opfam.data);
 
                systable_endscan(amscan);
-               heap_close(amprocDesc, AccessShareLock);
+               table_close(amprocDesc, AccessShareLock);
                break;
            }
 
                Form_pg_rewrite rule;
                StringInfoData rel;
 
-               ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
+               ruleDesc = table_open(RewriteRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_rewrite_oid,
                                 NameStr(rule->rulename), rel.data);
                pfree(rel.data);
                systable_endscan(rcscan);
-               heap_close(ruleDesc, AccessShareLock);
+               table_close(ruleDesc, AccessShareLock);
                break;
            }
 
                Form_pg_trigger trig;
                StringInfoData rel;
 
-               trigDesc = heap_open(TriggerRelationId, AccessShareLock);
+               trigDesc = table_open(TriggerRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_trigger_oid,
                                 NameStr(trig->tgname), rel.data);
                pfree(rel.data);
                systable_endscan(tgscan);
-               heap_close(trigDesc, AccessShareLock);
+               table_close(trigDesc, AccessShareLock);
                break;
            }
 
                char       *rolename;
                char       *nspname;
 
-               defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
+               defaclrel = table_open(DefaultAclRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_default_acl_oid,
                }
 
                systable_endscan(rcscan);
-               heap_close(defaclrel, AccessShareLock);
+               table_close(defaclrel, AccessShareLock);
                break;
            }
 
                Form_pg_policy form_policy;
                StringInfoData rel;
 
-               policy_rel = heap_open(PolicyRelationId, AccessShareLock);
+               policy_rel = table_open(PolicyRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_policy_oid,
                                 NameStr(form_policy->polname), rel.data);
                pfree(rel.data);
                systable_endscan(sscan);
-               heap_close(policy_rel, AccessShareLock);
+               table_close(policy_rel, AccessShareLock);
                break;
            }
 
    if (is_objectclass_supported(address.classId))
    {
        HeapTuple   objtup;
-       Relation    catalog = heap_open(address.classId, AccessShareLock);
+       Relation    catalog = table_open(address.classId, AccessShareLock);
 
        objtup = get_catalog_object_by_oid(catalog,
                                           get_object_attnum_oid(address.classId),
            }
        }
 
-       heap_close(catalog, AccessShareLock);
+       table_close(catalog, AccessShareLock);
    }
 
    /* object type */
    HeapTuple   constrTup;
    Form_pg_constraint constrForm;
 
-   constrRel = heap_open(ConstraintRelationId, AccessShareLock);
+   constrRel = table_open(ConstraintRelationId, AccessShareLock);
    constrTup = get_catalog_object_by_oid(constrRel, Anum_pg_constraint_oid,
                                          constroid);
    if (!HeapTupleIsValid(constrTup))
    else
        elog(ERROR, "invalid constraint %u", constrForm->oid);
 
-   heap_close(constrRel, AccessShareLock);
+   table_close(constrRel, AccessShareLock);
 }
 
 /*
                HeapTuple   tup;
                Form_pg_cast castForm;
 
-               castRel = heap_open(CastRelationId, AccessShareLock);
+               castRel = table_open(CastRelationId, AccessShareLock);
 
                tup = get_catalog_object_by_oid(castRel, Anum_pg_cast_oid,
                                                object->objectId);
                    *objargs = list_make1(format_type_be_qualified(castForm->casttarget));
                }
 
-               heap_close(castRel, AccessShareLock);
+               table_close(castRel, AccessShareLock);
                break;
            }
 
                Form_pg_attrdef attrdef;
                ObjectAddress colobject;
 
-               attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
+               attrdefDesc = table_open(AttrDefaultRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_attrdef_oid,
                                                        objname, objargs));
 
                systable_endscan(adscan);
-               heap_close(attrdefDesc, AccessShareLock);
+               table_close(attrdefDesc, AccessShareLock);
                break;
            }
 
                char       *ltype;
                char       *rtype;
 
-               amopDesc = heap_open(AccessMethodOperatorRelationId,
-                                    AccessShareLock);
+               amopDesc = table_open(AccessMethodOperatorRelationId,
+                                     AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_amop_oid,
                pfree(opfam.data);
 
                systable_endscan(amscan);
-               heap_close(amopDesc, AccessShareLock);
+               table_close(amopDesc, AccessShareLock);
                break;
            }
 
                char       *ltype;
                char       *rtype;
 
-               amprocDesc = heap_open(AccessMethodProcedureRelationId,
-                                      AccessShareLock);
+               amprocDesc = table_open(AccessMethodProcedureRelationId,
+                                       AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_amproc_oid,
                pfree(opfam.data);
 
                systable_endscan(amscan);
-               heap_close(amprocDesc, AccessShareLock);
+               table_close(amprocDesc, AccessShareLock);
                break;
            }
 
                HeapTuple   tup;
                Form_pg_rewrite rule;
 
-               ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
+               ruleDesc = table_open(RewriteRelationId, AccessShareLock);
 
                tup = get_catalog_object_by_oid(ruleDesc, Anum_pg_rewrite_oid,
                                                object->objectId);
                if (objname)
                    *objname = lappend(*objname, pstrdup(NameStr(rule->rulename)));
 
-               heap_close(ruleDesc, AccessShareLock);
+               table_close(ruleDesc, AccessShareLock);
                break;
            }
 
                HeapTuple   tup;
                Form_pg_trigger trig;
 
-               trigDesc = heap_open(TriggerRelationId, AccessShareLock);
+               trigDesc = table_open(TriggerRelationId, AccessShareLock);
 
                tup = get_catalog_object_by_oid(trigDesc, Anum_pg_trigger_oid,
                                                object->objectId);
                if (objname)
                    *objname = lappend(*objname, pstrdup(NameStr(trig->tgname)));
 
-               heap_close(trigDesc, AccessShareLock);
+               table_close(trigDesc, AccessShareLock);
                break;
            }
 
                char       *schema;
                char       *username;
 
-               defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
+               defaclrel = table_open(DefaultAclRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
                            Anum_pg_default_acl_oid,
                }
 
                systable_endscan(rcscan);
-               heap_close(defaclrel, AccessShareLock);
+               table_close(defaclrel, AccessShareLock);
                break;
            }
 
                HeapTuple   tup;
                Form_pg_policy policy;
 
-               polDesc = heap_open(PolicyRelationId, AccessShareLock);
+               polDesc = table_open(PolicyRelationId, AccessShareLock);
 
                tup = get_catalog_object_by_oid(polDesc, Anum_pg_policy_oid,
                                                object->objectId);
                if (objname)
                    *objname = lappend(*objname, pstrdup(NameStr(policy->polname)));
 
-               heap_close(polDesc, AccessShareLock);
+               table_close(polDesc, AccessShareLock);
                break;
            }
 
                char       *transformLang;
                char       *transformType;
 
-               transformDesc = heap_open(TransformRelationId, AccessShareLock);
+               transformDesc = table_open(TransformRelationId, AccessShareLock);
 
                tup = get_catalog_object_by_oid(transformDesc,
                                                Anum_pg_transform_oid,
                    *objargs = list_make1(pstrdup(transformLang));
                }
 
-               heap_close(transformDesc, AccessShareLock);
+               table_close(transformDesc, AccessShareLock);
            }
            break;
 
 
    Relation    catalogRelation;
    Oid         result;
 
-   catalogRelation = heap_open(InheritsRelationId, AccessShareLock);
+   catalogRelation = table_open(InheritsRelationId, AccessShareLock);
 
    result = get_partition_parent_worker(catalogRelation, relid);
 
    if (!OidIsValid(result))
        elog(ERROR, "could not find tuple for parent of relation %u", relid);
 
-   heap_close(catalogRelation, AccessShareLock);
+   table_close(catalogRelation, AccessShareLock);
 
    return result;
 }
    List       *result = NIL;
    Relation    inhRel;
 
-   inhRel = heap_open(InheritsRelationId, AccessShareLock);
+   inhRel = table_open(InheritsRelationId, AccessShareLock);
 
    get_partition_ancestors_worker(inhRel, relid, &result);
 
-   heap_close(inhRel, AccessShareLock);
+   table_close(inhRel, AccessShareLock);
 
    return result;
 }
    Relation    pg_partitioned_table;
    Form_pg_partitioned_table part_table_form;
 
-   pg_partitioned_table = heap_open(PartitionedRelationId, RowExclusiveLock);
+   pg_partitioned_table = table_open(PartitionedRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy1(PARTRELID, ObjectIdGetDatum(parentId));
 
    CatalogTupleUpdate(pg_partitioned_table, &tuple->t_self, tuple);
 
    heap_freetuple(tuple);
-   heap_close(pg_partitioned_table, RowExclusiveLock);
+   table_close(pg_partitioned_table, RowExclusiveLock);
 }
 
 /*
 
    /*
     * Okay to create the pg_aggregate entry.
     */
-   aggdesc = heap_open(AggregateRelationId, RowExclusiveLock);
+   aggdesc = table_open(AggregateRelationId, RowExclusiveLock);
    tupDesc = aggdesc->rd_att;
 
    /* initialize nulls and values */
    tup = heap_form_tuple(tupDesc, values, nulls);
    CatalogTupleInsert(aggdesc, tup);
 
-   heap_close(aggdesc, RowExclusiveLock);
+   table_close(aggdesc, RowExclusiveLock);
 
    /*
     * Create dependencies for the aggregate (above and beyond those already
 
    }
 
    /* open pg_collation; see below about the lock level */
-   rel = heap_open(CollationRelationId, ShareRowExclusiveLock);
+   rel = table_open(CollationRelationId, ShareRowExclusiveLock);
 
    /*
     * Also forbid a specific-encoding collation shadowing an any-encoding
    {
        if (quiet)
        {
-           heap_close(rel, NoLock);
+           table_close(rel, NoLock);
            return InvalidOid;
        }
        else if (if_not_exists)
        {
-           heap_close(rel, NoLock);
+           table_close(rel, NoLock);
            ereport(NOTICE,
                    (errcode(ERRCODE_DUPLICATE_OBJECT),
                     errmsg("collation \"%s\" already exists, skipping",
    InvokeObjectPostCreateHook(CollationRelationId, oid, 0);
 
    heap_freetuple(tup);
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return oid;
 }
    SysScanDesc scandesc;
    HeapTuple   tuple;
 
-   rel = heap_open(CollationRelationId, RowExclusiveLock);
+   rel = table_open(CollationRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scanKeyData,
                Anum_pg_collation_oid,
 
    systable_endscan(scandesc);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
    int         i;
    ObjectAddress conobject;
 
-   conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
 
    Assert(constraintName);
    namestrcpy(&cname, constraintName);
    conobject.objectId = conOid;
    conobject.objectSubId = 0;
 
-   heap_close(conDesc, RowExclusiveLock);
+   table_close(conDesc, RowExclusiveLock);
 
    if (OidIsValid(relId))
    {
    SysScanDesc conscan;
    ScanKeyData skey[3];
 
-   conDesc = heap_open(ConstraintRelationId, AccessShareLock);
+   conDesc = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conrelid,
    found = (HeapTupleIsValid(systable_getnext(conscan)));
 
    systable_endscan(conscan);
-   heap_close(conDesc, AccessShareLock);
+   table_close(conDesc, AccessShareLock);
 
    return found;
 }
    SysScanDesc conscan;
    ScanKeyData skey[2];
 
-   conDesc = heap_open(ConstraintRelationId, AccessShareLock);
+   conDesc = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conname,
    found = (HeapTupleIsValid(systable_getnext(conscan)));
 
    systable_endscan(conscan);
-   heap_close(conDesc, AccessShareLock);
+   table_close(conDesc, AccessShareLock);
 
    return found;
 }
    bool        found;
    ListCell   *l;
 
-   conDesc = heap_open(ConstraintRelationId, AccessShareLock);
+   conDesc = table_open(ConstraintRelationId, AccessShareLock);
 
    /* try the unmodified label first */
    StrNCpy(modlabel, label, sizeof(modlabel));
        snprintf(modlabel, sizeof(modlabel), "%s%d", label, ++pass);
    }
 
-   heap_close(conDesc, AccessShareLock);
+   table_close(conDesc, AccessShareLock);
 
    return conname;
 }
    HeapTuple   tup;
    Form_pg_constraint con;
 
-   conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conId));
    if (!HeapTupleIsValid(tup)) /* should not happen */
         * If the constraint is for a relation, open and exclusive-lock the
         * relation it's for.
         */
-       rel = heap_open(con->conrelid, AccessExclusiveLock);
+       rel = table_open(con->conrelid, AccessExclusiveLock);
 
        /*
         * We need to update the relcheck count if it is a check constraint
            HeapTuple   relTup;
            Form_pg_class classForm;
 
-           pgrel = heap_open(RelationRelationId, RowExclusiveLock);
+           pgrel = table_open(RelationRelationId, RowExclusiveLock);
            relTup = SearchSysCacheCopy1(RELOID,
                                         ObjectIdGetDatum(con->conrelid));
            if (!HeapTupleIsValid(relTup))
 
            heap_freetuple(relTup);
 
-           heap_close(pgrel, RowExclusiveLock);
+           table_close(pgrel, RowExclusiveLock);
        }
 
        /* Keep lock on constraint's rel until end of xact */
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
    else if (OidIsValid(con->contypid))
    {
 
    /* Clean up */
    ReleaseSysCache(tup);
-   heap_close(conDesc, RowExclusiveLock);
+   table_close(conDesc, RowExclusiveLock);
 }
 
 /*
    HeapTuple   tuple;
    Form_pg_constraint con;
 
-   conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy1(CONSTROID, ObjectIdGetDatum(conId));
    if (!HeapTupleIsValid(tuple))
    InvokeObjectPostAlterHook(ConstraintRelationId, conId, 0);
 
    heap_freetuple(tuple);
-   heap_close(conDesc, RowExclusiveLock);
+   table_close(conDesc, RowExclusiveLock);
 }
 
 /*
    SysScanDesc scan;
    HeapTuple   tup;
 
-   conRel = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conRel = table_open(ConstraintRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_constraint_conrelid,
 
    systable_endscan(scan);
 
-   heap_close(conRel, RowExclusiveLock);
+   table_close(conRel, RowExclusiveLock);
 }
 
 /*
    ObjectAddress depender;
    ObjectAddress referenced;
 
-   constrRel = heap_open(ConstraintRelationId, RowExclusiveLock);
+   constrRel = table_open(ConstraintRelationId, RowExclusiveLock);
    tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(childConstrId));
    if (!HeapTupleIsValid(tuple))
        elog(ERROR, "cache lookup failed for constraint %u", childConstrId);
    }
 
    ReleaseSysCache(tuple);
-   heap_close(constrRel, RowExclusiveLock);
+   table_close(constrRel, RowExclusiveLock);
 }
 
 
    ScanKeyData skey[3];
    Oid         conOid = InvalidOid;
 
-   pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+   pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conrelid,
                 errmsg("constraint \"%s\" for table \"%s\" does not exist",
                        conname, get_rel_name(relid))));
 
-   heap_close(pg_constraint, AccessShareLock);
+   table_close(pg_constraint, AccessShareLock);
 
    return conOid;
 }
    /* Set *constraintOid, to avoid complaints about uninitialized vars */
    *constraintOid = InvalidOid;
 
-   pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+   pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conrelid,
                 errmsg("constraint \"%s\" for table \"%s\" does not exist",
                        conname, get_rel_name(relid))));
 
-   heap_close(pg_constraint, AccessShareLock);
+   table_close(pg_constraint, AccessShareLock);
 
    return conattnos;
 }
    HeapTuple   tuple;
    Oid         constraintId = InvalidOid;
 
-   pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+   pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&key,
                Anum_pg_constraint_conrelid,
    }
    systable_endscan(scan);
 
-   heap_close(pg_constraint, AccessShareLock);
+   table_close(pg_constraint, AccessShareLock);
    return constraintId;
 }
 
    ScanKeyData skey[3];
    Oid         conOid = InvalidOid;
 
-   pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+   pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conrelid,
                 errmsg("constraint \"%s\" for domain %s does not exist",
                        conname, format_type_be(typid))));
 
-   heap_close(pg_constraint, AccessShareLock);
+   table_close(pg_constraint, AccessShareLock);
 
    return conOid;
 }
    *constraintOid = InvalidOid;
 
    /* Scan pg_constraint for constraints of the target rel */
-   pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+   pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conrelid,
 
    systable_endscan(scan);
 
-   heap_close(pg_constraint, AccessShareLock);
+   table_close(pg_constraint, AccessShareLock);
 
    return pkattnos;
 }
 
    }
 
    /* open pg_conversion */
-   rel = heap_open(ConversionRelationId, RowExclusiveLock);
+   rel = table_open(ConversionRelationId, RowExclusiveLock);
    tupDesc = rel->rd_att;
 
    /* initialize nulls and values */
    InvokeObjectPostCreateHook(ConversionRelationId, oid, 0);
 
    heap_freetuple(tup);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
                ObjectIdGetDatum(conversionOid));
 
    /* open pg_conversion */
-   rel = heap_open(ConversionRelationId, RowExclusiveLock);
+   rel = table_open(ConversionRelationId, RowExclusiveLock);
 
    scan = heap_beginscan_catalog(rel, 1, &scanKeyData);
 
    else
        elog(ERROR, "could not find tuple for conversion %u", conversionOid);
    heap_endscan(scan);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
 
 
    /* Get the old tuple, if any. */
 
-   rel = heap_open(DbRoleSettingRelationId, RowExclusiveLock);
+   rel = table_open(DbRoleSettingRelationId, RowExclusiveLock);
    ScanKeyInit(&scankey[0],
                Anum_pg_db_role_setting_setdatabase,
                BTEqualStrategyNumber, F_OIDEQ,
    systable_endscan(scan);
 
    /* Close pg_db_role_setting, but keep lock till commit */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
    HeapTuple   tup;
    int         numkeys = 0;
 
-   relsetting = heap_open(DbRoleSettingRelationId, RowExclusiveLock);
+   relsetting = table_open(DbRoleSettingRelationId, RowExclusiveLock);
 
    if (OidIsValid(databaseid))
    {
    }
    heap_endscan(scan);
 
-   heap_close(relsetting, RowExclusiveLock);
+   table_close(relsetting, RowExclusiveLock);
 }
 
 /*
 
    if (IsBootstrapProcessingMode())
        return;
 
-   dependDesc = heap_open(DependRelationId, RowExclusiveLock);
+   dependDesc = table_open(DependRelationId, RowExclusiveLock);
 
    /* Don't open indexes unless we need to make an update */
    indstate = NULL;
    if (indstate != NULL)
        CatalogCloseIndexes(indstate);
 
-   heap_close(dependDesc, RowExclusiveLock);
+   table_close(dependDesc, RowExclusiveLock);
 }
 
 /*
    SysScanDesc scan;
    HeapTuple   tup;
 
-   depRel = heap_open(DependRelationId, RowExclusiveLock);
+   depRel = table_open(DependRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_classid,
 
    systable_endscan(scan);
 
-   heap_close(depRel, RowExclusiveLock);
+   table_close(depRel, RowExclusiveLock);
 
    return count;
 }
    SysScanDesc scan;
    HeapTuple   tup;
 
-   depRel = heap_open(DependRelationId, RowExclusiveLock);
+   depRel = table_open(DependRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_classid,
 
    systable_endscan(scan);
 
-   heap_close(depRel, RowExclusiveLock);
+   table_close(depRel, RowExclusiveLock);
 
    return count;
 }
    ObjectAddress objAddr;
    bool        newIsPinned;
 
-   depRel = heap_open(DependRelationId, RowExclusiveLock);
+   depRel = table_open(DependRelationId, RowExclusiveLock);
 
    /*
     * If oldRefObjectId is pinned, there won't be any dependency entries on
 
    systable_endscan(scan);
 
-   heap_close(depRel, RowExclusiveLock);
+   table_close(depRel, RowExclusiveLock);
 
    return count;
 }
    SysScanDesc scan;
    HeapTuple   tup;
 
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_classid,
 
    systable_endscan(scan);
 
-   heap_close(depRel, AccessShareLock);
+   table_close(depRel, AccessShareLock);
 
    return result;
 }
    SysScanDesc scan;
    HeapTuple   tup;
 
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_classid,
 
    systable_endscan(scan);
 
-   heap_close(depRel, AccessShareLock);
+   table_close(depRel, AccessShareLock);
 
    return ret;
 }
    SysScanDesc scan;
    HeapTuple   tup;
 
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_refclassid,
 
    systable_endscan(scan);
 
-   heap_close(depRel, AccessShareLock);
+   table_close(depRel, AccessShareLock);
 
    return result;
 }
    HeapTuple   tup;
 
    /* Search the dependency table for the dependent index */
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_refclassid,
    }
 
    systable_endscan(scan);
-   heap_close(depRel, AccessShareLock);
+   table_close(depRel, AccessShareLock);
 
    return indexId;
 }
    HeapTuple   tup;
 
    /* Search the dependency table for the index */
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_classid,
    }
 
    systable_endscan(scan);
-   heap_close(depRel, AccessShareLock);
+   table_close(depRel, AccessShareLock);
 
    return constraintId;
 }
 
     * probably not worth trying harder.
     */
 
-   pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+   pg_enum = table_open(EnumRelationId, RowExclusiveLock);
 
    /*
     * Allocate OIDs for the enum's members.
 
    /* clean up */
    pfree(oids);
-   heap_close(pg_enum, RowExclusiveLock);
+   table_close(pg_enum, RowExclusiveLock);
 }
 
 
    SysScanDesc scan;
    HeapTuple   tup;
 
-   pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+   pg_enum = table_open(EnumRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_enum_enumtypid,
 
    systable_endscan(scan);
 
-   heap_close(pg_enum, RowExclusiveLock);
+   table_close(pg_enum, RowExclusiveLock);
 }
 
 /*
                            newVal)));
    }
 
-   pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+   pg_enum = table_open(EnumRelationId, RowExclusiveLock);
 
    /* If we have to renumber the existing members, we restart from here */
 restart:
    CatalogTupleInsert(pg_enum, enum_tup);
    heap_freetuple(enum_tup);
 
-   heap_close(pg_enum, RowExclusiveLock);
+   table_close(pg_enum, RowExclusiveLock);
 
    /* Set up the blacklist hash if not already done in this transaction */
    if (enum_blacklist == NULL)
     */
    LockDatabaseObject(TypeRelationId, enumTypeOid, 0, ExclusiveLock);
 
-   pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+   pg_enum = table_open(EnumRelationId, RowExclusiveLock);
 
    /* Get the list of existing members of the enum */
    list = SearchSysCacheList1(ENUMTYPOIDNAME,
    CatalogTupleUpdate(pg_enum, &enum_tup->t_self, enum_tup);
    heap_freetuple(enum_tup);
 
-   heap_close(pg_enum, RowExclusiveLock);
+   table_close(pg_enum, RowExclusiveLock);
 }
 
 
 
    oidarr = (Oid *) palloc(maxoids * sizeof(Oid));
    numoids = 0;
 
-   relation = heap_open(InheritsRelationId, AccessShareLock);
+   relation = table_open(InheritsRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_inherits_inhparent,
 
    systable_endscan(scan);
 
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    /*
     * If we found more than one child, sort them by OID.  This ensures
    ScanKeyData skey;
    bool        result;
 
-   catalog = heap_open(InheritsRelationId, AccessShareLock);
+   catalog = table_open(InheritsRelationId, AccessShareLock);
    ScanKeyInit(&skey, Anum_pg_inherits_inhrelid, BTEqualStrategyNumber,
                F_OIDEQ, ObjectIdGetDatum(relationId));
    scan = systable_beginscan(catalog, InheritsRelidSeqnoIndexId, true,
                              NULL, 1, &skey);
    result = HeapTupleIsValid(systable_getnext(scan));
    systable_endscan(scan);
-   heap_close(catalog, AccessShareLock);
+   table_close(catalog, AccessShareLock);
 
    return result;
 }
    queue = list_make1_oid(subclassRelid);
    visited = NIL;
 
-   inhrel = heap_open(InheritsRelationId, AccessShareLock);
+   inhrel = table_open(InheritsRelationId, AccessShareLock);
 
    /*
     * Use queue to do a breadth-first traversal of the inheritance graph from
    }
 
    /* clean up ... */
-   heap_close(inhrel, AccessShareLock);
+   table_close(inhrel, AccessShareLock);
 
    list_free(visited);
    list_free(queue);
    HeapTuple   tuple;
    Relation    inhRelation;
 
-   inhRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+   inhRelation = table_open(InheritsRelationId, RowExclusiveLock);
 
    /*
     * Make the pg_inherits entry
 
    heap_freetuple(tuple);
 
-   heap_close(inhRelation, RowExclusiveLock);
+   table_close(inhRelation, RowExclusiveLock);
 }
 
 /*
    /*
     * Find pg_inherits entries by inhrelid.
     */
-   catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+   catalogRelation = table_open(InheritsRelationId, RowExclusiveLock);
    ScanKeyInit(&key,
                Anum_pg_inherits_inhrelid,
                BTEqualStrategyNumber, F_OIDEQ,
 
    /* Done */
    systable_endscan(scan);
-   heap_close(catalogRelation, RowExclusiveLock);
+   table_close(catalogRelation, RowExclusiveLock);
 
    return found;
 }
 
    Datum       values[Natts_pg_largeobject_metadata];
    bool        nulls[Natts_pg_largeobject_metadata];
 
-   pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
-                          RowExclusiveLock);
+   pg_lo_meta = table_open(LargeObjectMetadataRelationId,
+                           RowExclusiveLock);
 
    /*
     * Insert metadata of the largeobject
 
    heap_freetuple(ntup);
 
-   heap_close(pg_lo_meta, RowExclusiveLock);
+   table_close(pg_lo_meta, RowExclusiveLock);
 
    return loid_new;
 }
    SysScanDesc scan;
    HeapTuple   tuple;
 
-   pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
-                          RowExclusiveLock);
+   pg_lo_meta = table_open(LargeObjectMetadataRelationId,
+                           RowExclusiveLock);
 
-   pg_largeobject = heap_open(LargeObjectRelationId,
-                              RowExclusiveLock);
+   pg_largeobject = table_open(LargeObjectRelationId,
+                               RowExclusiveLock);
 
    /*
     * Delete an entry from pg_largeobject_metadata
 
    systable_endscan(scan);
 
-   heap_close(pg_largeobject, RowExclusiveLock);
+   table_close(pg_largeobject, RowExclusiveLock);
 
-   heap_close(pg_lo_meta, RowExclusiveLock);
+   table_close(pg_lo_meta, RowExclusiveLock);
 }
 
 /*
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(loid));
 
-   pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
-                          AccessShareLock);
+   pg_lo_meta = table_open(LargeObjectMetadataRelationId,
+                           AccessShareLock);
 
    sd = systable_beginscan(pg_lo_meta,
                            LargeObjectMetadataOidIndexId, true,
 
    systable_endscan(sd);
 
-   heap_close(pg_lo_meta, AccessShareLock);
+   table_close(pg_lo_meta, AccessShareLock);
 
    return retval;
 }
 
    else
        nspacl = NULL;
 
-   nspdesc = heap_open(NamespaceRelationId, RowExclusiveLock);
+   nspdesc = table_open(NamespaceRelationId, RowExclusiveLock);
    tupDesc = nspdesc->rd_att;
 
    /* initialize nulls and values */
    CatalogTupleInsert(nspdesc, tup);
    Assert(OidIsValid(nspoid));
 
-   heap_close(nspdesc, RowExclusiveLock);
+   table_close(nspdesc, RowExclusiveLock);
 
    /* Record dependencies */
    myself.classId = NamespaceRelationId;
 
    /*
     * open pg_operator
     */
-   pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+   pg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);
    tupDesc = pg_operator_desc->rd_att;
 
    /*
    /*
     * close the operator relation and return the oid.
     */
-   heap_close(pg_operator_desc, RowExclusiveLock);
+   table_close(pg_operator_desc, RowExclusiveLock);
 
    return operatorObjectId;
 }
    values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(restrictionId);
    values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(joinId);
 
-   pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+   pg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);
 
    /*
     * If we are replacing an operator shell, update; else insert
    /* Post creation hook for new operator */
    InvokeObjectPostCreateHook(OperatorRelationId, operatorObjectId, 0);
 
-   heap_close(pg_operator_desc, RowExclusiveLock);
+   table_close(pg_operator_desc, RowExclusiveLock);
 
    /*
     * If a commutator and/or negator link is provided, update the other
        CommandCounterIncrement();
 
    /* Open the relation. */
-   pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+   pg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);
 
    /* Get a writable copy of the commutator's tuple. */
    if (OidIsValid(commId))
    }
 
    /* Close relation and release catalog lock. */
-   heap_close(pg_operator_desc, RowExclusiveLock);
+   table_close(pg_operator_desc, RowExclusiveLock);
 }
 
 /*
 
        nulls[Anum_pg_proc_proconfig - 1] = true;
    /* proacl will be determined later */
 
-   rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+   rel = table_open(ProcedureRelationId, RowExclusiveLock);
    tupDesc = RelationGetDescr(rel);
 
    /* Check for pre-existing definition */
    /* Post creation hook for new function */
    InvokeObjectPostCreateHook(ProcedureRelationId, retval, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    /* Verify function body */
    if (OidIsValid(languageValidator))
 
    ObjectAddress myself,
                referenced;
 
-   rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelRelationId, RowExclusiveLock);
 
    /*
     * Check for duplicates. Note that this does not really prevent
    if (SearchSysCacheExists2(PUBLICATIONRELMAP, ObjectIdGetDatum(relid),
                              ObjectIdGetDatum(pubid)))
    {
-       heap_close(rel, RowExclusiveLock);
+       table_close(rel, RowExclusiveLock);
 
        if (if_not_exists)
            return InvalidObjectAddress;
    recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
 
    /* Close the table. */
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    /* Invalidate relcache so that publication info is rebuilt. */
    CacheInvalidateRelcache(targetrel);
    HeapTuple   tup;
 
    /* Find all publications associated with the relation. */
-   pubrelsrel = heap_open(PublicationRelRelationId, AccessShareLock);
+   pubrelsrel = table_open(PublicationRelRelationId, AccessShareLock);
 
    ScanKeyInit(&scankey,
                Anum_pg_publication_rel_prpubid,
    }
 
    systable_endscan(scan);
-   heap_close(pubrelsrel, AccessShareLock);
+   table_close(pubrelsrel, AccessShareLock);
 
    return result;
 }
    HeapTuple   tup;
 
    /* Find all publications that are marked as for all tables. */
-   rel = heap_open(PublicationRelationId, AccessShareLock);
+   rel = table_open(PublicationRelationId, AccessShareLock);
 
    ScanKeyInit(&scankey,
                Anum_pg_publication_puballtables,
    }
 
    systable_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return result;
 }
    HeapTuple   tuple;
    List       *result = NIL;
 
-   classRel = heap_open(RelationRelationId, AccessShareLock);
+   classRel = table_open(RelationRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_class_relkind,
    }
 
    heap_endscan(scan);
-   heap_close(classRel, AccessShareLock);
+   table_close(classRel, AccessShareLock);
 
    return result;
 }
 
    ObjectAddress myself;
    ObjectAddress referenced;
 
-   pg_range = heap_open(RangeRelationId, RowExclusiveLock);
+   pg_range = table_open(RangeRelationId, RowExclusiveLock);
 
    memset(nulls, 0, sizeof(nulls));
 
        recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
    }
 
-   heap_close(pg_range, RowExclusiveLock);
+   table_close(pg_range, RowExclusiveLock);
 }
 
 
    SysScanDesc scan;
    HeapTuple   tup;
 
-   pg_range = heap_open(RangeRelationId, RowExclusiveLock);
+   pg_range = table_open(RangeRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_range_rngtypid,
 
    systable_endscan(scan);
 
-   heap_close(pg_range, RowExclusiveLock);
+   table_close(pg_range, RowExclusiveLock);
 }
 
    if (IsBootstrapProcessingMode())
        return;
 
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
    /* If the referenced object is pinned, do nothing. */
    if (!isSharedObjectPinned(referenced->classId, referenced->objectId,
                           deptype);
    }
 
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 }
 
 /*
 {
    Relation    sdepRel;
 
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
    /* Adjust the SHARED_DEPENDENCY_OWNER entry */
    shdepChangeDep(sdepRel,
                        AuthIdRelationId, newOwnerId,
                        SHARED_DEPENDENCY_ACL);
 
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 }
 
 /*
 
    if (noldmembers > 0 || nnewmembers > 0)
    {
-       sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+       sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
        /* Add new dependencies that weren't already present */
        for (i = 0; i < nnewmembers; i++)
                                SHARED_DEPENDENCY_ACL);
        }
 
-       heap_close(sdepRel, RowExclusiveLock);
+       table_close(sdepRel, RowExclusiveLock);
    }
 
    if (oldmembers)
    initStringInfo(&descs);
    initStringInfo(&alldescs);
 
-   sdepRel = heap_open(SharedDependRelationId, AccessShareLock);
+   sdepRel = table_open(SharedDependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_shdepend_refclassid,
 
    systable_endscan(scan);
 
-   heap_close(sdepRel, AccessShareLock);
+   table_close(sdepRel, AccessShareLock);
 
    /*
     * Summarize dependencies in remote databases.
    bool        nulls[Natts_pg_shdepend];
    bool        replace[Natts_pg_shdepend];
 
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
    sdepDesc = RelationGetDescr(sdepRel);
 
    indstate = CatalogOpenIndexes(sdepRel);
    systable_endscan(scan);
 
    CatalogCloseIndexes(indstate);
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 }
 
 /*
    SysScanDesc scan;
    HeapTuple   tup;
 
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
    /*
     * First, delete all the entries that have the database Oid in the dbid
                        InvalidOid, InvalidOid,
                        SHARED_DEPENDENCY_INVALID);
 
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 }
 
 /*
 {
    Relation    sdepRel;
 
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
    shdepDropDependency(sdepRel, classId, objectId, objectSubId,
                        (objectSubId == 0),
                        InvalidOid, InvalidOid,
                        SHARED_DEPENDENCY_INVALID);
 
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 }
 
 /*
     * acquire RowExclusiveLock.  Better get that right now to avoid potential
     * deadlock failures.
     */
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
    /*
     * For each role, find the dependent objects and drop them using the
    /* the dependency mechanism does the actual work */
    performMultipleDeletions(deleteobjs, behavior, 0);
 
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 
    free_object_addresses(deleteobjs);
 }
     * acquire RowExclusiveLock.  Better get that right now to avoid potential
     * deadlock problems.
     */
-   sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+   sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
 
    foreach(cell, roleids)
    {
                        if (classId == LargeObjectRelationId)
                            classId = LargeObjectMetadataRelationId;
 
-                       catalog = heap_open(classId, RowExclusiveLock);
+                       catalog = table_open(classId, RowExclusiveLock);
 
                        AlterObjectOwner_internal(catalog, sdepForm->objid,
                                                  newrole);
 
-                       heap_close(catalog, NoLock);
+                       table_close(catalog, NoLock);
                    }
                    break;
 
        systable_endscan(scan);
    }
 
-   heap_close(sdepRel, RowExclusiveLock);
+   table_close(sdepRel, RowExclusiveLock);
 }
 
    SysScanDesc scan;
    HeapTuple   tup;
 
-   rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scankey,
                Anum_pg_subscription_subdbid,
 
    systable_endscan(scan);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return nsubs;
 }
 
    LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
 
-   rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
 
    /* Try finding existing mapping. */
    tup = SearchSysCacheCopy2(SUBSCRIPTIONRELMAP,
    heap_freetuple(tup);
 
    /* Cleanup. */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
 
    LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
 
-   rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
 
    /* Try finding existing mapping. */
    tup = SearchSysCacheCopy2(SUBSCRIPTIONRELMAP,
    CatalogTupleUpdate(rel, &tup->t_self, tup);
 
    /* Cleanup. */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
    bool        isnull;
    Datum       d;
 
-   rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
+   rel = table_open(SubscriptionRelRelationId, AccessShareLock);
 
    /* Try finding the mapping. */
    tup = SearchSysCache2(SUBSCRIPTIONRELMAP,
    {
        if (missing_ok)
        {
-           heap_close(rel, AccessShareLock);
+           table_close(rel, AccessShareLock);
            *sublsn = InvalidXLogRecPtr;
            return SUBREL_STATE_UNKNOWN;
        }
 
    /* Cleanup */
    ReleaseSysCache(tup);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return substate;
 }
    HeapTuple   tup;
    int         nkeys = 0;
 
-   rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
 
    if (OidIsValid(subid))
    {
    }
    heap_endscan(scan);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
    ScanKeyData skey[2];
    SysScanDesc scan;
 
-   rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
+   rel = table_open(SubscriptionRelRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[nkeys++],
                Anum_pg_subscription_rel_srsubid,
 
    /* Cleanup */
    systable_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return res;
 }
    ScanKeyData skey[2];
    SysScanDesc scan;
 
-   rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
+   rel = table_open(SubscriptionRelRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[nkeys++],
                Anum_pg_subscription_rel_srsubid,
 
    /* Cleanup */
    systable_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return res;
 }
 
    /*
     * open pg_type
     */
-   pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
+   pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
    tupDesc = pg_type_desc->rd_att;
 
    /*
     * clean up and return the type-oid
     */
    heap_freetuple(tup);
-   heap_close(pg_type_desc, RowExclusiveLock);
+   table_close(pg_type_desc, RowExclusiveLock);
 
    return address;
 }
     * NOTE: updating will not work correctly in bootstrap mode; but we don't
     * expect to be overwriting any shell types in bootstrap mode.
     */
-   pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
+   pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy2(TYPENAMENSP,
                              CStringGetDatum(typeName),
    /*
     * finish up
     */
-   heap_close(pg_type_desc, RowExclusiveLock);
+   table_close(pg_type_desc, RowExclusiveLock);
 
    return address;
 }
    Oid         arrayOid;
    Oid         oldTypeOid;
 
-   pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
+   pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
    if (!HeapTupleIsValid(tuple))
    InvokeObjectPostAlterHook(TypeRelationId, typeOid, 0);
 
    heap_freetuple(tuple);
-   heap_close(pg_type_desc, RowExclusiveLock);
+   table_close(pg_type_desc, RowExclusiveLock);
 
    /*
     * If the type has an array type, recurse to handle that.  But we don't
     * The idea is to prepend underscores as needed until we make a name that
     * doesn't collide with anything...
     */
-   pg_type_desc = heap_open(TypeRelationId, AccessShareLock);
+   pg_type_desc = table_open(TypeRelationId, AccessShareLock);
 
    for (i = 1; i < NAMEDATALEN - 1; i++)
    {
            break;
    }
 
-   heap_close(pg_type_desc, AccessShareLock);
+   table_close(pg_type_desc, AccessShareLock);
 
    if (i >= NAMEDATALEN - 1)
        ereport(ERROR,
 
 {
    Relation    rel;
 
-   rel = heap_open(relOid, lockmode);
+   rel = table_open(relOid, lockmode);
 
    /* create_toast_table does all the work */
    (void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, lockmode, check);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
 {
    Relation    rel;
 
-   rel = heap_openrv(makeRangeVar(NULL, relName, -1), AccessExclusiveLock);
+   rel = table_openrv(makeRangeVar(NULL, relName, -1), AccessExclusiveLock);
 
    if (rel->rd_rel->relkind != RELKIND_RELATION &&
        rel->rd_rel->relkind != RELKIND_MATVIEW)
        elog(ERROR, "\"%s\" does not require a toast table",
             relName);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 
                                           NULL);
    Assert(toast_relid != InvalidOid);
 
-   /* make the toast relation visible, else heap_open will fail */
+   /* make the toast relation visible, else table_open will fail */
    CommandCounterIncrement();
 
    /* ShareLock is not really needed here, but take it anyway */
-   toast_rel = heap_open(toast_relid, ShareLock);
+   toast_rel = table_open(toast_relid, ShareLock);
 
    /*
     * Create unique index on chunk_id, chunk_seq.
                 collationObjectId, classObjectId, coloptions, (Datum) 0,
                 INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL);
 
-   heap_close(toast_rel, NoLock);
+   table_close(toast_rel, NoLock);
 
    /*
     * Store the toast table's OID in the parent relation's pg_class row
     */
-   class_rel = heap_open(RelationRelationId, RowExclusiveLock);
+   class_rel = table_open(RelationRelationId, RowExclusiveLock);
 
    reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
    if (!HeapTupleIsValid(reltup))
 
    heap_freetuple(reltup);
 
-   heap_close(class_rel, RowExclusiveLock);
+   table_close(class_rel, RowExclusiveLock);
 
    /*
     * Register dependency from the toast table to the master, so that the
 
                                             AccessExclusiveLock, false);
                Assert(relation == NULL);
 
-               catalog = heap_open(address.classId, RowExclusiveLock);
+               catalog = table_open(address.classId, RowExclusiveLock);
                AlterObjectRename_internal(catalog,
                                           address.objectId,
                                           stmt->newname);
-               heap_close(catalog, RowExclusiveLock);
+               table_close(catalog, RowExclusiveLock);
 
                return address;
            }
     * don't need the relation here, but we'll retain the lock until commit.
     */
    if (rel)
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
 
    refAddr = get_object_address(OBJECT_EXTENSION, (Node *) stmt->extname,
                                 &rel, AccessExclusiveLock, false);
                                             false);
                Assert(relation == NULL);
                classId = address.classId;
-               catalog = heap_open(classId, RowExclusiveLock);
+               catalog = table_open(classId, RowExclusiveLock);
                nspOid = LookupCreationNamespace(stmt->newschema);
 
                oldNspOid = AlterObjectNamespace_internal(catalog, address.objectId,
                                                          nspOid);
-               heap_close(catalog, RowExclusiveLock);
+               table_close(catalog, RowExclusiveLock);
            }
            break;
 
            {
                Relation    catalog;
 
-               catalog = heap_open(classId, RowExclusiveLock);
+               catalog = table_open(classId, RowExclusiveLock);
 
                oldNspOid = AlterObjectNamespace_internal(catalog, objid,
                                                          nspOid);
 
-               heap_close(catalog, RowExclusiveLock);
+               table_close(catalog, RowExclusiveLock);
            }
            break;
 
                if (classId == LargeObjectRelationId)
                    classId = LargeObjectMetadataRelationId;
 
-               catalog = heap_open(classId, RowExclusiveLock);
+               catalog = table_open(classId, RowExclusiveLock);
 
                AlterObjectOwner_internal(catalog, address.objectId, newowner);
-               heap_close(catalog, RowExclusiveLock);
+               table_close(catalog, RowExclusiveLock);
 
                return address;
            }
 
    Datum       values[Natts_pg_am];
    HeapTuple   tup;
 
-   rel = heap_open(AccessMethodRelationId, RowExclusiveLock);
+   rel = table_open(AccessMethodRelationId, RowExclusiveLock);
 
    /* Must be super user */
    if (!superuser())
 
    recordDependencyOnCurrentExtension(&myself, false);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to drop access methods")));
 
-   relation = heap_open(AccessMethodRelationId, RowExclusiveLock);
+   relation = table_open(AccessMethodRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(AMOID, ObjectIdGetDatum(amOid));
    if (!HeapTupleIsValid(tup))
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /*
 
        BlockNumber relpages = 0;
 
        /* We already got the needed lock */
-       childrel = heap_open(childOID, NoLock);
+       childrel = table_open(childOID, NoLock);
 
        /* Ignore if temp table of another backend */
        if (RELATION_IS_OTHER_TEMP(childrel))
        {
            /* ... but release the lock on it */
            Assert(childrel != onerel);
-           heap_close(childrel, AccessShareLock);
+           table_close(childrel, AccessShareLock);
            continue;
        }
 
            {
                /* ignore, but release the lock on it */
                Assert(childrel != onerel);
-               heap_close(childrel, AccessShareLock);
+               table_close(childrel, AccessShareLock);
                continue;
            }
        }
             */
            Assert(childrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
            if (childrel != onerel)
-               heap_close(childrel, AccessShareLock);
+               table_close(childrel, AccessShareLock);
            else
-               heap_close(childrel, NoLock);
+               table_close(childrel, NoLock);
            continue;
        }
 
         * Note: we cannot release the child-table locks, since we may have
         * pointers to their TOAST tables in the sampled rows.
         */
-       heap_close(childrel, NoLock);
+       table_close(childrel, NoLock);
    }
 
    return numrows;
    if (natts <= 0)
        return;                 /* nothing to do */
 
-   sd = heap_open(StatisticRelationId, RowExclusiveLock);
+   sd = table_open(StatisticRelationId, RowExclusiveLock);
 
    for (attno = 0; attno < natts; attno++)
    {
        heap_freetuple(stup);
    }
 
-   heap_close(sd, RowExclusiveLock);
+   table_close(sd, RowExclusiveLock);
 }
 
 /*
 
                                            AccessExclusiveLock,
                                            0,
                                            RangeVarCallbackOwnsTable, NULL);
-       rel = heap_open(tableOid, NoLock);
+       rel = table_open(tableOid, NoLock);
 
        /*
         * Reject clustering a remote temp table ... their local buffer
        }
 
        /* close relation, keep lock till commit */
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
 
        /* Do the job. */
        cluster_rel(tableOid, indexOid, stmt->options);
    /* rebuild_relation does all the dirty work */
    rebuild_relation(OldHeap, indexOid, verbose);
 
-   /* NB: rebuild_relation does heap_close() on OldHeap */
+   /* NB: rebuild_relation does table_close() on OldHeap */
 }
 
 /*
    /*
     * Check each index of the relation and set/clear the bit as needed.
     */
-   pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+   pg_index = table_open(IndexRelationId, RowExclusiveLock);
 
    foreach(index, RelationGetIndexList(rel))
    {
        heap_freetuple(indexTuple);
    }
 
-   heap_close(pg_index, RowExclusiveLock);
+   table_close(pg_index, RowExclusiveLock);
 }
 
 /*
    is_system_catalog = IsSystemRelation(OldHeap);
 
    /* Close relcache entry, but keep lock until transaction commit */
-   heap_close(OldHeap, NoLock);
+   table_close(OldHeap, NoLock);
 
    /* Create the transient table that will receive the re-ordered data */
    OIDNewHeap = make_new_heap(tableOid, tableSpace,
    bool        isNull;
    Oid         namespaceid;
 
-   OldHeap = heap_open(OIDOldHeap, lockmode);
+   OldHeap = table_open(OIDOldHeap, lockmode);
    OldHeapDesc = RelationGetDescr(OldHeap);
 
    /*
 
    /*
     * Advance command counter so that the newly-created relation's catalog
-    * tuples will be visible to heap_open.
+    * tuples will be visible to table_open.
     */
    CommandCounterIncrement();
 
        ReleaseSysCache(tuple);
    }
 
-   heap_close(OldHeap, NoLock);
+   table_close(OldHeap, NoLock);
 
    return OIDNewHeap;
 }
    /*
     * Open the relations we need.
     */
-   NewHeap = heap_open(OIDNewHeap, AccessExclusiveLock);
-   OldHeap = heap_open(OIDOldHeap, AccessExclusiveLock);
+   NewHeap = table_open(OIDNewHeap, AccessExclusiveLock);
+   OldHeap = table_open(OIDOldHeap, AccessExclusiveLock);
    if (OidIsValid(OIDOldIndex))
        OldIndex = index_open(OIDOldIndex, AccessExclusiveLock);
    else
 
    if (OldIndex != NULL)
        index_close(OldIndex, NoLock);
-   heap_close(OldHeap, NoLock);
-   heap_close(NewHeap, NoLock);
+   table_close(OldHeap, NoLock);
+   table_close(NewHeap, NoLock);
 
    /* Update pg_class to reflect the correct values of pages and tuples. */
-   relRelation = heap_open(RelationRelationId, RowExclusiveLock);
+   relRelation = table_open(RelationRelationId, RowExclusiveLock);
 
    reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDNewHeap));
    if (!HeapTupleIsValid(reltup))
 
    /* Clean up. */
    heap_freetuple(reltup);
-   heap_close(relRelation, RowExclusiveLock);
+   table_close(relRelation, RowExclusiveLock);
 
    /* Make the update visible */
    CommandCounterIncrement();
    char        swptmpchr;
 
    /* We need writable copies of both pg_class tuples. */
-   relRelation = heap_open(RelationRelationId, RowExclusiveLock);
+   relRelation = table_open(RelationRelationId, RowExclusiveLock);
 
    reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1));
    if (!HeapTupleIsValid(reltup1))
    heap_freetuple(reltup1);
    heap_freetuple(reltup2);
 
-   heap_close(relRelation, RowExclusiveLock);
+   table_close(relRelation, RowExclusiveLock);
 
    /*
     * Close both relcache entries' smgr links.  We need this kluge because
        HeapTuple   reltup;
        Form_pg_class relform;
 
-       relRelation = heap_open(RelationRelationId, RowExclusiveLock);
+       relRelation = table_open(RelationRelationId, RowExclusiveLock);
 
        reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDOldHeap));
        if (!HeapTupleIsValid(reltup))
 
        CatalogTupleUpdate(relRelation, &reltup->t_self, reltup);
 
-       heap_close(relRelation, RowExclusiveLock);
+       table_close(relRelation, RowExclusiveLock);
    }
 
    /* Destroy new heap with old filenode */
    {
        Relation    newrel;
 
-       newrel = heap_open(OIDOldHeap, NoLock);
+       newrel = table_open(OIDOldHeap, NoLock);
        if (OidIsValid(newrel->rd_rel->reltoastrelid))
        {
            Oid         toastidx;
    {
        Relation    newrel;
 
-       newrel = heap_open(OIDOldHeap, NoLock);
+       newrel = table_open(OIDOldHeap, NoLock);
        RelationClearMissing(newrel);
        relation_close(newrel, NoLock);
    }
     * have indisclustered set, because CLUSTER will refuse to set it when
     * called with one of them as argument.
     */
-   indRelation = heap_open(IndexRelationId, AccessShareLock);
+   indRelation = table_open(IndexRelationId, AccessShareLock);
    ScanKeyInit(&entry,
                Anum_pg_index_indisclustered,
                BTEqualStrategyNumber, F_BOOLEQ,
 
    char       *newversion;
    ObjectAddress address;
 
-   rel = heap_open(CollationRelationId, RowExclusiveLock);
+   rel = table_open(CollationRelationId, RowExclusiveLock);
    collOid = get_collation_oid(stmt->collname, false);
 
    if (!pg_collation_ownercheck(collOid, GetUserId()))
    ObjectAddressSet(address, CollationRelationId, collOid);
 
    heap_freetuple(tup);
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return address;
 }
 
                BTEqualStrategyNumber, F_INT4EQ,
                Int32GetDatum(subid));
 
-   description = heap_open(DescriptionRelationId, RowExclusiveLock);
+   description = table_open(DescriptionRelationId, RowExclusiveLock);
 
    sd = systable_beginscan(description, DescriptionObjIndexId, true,
                            NULL, 3, skey);
 
    /* Done */
 
-   heap_close(description, NoLock);
+   table_close(description, NoLock);
 }
 
 /*
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(classoid));
 
-   shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock);
+   shdescription = table_open(SharedDescriptionRelationId, RowExclusiveLock);
 
    sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true,
                            NULL, 2, skey);
 
    /* Done */
 
-   heap_close(shdescription, NoLock);
+   table_close(shdescription, NoLock);
 }
 
 /*
    else
        nkeys = 2;
 
-   description = heap_open(DescriptionRelationId, RowExclusiveLock);
+   description = table_open(DescriptionRelationId, RowExclusiveLock);
 
    sd = systable_beginscan(description, DescriptionObjIndexId, true,
                            NULL, nkeys, skey);
    /* Done */
 
    systable_endscan(sd);
-   heap_close(description, RowExclusiveLock);
+   table_close(description, RowExclusiveLock);
 }
 
 /*
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(classoid));
 
-   shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock);
+   shdescription = table_open(SharedDescriptionRelationId, RowExclusiveLock);
 
    sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true,
                            NULL, 2, skey);
    /* Done */
 
    systable_endscan(sd);
-   heap_close(shdescription, RowExclusiveLock);
+   table_close(shdescription, RowExclusiveLock);
 }
 
 /*
                BTEqualStrategyNumber, F_INT4EQ,
                Int32GetDatum(subid));
 
-   description = heap_open(DescriptionRelationId, AccessShareLock);
+   description = table_open(DescriptionRelationId, AccessShareLock);
    tupdesc = RelationGetDescr(description);
 
    sd = systable_beginscan(description, DescriptionObjIndexId, true,
    systable_endscan(sd);
 
    /* Done */
-   heap_close(description, AccessShareLock);
+   table_close(description, AccessShareLock);
 
    return comment;
 }
 
        Assert(!stmt->query);
 
        /* Open and lock the relation, using the appropriate lock type. */
-       rel = heap_openrv(stmt->relation, lockmode);
+       rel = table_openrv(stmt->relation, lockmode);
 
        relid = RelationGetRelid(rel);
 
             *
             * We'll reopen it later as part of the query-based COPY.
             */
-           heap_close(rel, NoLock);
+           table_close(rel, NoLock);
            rel = NULL;
        }
    }
     * ensure that updates will be committed before lock is released.
     */
    if (rel != NULL)
-       heap_close(rel, (is_from ? NoLock : AccessShareLock));
+       table_close(rel, (is_from ? NoLock : AccessShareLock));
 }
 
 /*
 
    /*
     * Finally we can open the target table
     */
-   intoRelationDesc = heap_open(intoRelationAddr.objectId, AccessExclusiveLock);
+   intoRelationDesc = table_open(intoRelationAddr.objectId, AccessExclusiveLock);
 
    /*
     * Check INSERT permission on the constructed table.
        heap_sync(myState->rel);
 
    /* close rel, but keep lock until commit */
-   heap_close(myState->rel, NoLock);
+   table_close(myState->rel, NoLock);
    myState->rel = NULL;
 }
 
 
     * filename conflict with anything already existing in the tablespace
     * directories.
     */
-   pg_database_rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+   pg_database_rel = table_open(DatabaseRelationId, RowExclusiveLock);
 
    do
    {
         * Iterate through all tablespaces of the template database, and copy
         * each one to the new database.
         */
-       rel = heap_open(TableSpaceRelationId, AccessShareLock);
+       rel = table_open(TableSpaceRelationId, AccessShareLock);
        scan = heap_beginscan_catalog(rel, 0, NULL);
        while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
        {
            }
        }
        heap_endscan(scan);
-       heap_close(rel, AccessShareLock);
+       table_close(rel, AccessShareLock);
 
        /*
         * We force a checkpoint before committing.  This effectively means
        /*
         * Close pg_database, but keep lock till commit.
         */
-       heap_close(pg_database_rel, NoLock);
+       table_close(pg_database_rel, NoLock);
 
        /*
         * Force synchronous commit, thus minimizing the window between
     * using it as a CREATE DATABASE template or trying to delete it for
     * themselves.
     */
-   pgdbrel = heap_open(DatabaseRelationId, RowExclusiveLock);
+   pgdbrel = table_open(DatabaseRelationId, RowExclusiveLock);
 
    if (!get_db_info(dbname, AccessExclusiveLock, &db_id, NULL, NULL,
                     &db_istemplate, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
        else
        {
            /* Close pg_database, release the lock, since we changed nothing */
-           heap_close(pgdbrel, RowExclusiveLock);
+           table_close(pgdbrel, RowExclusiveLock);
            ereport(NOTICE,
                    (errmsg("database \"%s\" does not exist, skipping",
                            dbname)));
    /*
     * Close pg_database, but keep lock till commit.
     */
-   heap_close(pgdbrel, NoLock);
+   table_close(pgdbrel, NoLock);
 
    /*
     * Force synchronous commit, thus minimizing the window between removal of
     * Look up the target database's OID, and get exclusive lock on it. We
     * need this for the same reasons as DROP DATABASE.
     */
-   rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+   rel = table_open(DatabaseRelationId, RowExclusiveLock);
 
    if (!get_db_info(oldname, AccessExclusiveLock, &db_id, NULL, NULL,
                     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
    /*
     * Close pg_database, but keep lock till commit.
     */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return address;
 }
     * we are moving it, and that no one is using it as a CREATE DATABASE
     * template or trying to delete it.
     */
-   pgdbrel = heap_open(DatabaseRelationId, RowExclusiveLock);
+   pgdbrel = table_open(DatabaseRelationId, RowExclusiveLock);
 
    if (!get_db_info(dbname, AccessExclusiveLock, &db_id, NULL, NULL,
                     NULL, NULL, NULL, NULL, NULL, &src_tblspcoid, NULL, NULL))
     */
    if (src_tblspcoid == dst_tblspcoid)
    {
-       heap_close(pgdbrel, NoLock);
+       table_close(pgdbrel, NoLock);
        UnlockSharedObjectForSession(DatabaseRelationId, db_id, 0,
                                     AccessExclusiveLock);
        return;
        /*
         * Close pg_database, but keep lock till commit.
         */
-       heap_close(pgdbrel, NoLock);
+       table_close(pgdbrel, NoLock);
    }
    PG_END_ENSURE_ERROR_CLEANUP(movedb_failure_callback,
                                PointerGetDatum(&fparms));
     * because we're not going to do anything that would mess up incoming
     * connections.
     */
-   rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+   rel = table_open(DatabaseRelationId, RowExclusiveLock);
    ScanKeyInit(&scankey,
                Anum_pg_database_datname,
                BTEqualStrategyNumber, F_NAMEEQ,
    systable_endscan(scan);
 
    /* Close pg_database, but keep lock till commit */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return dboid;
 }
     * because we're not going to do anything that would mess up incoming
     * connections.
     */
-   rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+   rel = table_open(DatabaseRelationId, RowExclusiveLock);
    ScanKeyInit(&scankey,
                Anum_pg_database_datname,
                BTEqualStrategyNumber, F_NAMEEQ,
    systable_endscan(scan);
 
    /* Close pg_database, but keep lock till commit */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return address;
 }
    AssertArg(name);
 
    /* Caller may wish to grab a better lock on pg_database beforehand... */
-   relation = heap_open(DatabaseRelationId, AccessShareLock);
+   relation = table_open(DatabaseRelationId, AccessShareLock);
 
    /*
     * Loop covers the rare case where the database is renamed before we can
            UnlockSharedObject(DatabaseRelationId, dbOid, 0, lockmode);
    }
 
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    return result;
 }
    HeapScanDesc scan;
    HeapTuple   tuple;
 
-   rel = heap_open(TableSpaceRelationId, AccessShareLock);
+   rel = table_open(TableSpaceRelationId, AccessShareLock);
    scan = heap_beginscan_catalog(rel, 0, NULL);
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
    }
 
    heap_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 }
 
 /*
    HeapScanDesc scan;
    HeapTuple   tuple;
 
-   rel = heap_open(TableSpaceRelationId, AccessShareLock);
+   rel = table_open(TableSpaceRelationId, AccessShareLock);
    scan = heap_beginscan_catalog(rel, 0, NULL);
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
    }
 
    heap_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return result;
 }
     * There's no syscache for pg_database indexed by name, so we must look
     * the hard way.
     */
-   pg_database = heap_open(DatabaseRelationId, AccessShareLock);
+   pg_database = table_open(DatabaseRelationId, AccessShareLock);
    ScanKeyInit(&entry[0],
                Anum_pg_database_datname,
                BTEqualStrategyNumber, F_NAMEEQ,
        oid = InvalidOid;
 
    systable_endscan(scan);
-   heap_close(pg_database, AccessShareLock);
+   table_close(pg_database, AccessShareLock);
 
    if (!OidIsValid(oid) && !missing_ok)
        ereport(ERROR,
 
 
        /* Release any relcache reference count, but keep lock until commit. */
        if (relation)
-           heap_close(relation, NoLock);
+           table_close(relation, NoLock);
 
        add_exact_object_address(&address, objects);
    }
 
                referenced;
 
    /* Open pg_event_trigger. */
-   tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(EventTriggerRelationId, RowExclusiveLock);
 
    /* Build the new pg_trigger tuple. */
    trigoid = GetNewOidWithIndex(tgrel, EventTriggerOidIndexId,
    InvokeObjectPostCreateHook(EventTriggerRelationId, trigoid, 0);
 
    /* Close pg_event_trigger. */
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 
    return trigoid;
 }
    Relation    tgrel;
    HeapTuple   tup;
 
-   tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(EventTriggerRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(EVENTTRIGGEROID, ObjectIdGetDatum(trigOid));
    if (!HeapTupleIsValid(tup))
 
    ReleaseSysCache(tup);
 
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 }
 
 /*
    Form_pg_event_trigger evtForm;
    char        tgenabled = stmt->tgenabled;
 
-   tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(EventTriggerRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(EVENTTRIGGERNAME,
                              CStringGetDatum(stmt->trigname));
 
    /* clean up */
    heap_freetuple(tup);
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 
    return trigoid;
 }
    Relation    rel;
    ObjectAddress address;
 
-   rel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+   rel = table_open(EventTriggerRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(EVENTTRIGGERNAME, CStringGetDatum(name));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tup;
    Relation    rel;
 
-   rel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+   rel = table_open(EventTriggerRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(EVENTTRIGGEROID, ObjectIdGetDatum(trigOid));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
        Relation    catalog;
        HeapTuple   tuple;
 
-       catalog = heap_open(obj->address.classId, AccessShareLock);
+       catalog = table_open(obj->address.classId, AccessShareLock);
        tuple = get_catalog_object_by_oid(catalog,
                                          get_object_attnum_oid(object->classId),
                                          obj->address.objectId);
                    else if (isAnyTempNamespace(namespaceId))
                    {
                        pfree(obj);
-                       heap_close(catalog, AccessShareLock);
+                       table_close(catalog, AccessShareLock);
                        MemoryContextSwitchTo(oldcxt);
                        return;
                    }
            }
        }
 
-       heap_close(catalog, AccessShareLock);
+       table_close(catalog, AccessShareLock);
    }
    else
    {
                            Oid         schema_oid;
                            bool        isnull;
 
-                           catalog = heap_open(addr.classId, AccessShareLock);
+                           catalog = table_open(addr.classId, AccessShareLock);
                            objtup = get_catalog_object_by_oid(catalog,
                                                               get_object_attnum_oid(addr.classId),
                                                               addr.objectId);
                            else
                                schema = get_namespace_name(schema_oid);
 
-                           heap_close(catalog, AccessShareLock);
+                           table_close(catalog, AccessShareLock);
                        }
                    }
 
 
    HeapTuple   tuple;
    ScanKeyData entry[1];
 
-   rel = heap_open(ExtensionRelationId, AccessShareLock);
+   rel = table_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_extension_extname,
 
    systable_endscan(scandesc);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    if (!OidIsValid(result) && !missing_ok)
        ereport(ERROR,
    HeapTuple   tuple;
    ScanKeyData entry[1];
 
-   rel = heap_open(ExtensionRelationId, AccessShareLock);
+   rel = table_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_extension_oid,
 
    systable_endscan(scandesc);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return result;
 }
    HeapTuple   tuple;
    ScanKeyData entry[1];
 
-   rel = heap_open(ExtensionRelationId, AccessShareLock);
+   rel = table_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_extension_oid,
 
    systable_endscan(scandesc);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return result;
 }
    /*
     * Build and insert the pg_extension tuple
     */
-   rel = heap_open(ExtensionRelationId, RowExclusiveLock);
+   rel = table_open(ExtensionRelationId, RowExclusiveLock);
 
    memset(values, 0, sizeof(values));
    memset(nulls, 0, sizeof(nulls));
    CatalogTupleInsert(rel, tuple);
 
    heap_freetuple(tuple);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    /*
     * Record dependencies on owner, schema, and prerequisite extensions
                 errmsg("cannot drop extension \"%s\" because it is being modified",
                        get_extension_name(extId))));
 
-   rel = heap_open(ExtensionRelationId, RowExclusiveLock);
+   rel = table_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_extension_oid,
 
    systable_endscan(scandesc);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
     */
 
    /* Find the pg_extension tuple */
-   extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+   extRel = table_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_extension_oid,
 
    systable_endscan(extScan);
 
-   heap_close(extRel, RowExclusiveLock);
+   table_close(extRel, RowExclusiveLock);
 
    PG_RETURN_VOID();
 }
    ArrayType  *a;
 
    /* Find the pg_extension tuple */
-   extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+   extRel = table_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_extension_oid,
    if (arrayIndex < 0)
    {
        systable_endscan(extScan);
-       heap_close(extRel, RowExclusiveLock);
+       table_close(extRel, RowExclusiveLock);
        return;
    }
 
 
    systable_endscan(extScan);
 
-   heap_close(extRel, RowExclusiveLock);
+   table_close(extRel, RowExclusiveLock);
 }
 
 /*
                        extensionName, newschema)));
 
    /* Locate the pg_extension tuple */
-   extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+   extRel = table_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_extension_oid,
     */
    if (extForm->extnamespace == nspOid)
    {
-       heap_close(extRel, RowExclusiveLock);
+       table_close(extRel, RowExclusiveLock);
        return InvalidObjectAddress;
    }
 
     * Scan pg_depend to find objects that depend directly on the extension,
     * and alter each one's schema.
     */
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_refclassid,
 
    CatalogTupleUpdate(extRel, &extTup->t_self, extTup);
 
-   heap_close(extRel, RowExclusiveLock);
+   table_close(extRel, RowExclusiveLock);
 
    /* update dependencies to point to the new schema */
    changeDependencyFor(ExtensionRelationId, extensionOid,
    /*
     * Look up the extension --- it must already exist in pg_extension
     */
-   extRel = heap_open(ExtensionRelationId, AccessShareLock);
+   extRel = table_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_extension_extname,
 
    systable_endscan(extScan);
 
-   heap_close(extRel, AccessShareLock);
+   table_close(extRel, AccessShareLock);
 
    /* Permission check: must own extension */
    if (!pg_extension_ownercheck(extensionOid, GetUserId()))
        control = read_extension_aux_control_file(pcontrol, versionName);
 
        /* Find the pg_extension tuple */
-       extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+       extRel = table_open(ExtensionRelationId, RowExclusiveLock);
 
        ScanKeyInit(&key[0],
                    Anum_pg_extension_oid,
 
        systable_endscan(extScan);
 
-       heap_close(extRel, RowExclusiveLock);
+       table_close(extRel, RowExclusiveLock);
 
        /*
         * Look up the prerequisite extensions for this version, install them
 
    Form_pg_foreign_data_wrapper form;
 
 
-   rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+   rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(FOREIGNDATAWRAPPERNAME, CStringGetDatum(name));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tup;
    Relation    rel;
 
-   rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+   rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fwdId));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    ObjectAddress address;
    Form_pg_foreign_server form;
 
-   rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+   rel = table_open(ForeignServerRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(FOREIGNSERVERNAME, CStringGetDatum(name));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tup;
    Relation    rel;
 
-   rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+   rel = table_open(ForeignServerRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(FOREIGNSERVEROID, ObjectIdGetDatum(srvId));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    ObjectAddress myself;
    ObjectAddress referenced;
 
-   rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+   rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
    /* Must be super user */
    if (!superuser())
    /* Post creation hook for new foreign data wrapper */
    InvokeObjectPostCreateHook(ForeignDataWrapperRelationId, fdwId, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
    Oid         fdwvalidator;
    ObjectAddress myself;
 
-   rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+   rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
    /* Must be super user */
    if (!superuser())
 
    InvokeObjectPostAlterHook(ForeignDataWrapperRelationId, fdwId, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
    HeapTuple   tp;
    Relation    rel;
 
-   rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+   rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
    tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwId));
 
 
    ReleaseSysCache(tp);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
    ObjectAddress referenced;
    ForeignDataWrapper *fdw;
 
-   rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+   rel = table_open(ForeignServerRelationId, RowExclusiveLock);
 
    /* For now the owner cannot be specified on create. Use effective user ID. */
    ownerId = GetUserId();
                    (errcode(ERRCODE_DUPLICATE_OBJECT),
                     errmsg("server \"%s\" already exists, skipping",
                            stmt->servername)));
-           heap_close(rel, RowExclusiveLock);
+           table_close(rel, RowExclusiveLock);
            return InvalidObjectAddress;
        }
        else
    /* Post creation hook for new foreign server */
    InvokeObjectPostCreateHook(ForeignServerRelationId, srvId, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
    Form_pg_foreign_server srvForm;
    ObjectAddress address;
 
-   rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+   rel = table_open(ForeignServerRelationId, RowExclusiveLock);
 
    tp = SearchSysCacheCopy1(FOREIGNSERVERNAME,
                             CStringGetDatum(stmt->servername));
 
    heap_freetuple(tp);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tp;
    Relation    rel;
 
-   rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+   rel = table_open(ForeignServerRelationId, RowExclusiveLock);
 
    tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srvId));
 
 
    ReleaseSysCache(tp);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
    ForeignDataWrapper *fdw;
    RoleSpec   *role = (RoleSpec *) stmt->user;
 
-   rel = heap_open(UserMappingRelationId, RowExclusiveLock);
+   rel = table_open(UserMappingRelationId, RowExclusiveLock);
 
    if (role->roletype == ROLESPEC_PUBLIC)
        useId = ACL_ID_PUBLIC;
                            MappingUserName(useId),
                            stmt->servername)));
 
-           heap_close(rel, RowExclusiveLock);
+           table_close(rel, RowExclusiveLock);
            return InvalidObjectAddress;
        }
        else
    /* Post creation hook for new user mapping */
    InvokeObjectPostCreateHook(UserMappingRelationId, umId, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
    ObjectAddress address;
    RoleSpec   *role = (RoleSpec *) stmt->user;
 
-   rel = heap_open(UserMappingRelationId, RowExclusiveLock);
+   rel = table_open(UserMappingRelationId, RowExclusiveLock);
 
    if (role->roletype == ROLESPEC_PUBLIC)
        useId = ACL_ID_PUBLIC;
 
    heap_freetuple(tp);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tp;
    Relation    rel;
 
-   rel = heap_open(UserMappingRelationId, RowExclusiveLock);
+   rel = table_open(UserMappingRelationId, RowExclusiveLock);
 
    tp = SearchSysCache1(USERMAPPINGOID, ObjectIdGetDatum(umId));
 
 
    ReleaseSysCache(tp);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
     */
    CommandCounterIncrement();
 
-   ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+   ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
 
    /*
     * For now the owner cannot be specified on create. Use effective user ID.
    referenced.objectSubId = 0;
    recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
 
-   heap_close(ftrel, RowExclusiveLock);
+   table_close(ftrel, RowExclusiveLock);
 }
 
 /*
 
    /*
     * Delete the pg_proc tuple.
     */
-   relation = heap_open(ProcedureRelationId, RowExclusiveLock);
+   relation = table_open(ProcedureRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
    if (!HeapTupleIsValid(tup)) /* should not happen */
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 
    /*
     * If there's a pg_aggregate tuple, delete that too.
     */
    if (prokind == PROKIND_AGGREGATE)
    {
-       relation = heap_open(AggregateRelationId, RowExclusiveLock);
+       relation = table_open(AggregateRelationId, RowExclusiveLock);
 
        tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcOid));
        if (!HeapTupleIsValid(tup)) /* should not happen */
 
        ReleaseSysCache(tup);
 
-       heap_close(relation, RowExclusiveLock);
+       table_close(relation, RowExclusiveLock);
    }
 }
 
    DefElem    *parallel_item = NULL;
    ObjectAddress address;
 
-   rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+   rel = table_open(ProcedureRelationId, RowExclusiveLock);
 
    funcOid = LookupFuncWithArgs(stmt->objtype, stmt->func, false);
 
 
    ObjectAddressSet(address, ProcedureRelationId, funcOid);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
    heap_freetuple(tup);
 
    return address;
    ObjectAddress func_address;
    ObjectAddress type_address;
 
-   pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+   pg_proc_rel = table_open(ProcedureRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
    if (!HeapTupleIsValid(tup)) /* should not happen */
    /* update the catalog and its indexes */
    CatalogTupleUpdate(pg_proc_rel, &tup->t_self, tup);
 
-   heap_close(pg_proc_rel, RowExclusiveLock);
+   table_close(pg_proc_rel, RowExclusiveLock);
 
    /*
     * Also update the dependency to the new type. Opaque is a pinned type, so
    ObjectAddress func_address;
    ObjectAddress type_address;
 
-   pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+   pg_proc_rel = table_open(ProcedureRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
    if (!HeapTupleIsValid(tup)) /* should not happen */
    /* update the catalog and its indexes */
    CatalogTupleUpdate(pg_proc_rel, &tup->t_self, tup);
 
-   heap_close(pg_proc_rel, RowExclusiveLock);
+   table_close(pg_proc_rel, RowExclusiveLock);
 
    /*
     * Also update the dependency to the new type. Opaque is a pinned type, so
            break;
    }
 
-   relation = heap_open(CastRelationId, RowExclusiveLock);
+   relation = table_open(CastRelationId, RowExclusiveLock);
 
    /*
     * Check for duplicate.  This is just to give a friendly error message,
 
    heap_freetuple(tuple);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 
    return myself;
 }
    SysScanDesc scan;
    HeapTuple   tuple;
 
-   relation = heap_open(CastRelationId, RowExclusiveLock);
+   relation = table_open(CastRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scankey,
                Anum_pg_cast_oid,
    CatalogTupleDelete(relation, &tuple->t_self);
 
    systable_endscan(scan);
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 
 
    MemSet(nulls, false, sizeof(nulls));
 
-   relation = heap_open(TransformRelationId, RowExclusiveLock);
+   relation = table_open(TransformRelationId, RowExclusiveLock);
 
    tuple = SearchSysCache2(TRFTYPELANG,
                            ObjectIdGetDatum(typeid),
 
    heap_freetuple(newtuple);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 
    return myself;
 }
    SysScanDesc scan;
    HeapTuple   tuple;
 
-   relation = heap_open(TransformRelationId, RowExclusiveLock);
+   relation = table_open(TransformRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scankey,
                Anum_pg_transform_oid,
    CatalogTupleDelete(relation, &tuple->t_self);
 
    systable_endscan(scan);
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 
 
     * functions will need to be updated, too.
     */
    lockmode = stmt->concurrent ? ShareUpdateExclusiveLock : ShareLock;
-   rel = heap_open(relationId, lockmode);
+   rel = table_open(relationId, lockmode);
 
    namespaceId = RelationGetNamespace(rel);
 
 
    if (!OidIsValid(indexRelationId))
    {
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
        return address;
    }
 
            for (i = 0; i < numberOfKeyAttributes; i++)
                opfamOids[i] = get_opclass_family(classObjectId[i]);
 
-           heap_close(rel, NoLock);
+           table_close(rel, NoLock);
 
            /*
             * For each partition, scan all existing indexes; if one matches
                bool        found = false;
                int         maplen;
 
-               childrel = heap_open(childRelid, lockmode);
+               childrel = table_open(childRelid, lockmode);
                childidxs = RelationGetIndexList(childrel);
                attmap =
                    convert_tuples_by_name_map(RelationGetDescr(childrel),
                }
 
                list_free(childidxs);
-               heap_close(childrel, NoLock);
+               table_close(childrel, NoLock);
 
                /*
                 * If no matching index was found, create our own.
             */
            if (invalidate_parent)
            {
-               Relation    pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+               Relation    pg_index = table_open(IndexRelationId, RowExclusiveLock);
                HeapTuple   tup,
                            newtup;
 
                ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = false;
                CatalogTupleUpdate(pg_index, &tup->t_self, newtup);
                ReleaseSysCache(tup);
-               heap_close(pg_index, RowExclusiveLock);
+               table_close(pg_index, RowExclusiveLock);
                heap_freetuple(newtup);
            }
        }
        else
-           heap_close(rel, NoLock);
+           table_close(rel, NoLock);
 
        /*
         * Indexes on partitioned tables are not themselves built, so we're
    if (!stmt->concurrent)
    {
        /* Close the heap and we're done, in the non-concurrent case */
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
        return address;
    }
 
    /* save lockrelid and locktag for below, then close rel */
    heaprelid = rel->rd_lockInfo.lockRelId;
    SET_LOCKTAG_RELATION(heaplocktag, heaprelid.dbId, heaprelid.relId);
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /*
     * For a concurrent build, it's important to make the catalog entries
     */
 
    /* Open and lock the parent heap relation */
-   rel = heap_open(relationId, ShareUpdateExclusiveLock);
+   rel = table_open(relationId, ShareUpdateExclusiveLock);
 
    /* And the target index relation */
    indexRelation = index_open(indexRelationId, RowExclusiveLock);
    index_build(rel, indexRelation, indexInfo, stmt->primary, false, true);
 
    /* Close both the relations, but keep the locks */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
    index_close(indexRelation, NoLock);
 
    /*
     * we need a tiebreaker.)  If we find more than one exact match, then
     * someone put bogus entries in pg_opclass.
     */
-   rel = heap_open(OperatorClassRelationId, AccessShareLock);
+   rel = table_open(OperatorClassRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_opclass_opcmethod,
 
    systable_endscan(scan);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    /* raise error if pg_opclass contains inconsistent data */
    if (nexact > 1)
     * We only consider plain relations and materialized views here (toast
     * rels will be processed indirectly by reindex_relation).
     */
-   relationRelation = heap_open(RelationRelationId, AccessShareLock);
+   relationRelation = table_open(RelationRelationId, AccessShareLock);
    scan = heap_beginscan_catalog(relationRelation, num_keys, scan_keys);
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
        MemoryContextSwitchTo(old);
    }
    heap_endscan(scan);
-   heap_close(relationRelation, AccessShareLock);
+   table_close(relationRelation, AccessShareLock);
 
    /* Now reindex each rel in a separate transaction */
    PopActiveSnapshot();
 
    Relation    view;
    Query      *viewquery;
 
-   view = heap_open(reloid, NoLock);
+   view = table_open(reloid, NoLock);
    viewquery = get_view_query(view);
 
    context.lockmode = lockmode;
 
    ancestor_views = list_delete_oid(ancestor_views, reloid);
 
-   heap_close(view, NoLock);
+   table_close(view, NoLock);
 }
 
 /*
 
     * (and this one too!) are sent SI message to make them rebuild relcache
     * entries.
     */
-   pgrel = heap_open(RelationRelationId, RowExclusiveLock);
+   pgrel = table_open(RelationRelationId, RowExclusiveLock);
    tuple = SearchSysCacheCopy1(RELOID,
                                ObjectIdGetDatum(RelationGetRelid(relation)));
    if (!HeapTupleIsValid(tuple))
    CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
 
    heap_freetuple(tuple);
-   heap_close(pgrel, RowExclusiveLock);
+   table_close(pgrel, RowExclusiveLock);
 
    /*
     * Advance command counter to make the updated pg_class row locally
    matviewOid = RangeVarGetRelidExtended(stmt->relation,
                                          lockmode, 0,
                                          RangeVarCallbackOwnsTable, NULL);
-   matviewRel = heap_open(matviewOid, NoLock);
+   matviewRel = table_open(matviewOid, NoLock);
 
    /* Make sure it is a materialized view. */
    if (matviewRel->rd_rel->relkind != RELKIND_MATVIEW)
            pgstat_count_heap_insert(matviewRel, processed);
    }
 
-   heap_close(matviewRel, NoLock);
+   table_close(matviewRel, NoLock);
 
    /* Roll back any GUC changes */
    AtEOXact_GUC(false, save_nestlevel);
    DR_transientrel *myState = (DR_transientrel *) self;
    Relation    transientrel;
 
-   transientrel = heap_open(myState->transientoid, NoLock);
+   transientrel = table_open(myState->transientoid, NoLock);
 
    /*
     * Fill private fields of myState for use by later routines
        heap_sync(myState->transientrel);
 
    /* close transientrel, but keep lock until commit */
-   heap_close(myState->transientrel, NoLock);
+   table_close(myState->transientrel, NoLock);
    myState->transientrel = NULL;
 }
 
    Oid        *opUsedForQual;
 
    initStringInfo(&querybuf);
-   matviewRel = heap_open(matviewOid, NoLock);
+   matviewRel = table_open(matviewOid, NoLock);
    matviewname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(matviewRel)),
                                             RelationGetRelationName(matviewRel));
-   tempRel = heap_open(tempOid, NoLock);
+   tempRel = table_open(tempOid, NoLock);
    tempname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(tempRel)),
                                          RelationGetRelationName(tempRel));
    diffname = make_temptable_name_n(tempname, 2);
 
    /* We're done maintaining the materialized view. */
    CloseMatViewIncrementalMaintenance();
-   heap_close(tempRel, NoLock);
-   heap_close(matviewRel, NoLock);
+   table_close(tempRel, NoLock);
+   table_close(matviewRel, NoLock);
 
    /* Clean up temp tables. */
    resetStringInfo(&querybuf);
 
    ObjectAddress myself,
                referenced;
 
-   rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
+   rel = table_open(OperatorFamilyRelationId, RowExclusiveLock);
 
    /*
     * Make sure there is no existing opfamily of this name (this is just to
    /* Post creation hook for new operator family */
    InvokeObjectPostCreateHook(OperatorFamilyRelationId, opfamilyoid, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
                            stmt->amname)));
    }
 
-   rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
+   rel = table_open(OperatorClassRelationId, RowExclusiveLock);
 
    /*
     * Make sure there is no existing opclass of this name (this is just to
    /* Post creation hook for new operator class */
    InvokeObjectPostCreateHook(OperatorClassRelationId, opclassoid, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
                referenced;
    ListCell   *l;
 
-   rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock);
+   rel = table_open(AccessMethodOperatorRelationId, RowExclusiveLock);
 
    foreach(l, operators)
    {
                                   entryoid, 0);
    }
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
                referenced;
    ListCell   *l;
 
-   rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock);
+   rel = table_open(AccessMethodProcedureRelationId, RowExclusiveLock);
 
    foreach(l, procedures)
    {
                                   entryoid, 0);
    }
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
    Relation    rel;
    HeapTuple   tup;
 
-   rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
+   rel = table_open(OperatorFamilyRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid));
    if (!HeapTupleIsValid(tup)) /* should not happen */
 
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 void
    Relation    rel;
    HeapTuple   tup;
 
-   rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
+   rel = table_open(OperatorClassRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassOid));
    if (!HeapTupleIsValid(tup)) /* should not happen */
 
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 void
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(entryOid));
 
-   rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock);
+   rel = table_open(AccessMethodOperatorRelationId, RowExclusiveLock);
 
    scan = systable_beginscan(rel, AccessMethodOperatorOidIndexId, true,
                              NULL, 1, skey);
    CatalogTupleDelete(rel, &tup->t_self);
 
    systable_endscan(scan);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 void
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(entryOid));
 
-   rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock);
+   rel = table_open(AccessMethodProcedureRelationId, RowExclusiveLock);
 
    scan = systable_beginscan(rel, AccessMethodProcedureOidIndexId, true,
                              NULL, 1, skey);
    CatalogTupleDelete(rel, &tup->t_self);
 
    systable_endscan(scan);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
 
    HeapTuple   tup;
    Form_pg_operator op;
 
-   relation = heap_open(OperatorRelationId, RowExclusiveLock);
+   relation = table_open(OperatorRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
    if (!HeapTupleIsValid(tup)) /* should not happen */
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /*
 
    /* Look up the operator */
    oprId = LookupOperWithArgs(stmt->opername, false);
-   catalog = heap_open(OperatorRelationId, RowExclusiveLock);
+   catalog = table_open(OperatorRelationId, RowExclusiveLock);
    tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
    if (tup == NULL)
        elog(ERROR, "cache lookup failed for operator %u", oprId);
 
    InvokeObjectPostAlterHook(OperatorRelationId, oprId, 0);
 
-   heap_close(catalog, NoLock);
+   table_close(catalog, NoLock);
 
    return address;
 }
 
        rsdesc = MemoryContextAllocZero(rscxt, sizeof(RowSecurityDesc));
        rsdesc->rscxt = rscxt;
 
-       catalog = heap_open(PolicyRelationId, AccessShareLock);
+       catalog = table_open(PolicyRelationId, AccessShareLock);
 
        ScanKeyInit(&skey,
                    Anum_pg_policy_polrelid,
        }
 
        systable_endscan(sscan);
-       heap_close(catalog, AccessShareLock);
+       table_close(catalog, AccessShareLock);
    }
    PG_CATCH();
    {
    Oid         relid;
    Relation    rel;
 
-   pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+   pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
 
    /*
     * Find the policy to delete.
     */
    relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
 
-   rel = heap_open(relid, AccessExclusiveLock);
+   rel = table_open(relid, AccessExclusiveLock);
    if (rel->rd_rel->relkind != RELKIND_RELATION &&
        rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
        ereport(ERROR,
     */
    CacheInvalidateRelcache(rel);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /* Clean up */
-   heap_close(pg_policy_rel, RowExclusiveLock);
+   table_close(pg_policy_rel, RowExclusiveLock);
 }
 
 /*
 
    Assert(classid == PolicyRelationId);
 
-   pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+   pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
 
    /*
     * Find the policy to update.
 
    relation_close(rel, NoLock);
 
-   heap_close(pg_policy_rel, RowExclusiveLock);
+   table_close(pg_policy_rel, RowExclusiveLock);
 
    return (noperm || num_roles > 0);
 }
    assign_expr_collations(with_check_pstate, with_check_qual);
 
    /* Open pg_policy catalog */
-   pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+   pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
 
    /* Set key - policy's relation id. */
    ScanKeyInit(&skey[0],
    free_parsestate(with_check_pstate);
    systable_endscan(sscan);
    relation_close(target_table, NoLock);
-   heap_close(pg_policy_rel, RowExclusiveLock);
+   table_close(pg_policy_rel, RowExclusiveLock);
 
    return myself;
 }
    memset(isnull, 0, sizeof(isnull));
 
    /* Find policy to update. */
-   pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+   pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
 
    /* Set key - policy's relation id. */
    ScanKeyInit(&skey[0],
    /* Clean up. */
    systable_endscan(sscan);
    relation_close(target_table, NoLock);
-   heap_close(pg_policy_rel, RowExclusiveLock);
+   table_close(pg_policy_rel, RowExclusiveLock);
 
    return myself;
 }
 
    target_table = relation_open(table_id, NoLock);
 
-   pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+   pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
 
    /* First pass -- check for conflict */
 
 
    /* Clean up. */
    systable_endscan(sscan);
-   heap_close(pg_policy_rel, RowExclusiveLock);
+   table_close(pg_policy_rel, RowExclusiveLock);
    relation_close(target_table, NoLock);
 
    return address;
    HeapTuple   policy_tuple;
    Oid         policy_oid;
 
-   pg_policy_rel = heap_open(PolicyRelationId, AccessShareLock);
+   pg_policy_rel = table_open(PolicyRelationId, AccessShareLock);
 
    /* Add key - policy's relation id. */
    ScanKeyInit(&skey[0],
 
    /* Clean up. */
    systable_endscan(sscan);
-   heap_close(pg_policy_rel, AccessShareLock);
+   table_close(pg_policy_rel, AccessShareLock);
 
    return policy_oid;
 }
    HeapTuple   policy_tuple;
    bool        ret = false;
 
-   catalog = heap_open(PolicyRelationId, AccessShareLock);
+   catalog = table_open(PolicyRelationId, AccessShareLock);
    ScanKeyInit(&skey,
                Anum_pg_policy_polrelid,
                BTEqualStrategyNumber, F_OIDEQ,
        ret = true;
 
    systable_endscan(sscan);
-   heap_close(catalog, AccessShareLock);
+   table_close(catalog, AccessShareLock);
 
    return ret;
 }
 
    ObjectAddress myself,
                referenced;
 
-   rel = heap_open(LanguageRelationId, RowExclusiveLock);
+   rel = table_open(LanguageRelationId, RowExclusiveLock);
    tupDesc = RelationGetDescr(rel);
 
    /* Prepare data to be inserted */
    /* Post creation hook for new procedural language */
    InvokeObjectPostCreateHook(LanguageRelationId, myself.objectId, 0);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return myself;
 }
    ScanKeyData key;
    HeapTuple   tup;
 
-   rel = heap_open(PLTemplateRelationId, AccessShareLock);
+   rel = table_open(PLTemplateRelationId, AccessShareLock);
 
    ScanKeyInit(&key,
                Anum_pg_pltemplate_tmplname,
 
    systable_endscan(scan);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return result;
 }
    Relation    rel;
    HeapTuple   langTup;
 
-   rel = heap_open(LanguageRelationId, RowExclusiveLock);
+   rel = table_open(LanguageRelationId, RowExclusiveLock);
 
    langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(langOid));
    if (!HeapTupleIsValid(langTup)) /* should not happen */
 
    ReleaseSysCache(langTup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
 
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 (errmsg("must be superuser to create FOR ALL TABLES publication"))));
 
-   rel = heap_open(PublicationRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelationId, RowExclusiveLock);
 
    /* Check if name is used */
    puboid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
        CloseTableList(rels);
    }
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    InvokeObjectPostCreateHook(PublicationRelationId, puboid, 0);
 
 
            if (!found)
            {
-               Relation    oldrel = heap_open(oldrelid,
-                                              ShareUpdateExclusiveLock);
+               Relation    oldrel = table_open(oldrelid,
+                                               ShareUpdateExclusiveLock);
 
                delrels = lappend(delrels, oldrel);
            }
    HeapTuple   tup;
    Form_pg_publication pubform;
 
-   rel = heap_open(PublicationRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(PUBLICATIONNAME,
                              CStringGetDatum(stmt->pubname));
 
    /* Cleanup. */
    heap_freetuple(tup);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    Relation    rel;
    HeapTuple   tup;
 
-   rel = heap_open(PublicationRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    HeapTuple   tup;
    Form_pg_publication_rel pubrel;
 
-   rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(PUBLICATIONREL, ObjectIdGetDatum(proid));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
        /* Allow query cancel in case this takes a long time */
        CHECK_FOR_INTERRUPTS();
 
-       rel = heap_openrv(rv, ShareUpdateExclusiveLock);
+       rel = table_openrv(rv, ShareUpdateExclusiveLock);
        myrelid = RelationGetRelid(rel);
 
        /*
         */
        if (list_member_oid(relids, myrelid))
        {
-           heap_close(rel, ShareUpdateExclusiveLock);
+           table_close(rel, ShareUpdateExclusiveLock);
            continue;
        }
 
                    continue;
 
                /* find_all_inheritors already got lock */
-               rel = heap_open(childrelid, NoLock);
+               rel = table_open(childrelid, NoLock);
                rels = lappend(rels, rel);
                relids = lappend_oid(relids, childrelid);
            }
    {
        Relation    rel = (Relation) lfirst(lc);
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 }
 
    ObjectAddress address;
    Form_pg_publication pubform;
 
-   rel = heap_open(PublicationRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(PUBLICATIONNAME, CStringGetDatum(name));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tup;
    Relation    rel;
 
-   rel = heap_open(PublicationRelationId, RowExclusiveLock);
+   rel = table_open(PublicationRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(PUBLICATIONOID, ObjectIdGetDatum(subid));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
    Relation    relation;
    HeapTuple   tup;
 
-   relation = heap_open(NamespaceRelationId, RowExclusiveLock);
+   relation = table_open(NamespaceRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(NAMESPACEOID,
                          ObjectIdGetDatum(schemaOid));
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 
    ObjectAddress address;
    Form_pg_namespace nspform;
 
-   rel = heap_open(NamespaceRelationId, RowExclusiveLock);
+   rel = table_open(NamespaceRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(NAMESPACENAME, CStringGetDatum(oldname));
    if (!HeapTupleIsValid(tup))
 
    ObjectAddressSet(address, NamespaceRelationId, nspOid);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
    heap_freetuple(tup);
 
    return address;
    HeapTuple   tup;
    Relation    rel;
 
-   rel = heap_open(NamespaceRelationId, RowExclusiveLock);
+   rel = table_open(NamespaceRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(oid));
    if (!HeapTupleIsValid(tup))
 
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 
    ObjectAddress address;
    Form_pg_namespace nspform;
 
-   rel = heap_open(NamespaceRelationId, RowExclusiveLock);
+   rel = table_open(NamespaceRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(NAMESPACENAME, CStringGetDatum(name));
    if (!HeapTupleIsValid(tup))
 
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
 
                BTEqualStrategyNumber, F_TEXTEQ,
                CStringGetTextDatum(provider));
 
-   pg_shseclabel = heap_open(SharedSecLabelRelationId, AccessShareLock);
+   pg_shseclabel = table_open(SharedSecLabelRelationId, AccessShareLock);
 
    scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
                              NULL, 3, keys);
    }
    systable_endscan(scan);
 
-   heap_close(pg_shseclabel, AccessShareLock);
+   table_close(pg_shseclabel, AccessShareLock);
 
    return seclabel;
 }
                BTEqualStrategyNumber, F_TEXTEQ,
                CStringGetTextDatum(provider));
 
-   pg_seclabel = heap_open(SecLabelRelationId, AccessShareLock);
+   pg_seclabel = table_open(SecLabelRelationId, AccessShareLock);
 
    scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
                              NULL, 4, keys);
    }
    systable_endscan(scan);
 
-   heap_close(pg_seclabel, AccessShareLock);
+   table_close(pg_seclabel, AccessShareLock);
 
    return seclabel;
 }
                BTEqualStrategyNumber, F_TEXTEQ,
                CStringGetTextDatum(provider));
 
-   pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock);
+   pg_shseclabel = table_open(SharedSecLabelRelationId, RowExclusiveLock);
 
    scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
                              NULL, 3, keys);
    if (newtup != NULL)
        heap_freetuple(newtup);
 
-   heap_close(pg_shseclabel, RowExclusiveLock);
+   table_close(pg_shseclabel, RowExclusiveLock);
 }
 
 /*
                BTEqualStrategyNumber, F_TEXTEQ,
                CStringGetTextDatum(provider));
 
-   pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock);
+   pg_seclabel = table_open(SecLabelRelationId, RowExclusiveLock);
 
    scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
                              NULL, 4, keys);
    if (newtup != NULL)
        heap_freetuple(newtup);
 
-   heap_close(pg_seclabel, RowExclusiveLock);
+   table_close(pg_seclabel, RowExclusiveLock);
 }
 
 /*
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(classId));
 
-   pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock);
+   pg_shseclabel = table_open(SharedSecLabelRelationId, RowExclusiveLock);
 
    scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
                              NULL, 2, skey);
        CatalogTupleDelete(pg_shseclabel, &oldtup->t_self);
    systable_endscan(scan);
 
-   heap_close(pg_shseclabel, RowExclusiveLock);
+   table_close(pg_shseclabel, RowExclusiveLock);
 }
 
 /*
    else
        nkeys = 2;
 
-   pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock);
+   pg_seclabel = table_open(SecLabelRelationId, RowExclusiveLock);
 
    scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
                              NULL, nkeys, skey);
        CatalogTupleDelete(pg_seclabel, &oldtup->t_self);
    systable_endscan(scan);
 
-   heap_close(pg_seclabel, RowExclusiveLock);
+   table_close(pg_seclabel, RowExclusiveLock);
 }
 
 void
 
    seqoid = address.objectId;
    Assert(seqoid != InvalidOid);
 
-   rel = heap_open(seqoid, AccessExclusiveLock);
+   rel = table_open(seqoid, AccessExclusiveLock);
    tupDesc = RelationGetDescr(rel);
 
    /* now initialize the sequence's data */
    if (owned_by)
        process_owned_by(rel, owned_by, seq->for_identity);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /* fill in pg_sequence */
-   rel = heap_open(SequenceRelationId, RowExclusiveLock);
+   rel = table_open(SequenceRelationId, RowExclusiveLock);
    tupDesc = RelationGetDescr(rel);
 
    memset(pgs_nulls, 0, sizeof(pgs_nulls));
    CatalogTupleInsert(rel, tuple);
 
    heap_freetuple(tuple);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
 
    init_sequence(relid, &elm, &seqrel);
 
-   rel = heap_open(SequenceRelationId, RowExclusiveLock);
+   rel = table_open(SequenceRelationId, RowExclusiveLock);
    seqtuple = SearchSysCacheCopy1(SEQRELID,
                                   ObjectIdGetDatum(relid));
    if (!HeapTupleIsValid(seqtuple))
 
    ObjectAddressSet(address, RelationRelationId, relid);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
    relation_close(seqrel, NoLock);
 
    return address;
    Relation    rel;
    HeapTuple   tuple;
 
-   rel = heap_open(SequenceRelationId, RowExclusiveLock);
+   rel = table_open(SequenceRelationId, RowExclusiveLock);
 
    tuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
    if (!HeapTupleIsValid(tuple))
    CatalogTupleDelete(rel, &tuple->t_self);
 
    ReleaseSysCache(tuple);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
 
    Assert(ntypes > 0 && ntypes <= lengthof(types));
    stxkind = construct_array(types, ntypes, CHAROID, 1, true, 'c');
 
-   statrel = heap_open(StatisticExtRelationId, RowExclusiveLock);
+   statrel = table_open(StatisticExtRelationId, RowExclusiveLock);
 
    /*
     * Everything seems fine, so let's build the pg_statistic_ext tuple.
     * Delete the pg_statistic_ext tuple.  Also send out a cache inval on the
     * associated table, so that dependent plans will be rebuilt.
     */
-   relation = heap_open(StatisticExtRelationId, RowExclusiveLock);
+   relation = table_open(StatisticExtRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statsOid));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /*
 
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 (errmsg("must be superuser to create subscriptions"))));
 
-   rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelationId, RowExclusiveLock);
 
    /* Check if name is used */
    subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
                        "ALTER SUBSCRIPTION ... REFRESH PUBLICATION to "
                        "subscribe the tables")));
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    if (enabled)
        ApplyLauncherWakeupAtCommit();
    Subscription *sub;
    Form_pg_subscription form;
 
-   rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelationId, RowExclusiveLock);
 
    /* Fetch the existing tuple. */
    tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, MyDatabaseId,
        heap_freetuple(tup);
    }
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    ObjectAddressSet(myself, SubscriptionRelationId, subid);
 
     * Lock pg_subscription with AccessExclusiveLock to ensure that the
     * launcher doesn't restart new worker during dropping the subscription
     */
-   rel = heap_open(SubscriptionRelationId, AccessExclusiveLock);
+   rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
 
    tup = SearchSysCache2(SUBSCRIPTIONNAME, MyDatabaseId,
                          CStringGetDatum(stmt->subname));
 
    if (!HeapTupleIsValid(tup))
    {
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
 
        if (!stmt->missing_ok)
            ereport(ERROR,
     */
    if (!slotname)
    {
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
        return;
    }
 
 
    pfree(cmd.data);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
    ObjectAddress address;
    Form_pg_subscription form;
 
-   rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, MyDatabaseId,
                              CStringGetDatum(name));
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tup;
    Relation    rel;
 
-   rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+   rel = table_open(SubscriptionRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
 
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
 
                    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
        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);
        {
            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. */
        ListCell   *cell;
 
        /* Already have strong enough lock on the parent */
-       parent = heap_open(parentId, NoLock);
+       parent = table_open(parentId, NoLock);
        idxlist = RelationGetIndexList(parent);
 
        /*
         */
        CloneForeignKeyConstraints(parentId, relationId, NULL);
 
-       heap_close(parent, NoLock);
+       table_close(parent, NoLock);
    }
 
    /*
                                           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;
        }
 
                    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
                 */
                if (RELATION_IS_OTHER_TEMP(rel))
                {
-                   heap_close(rel, lockmode);
+                   table_close(rel, lockmode);
                    continue;
                }
 
    {
        Relation    rel = (Relation) lfirst(cell);
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 }
 
                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))));
                                          RecentXmin, minmulti);
                if (toastrel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
                    heap_create_init_fork(toastrel);
-               heap_close(toastrel, NoLock);
+               table_close(toastrel, NoLock);
            }
 
            /*
    {
        Relation    rel = (Relation) lfirst(cell);
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 }
 
        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
         * That will prevent someone else from deleting or ALTERing the parent
         * before the child is committed.
         */
-       heap_close(relation, NoLock);
+       table_close(relation, NoLock);
    }
 
    /*
     * 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)
        seqNumber++;
    }
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /*
    /*
     * 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);
    }
 
    heap_freetuple(tuple);
-   heap_close(relationRelation, RowExclusiveLock);
+   table_close(relationRelation, RowExclusiveLock);
 }
 
 /*
            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))
 
    heap_freetuple(atttup);
 
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    relation_close(targetrelation, NoLock); /* close rel but keep lock */
 
        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
    {
    /*
     * 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 */
                                 InvalidOid, is_internal);
 
    heap_freetuple(reltup);
-   heap_close(relrelation, RowExclusiveLock);
+   table_close(relrelation, RowExclusiveLock);
 
    /*
     * Also rename the associated type, if any.
        {
            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);
        }
 
        /*
            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
            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
                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,
                 * 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);
    }
 }
 
     * 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;
 
 
    FreeExecutorState(estate);
 
-   heap_close(oldrel, NoLock);
+   table_close(oldrel, NoLock);
    if (newrel)
    {
        FreeBulkInsertState(bistate);
        if (hi_options & HEAP_INSERT_SKIP_WAL)
            heap_sync(newrel);
 
-       heap_close(newrel, NoLock);
+       table_close(newrel, NoLock);
    }
 }
 
     * 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,
    HeapTuple   tuple;
    List       *result = NIL;
 
-   classRel = heap_open(RelationRelationId, AccessShareLock);
+   classRel = table_open(RelationRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_class_reloftype,
    }
 
    heap_endscan(scan);
-   heap_close(classRel, AccessShareLock);
+   table_close(classRel, AccessShareLock);
 
    return result;
 }
                (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
                    (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))
    /* 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;
    }
 
 
    InsertPgAttributeTuple(attrdesc, &attribute, NULL);
 
-   heap_close(attrdesc, RowExclusiveLock);
+   table_close(attrdesc, RowExclusiveLock);
 
    /*
     * Update pg_class tuple as appropriate
    /* 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();
        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 */
                        colDef, recurse, true,
                        if_not_exists, lockmode);
 
-       heap_close(childrel, NoLock);
+       table_close(childrel, NoLock);
    }
 
    ObjectAddressSubSet(address, RelationRelationId, myrelid, newattnum);
    /*
     * lookup the attribute
     */
-   attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
    if (!HeapTupleIsValid(tuple))
    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;
 
                    (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
                     errmsg("column \"%s\" is marked NOT NULL in parent table",
                            colName)));
-       heap_close(parent, AccessShareLock);
+       table_close(parent, AccessShareLock);
    }
 
    /*
    InvokeObjectPostAlterHook(RelationRelationId,
                              RelationGetRelid(rel), attnum);
 
-   heap_close(attr_rel, RowExclusiveLock);
+   table_close(attr_rel, RowExclusiveLock);
 
    return address;
 }
    /*
     * lookup the attribute
     */
-   attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+   attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
 
    InvokeObjectPostAlterHook(RelationRelationId,
                              RelationGetRelid(rel), attnum);
 
-   heap_close(attr_rel, RowExclusiveLock);
+   table_close(attr_rel, RowExclusiveLock);
 
    return address;
 }
    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))
                        RelationGetRelid(rel), attnum);
    heap_freetuple(tuple);
 
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    return address;
 }
     * there.
     */
 
-   attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrelation = table_open(AttributeRelationId, RowExclusiveLock);
    tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
    if (!HeapTupleIsValid(tuple))
        ereport(ERROR,
        address = InvalidObjectAddress;
 
    heap_freetuple(tuple);
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    return address;
 }
    Oid         seqid;
    ObjectAddress seqaddress;
 
-   attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrelation = table_open(AttributeRelationId, RowExclusiveLock);
    tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
    if (!HeapTupleIsValid(tuple))
        ereport(ERROR,
                    (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;
        }
    }
                        RelationGetRelid(rel), attnum);
    heap_freetuple(tuple);
 
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    /* drop the internal sequence */
    seqid = getOwnedSequence(RelationGetRelid(rel), attnum);
                        newtarget)));
    }
 
-   attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrelation = table_open(AttributeRelationId, RowExclusiveLock);
 
    if (colName)
    {
                        RelationGetRelid(rel), attnum);
    heap_freetuple(tuple);
 
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    return address;
 }
    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);
 
 
    ReleaseSysCache(tuple);
 
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    return address;
 }
        newstorage = 0;         /* keep compiler quiet */
    }
 
-   attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+   attrelation = table_open(AttributeRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
 
 
    heap_freetuple(tuple);
 
-   heap_close(attrelation, RowExclusiveLock);
+   table_close(attrelation, RowExclusiveLock);
 
    ObjectAddressSubSet(address, RelationRelationId,
                        RelationGetRelid(rel), attnum);
                     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);
            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);
 
            heap_freetuple(tuple);
 
-           heap_close(childrel, NoLock);
+           table_close(childrel, NoLock);
        }
-       heap_close(attr_rel, RowExclusiveLock);
+       table_close(attr_rel, RowExclusiveLock);
    }
 
    /*
        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 */
        ATAddCheckConstraint(wqueue, childtab, childrel,
                             constr, recurse, true, is_readd, lockmode);
 
-       heap_close(childrel, NoLock);
+       table_close(childrel, NoLock);
    }
 
    return address;
     * 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
        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");
 
                               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;
 
 
            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;
 }
    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,
    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);
 }
 
 /*
        {
            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 */
        }
    }
 }
 
    cmdcon = castNode(Constraint, cmd->def);
 
-   conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conrel = table_open(ConstraintRelationId, RowExclusiveLock);
 
    /*
     * Find and check the target constraint
         * 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,
 
        systable_endscan(tgscan);
 
-       heap_close(tgrel, RowExclusiveLock);
+       table_close(tgrel, RowExclusiveLock);
 
        /*
         * Invalidate relcache so that others see the new attributes.  We must
 
    systable_endscan(scan);
 
-   heap_close(conrel, RowExclusiveLock);
+   table_close(conrel, RowExclusiveLock);
 
    return address;
 }
    Form_pg_constraint con;
    ObjectAddress address;
 
-   conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conrel = table_open(ConstraintRelationId, RowExclusiveLock);
 
    /*
     * Find and check the target constraint
             * 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
                             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);
 
    systable_endscan(scan);
 
-   heap_close(conrel, RowExclusiveLock);
+   table_close(conrel, RowExclusiveLock);
 
    return address;
 }
    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
            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);
        }
 
        /*
            ereport(NOTICE,
                    (errmsg("constraint \"%s\" of relation \"%s\" does not exist, skipping",
                            constrName, RelationGetRelationName(rel))));
-           heap_close(conrel, RowExclusiveLock);
+           table_close(conrel, RowExclusiveLock);
            return;
        }
    }
        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],
 
        heap_freetuple(copy_tuple);
 
-       heap_close(childrel, NoLock);
+       table_close(childrel, NoLock);
    }
 
-   heap_close(conrel, RowExclusiveLock);
+   table_close(conrel, RowExclusiveLock);
 }
 
 /*
    {
        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);
     * 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,
 
    systable_endscan(scan);
 
-   heap_close(depRel, RowExclusiveLock);
+   table_close(depRel, RowExclusiveLock);
 
    /*
     * Here we go --- change the recorded column type and collation.  (Note
 
    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);
        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,
    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,
 
    ReleaseSysCache(tuple);
 
-   heap_close(attrel, RowExclusiveLock);
+   table_close(attrel, RowExclusiveLock);
 
    heap_freetuple(newtuple);
 
    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))
    InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);
 
    ReleaseSysCache(tuple);
-   heap_close(class_rel, RowExclusiveLock);
+   table_close(class_rel, RowExclusiveLock);
    relation_close(target_rel, NoLock);
 }
 
    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,
        heap_freetuple(newtuple);
    }
    systable_endscan(scan);
-   heap_close(attRelation, RowExclusiveLock);
+   table_close(attRelation, RowExclusiveLock);
 }
 
 /*
     * 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,
    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);
        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));
 
        ReleaseSysCache(tuple);
 
-       heap_close(toastrel, NoLock);
+       table_close(toastrel, NoLock);
    }
 
-   heap_close(pgclass, RowExclusiveLock);
+   table_close(pgclass, RowExclusiveLock);
 }
 
 /*
    }
 
    /* 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))
 
    heap_freetuple(tuple);
 
-   heap_close(pg_class, RowExclusiveLock);
+   table_close(pg_class, RowExclusiveLock);
 
    relation_close(rel, NoLock);
 
    }
 
    /* 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))
 
    heap_freetuple(tuple);
 
-   heap_close(pg_class, RowExclusiveLock);
+   table_close(pg_class, RowExclusiveLock);
 
    /* Make sure the reltablespace change is visible */
    CommandCounterIncrement();
                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)
    {
    }
 
    heap_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    if (relations == NIL)
        ereport(NOTICE,
     * 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
                     RelationGetRelid(parent_rel));
 
    /* keep our lock on the parent relation until commit */
-   heap_close(parent_rel, NoLock);
+   table_close(parent_rel, NoLock);
 
    return address;
 }
    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
                             RELKIND_PARTITIONED_TABLE);
 
    /* Now we're done with pg_inherits */
-   heap_close(catalogRelation, RowExclusiveLock);
+   table_close(catalogRelation, RowExclusiveLock);
 }
 
 /*
    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;
        }
    }
 
-   heap_close(attrrel, RowExclusiveLock);
+   table_close(attrrel, RowExclusiveLock);
 }
 
 /*
    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 */
    }
 
    systable_endscan(parent_scan);
-   heap_close(catalog_relation, RowExclusiveLock);
+   table_close(catalog_relation, RowExclusiveLock);
 }
 
 /*
     * 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
                     RelationGetRelid(parent_rel));
 
    /* keep our lock on the parent relation until commit */
-   heap_close(parent_rel, NoLock);
+   table_close(parent_rel, NoLock);
 
    return address;
 }
    /*
     * 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,
        }
    }
    systable_endscan(scan);
-   heap_close(catalogRelation, RowExclusiveLock);
+   table_close(catalogRelation, RowExclusiveLock);
 
    /*
     * Likewise, find inherited check constraints and disinherit them. To do
     * 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,
    }
 
    systable_endscan(scan);
-   heap_close(catalogRelation, RowExclusiveLock);
+   table_close(catalogRelation, RowExclusiveLock);
 
    drop_parent_dependency(RelationGetRelid(child_rel),
                           RelationRelationId,
    ScanKeyData key[3];
    HeapTuple   depTuple;
 
-   catalogRelation = heap_open(DependRelationId, RowExclusiveLock);
+   catalogRelation = table_open(DependRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_classid,
    }
 
    systable_endscan(scan);
-   heap_close(catalogRelation, RowExclusiveLock);
+   table_close(catalogRelation, RowExclusiveLock);
 }
 
 /*
    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,
                (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
    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);
    InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
 
    heap_freetuple(classtuple);
-   heap_close(relationRelation, RowExclusiveLock);
+   table_close(relationRelation, RowExclusiveLock);
 
    ReleaseSysCache(typetuple);
 
                           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);
    InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
 
    heap_freetuple(tuple);
-   heap_close(relationRelation, RowExclusiveLock);
+   table_close(relationRelation, RowExclusiveLock);
 }
 
 /*
    /*
     * 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))
        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);
 
    /*
     * 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);
        heap_freetuple(pg_index_tuple);
    }
 
-   heap_close(pg_index, RowExclusiveLock);
+   table_close(pg_index, RowExclusiveLock);
 }
 
 /*
 
    relid = RelationGetRelid(rel);
 
-   pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+   pg_class = table_open(RelationRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
 
    ((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);
 }
 
    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));
 
    ((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);
 }
 
 
    relid = RelationGetRelid(rel);
 
-   pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+   pg_class = table_open(RelationRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
 
    ((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);
 }
 
    if (options == NIL)
        return;
 
-   ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+   ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
 
    tuple = SearchSysCacheCopy1(FOREIGNTABLEREL, rel->rd_id);
    if (!HeapTupleIsValid(tuple))
    InvokeObjectPostAlterHook(ForeignTableRelationId,
                              RelationGetRelid(rel), 0);
 
-   heap_close(ftrel, RowExclusiveLock);
+   table_close(ftrel, RowExclusiveLock);
 
    heap_freetuple(tuple);
 }
     * 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
 
    systable_endscan(scan);
 
-   heap_close(pg_constraint, AccessShareLock);
+   table_close(pg_constraint, AccessShareLock);
 
    return true;
 }
    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);
                                  false, objsMoved);
    }
 
-   heap_close(classRel, RowExclusiveLock);
+   table_close(classRel, RowExclusiveLock);
 }
 
 /*
     * 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,
            /*
             * 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
            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 */
        }
    }
 }
    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
     * 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,
                (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
        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;
 }
 
    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);
 
    MemoryContextDelete(perTupCxt);
 
    systable_endscan(scan);
-   heap_close(pg_trigger, RowExclusiveLock);
+   table_close(pg_trigger, RowExclusiveLock);
 }
 
 /*
    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))
        update_relispartition(classRel, idxid, false);
        index_close(idx, NoLock);
    }
-   heap_close(classRel, RowExclusiveLock);
+   table_close(classRel, RowExclusiveLock);
 
    /* Detach foreign keys */
    fks = copyObject(RelationGetFKeyList(partRel));
    ObjectAddressSet(address, RelationRelationId, RelationGetRelid(partRel));
 
    /* keep our lock until commit */
-   heap_close(partRel, NoLock);
+   table_close(partRel, NoLock);
 
    return address;
 }
    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)));
    }
 
    systable_endscan(scan);
-   heap_close(pg_inherits, AccessShareLock);
+   table_close(pg_inherits, AccessShareLock);
 }
 
 /*
     * (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)));
 
    /* 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
        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;
 
        CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup);
 
-       heap_close(idxRel, RowExclusiveLock);
+       table_close(idxRel, RowExclusiveLock);
    }
 
    /*
 
    if (classRel == NULL)
    {
-       classRel = heap_open(RelationRelationId, RowExclusiveLock);
+       classRel = table_open(RelationRelationId, RowExclusiveLock);
        opened = true;
    }
 
    ReleaseSysCache(tup);
 
    if (opened)
-       heap_close(classRel, RowExclusiveLock);
+       table_close(classRel, RowExclusiveLock);
 }
 
     * lock the proposed tablename against other would-be creators. The
     * insertion will roll back if we find problems below.
     */
-   rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+   rel = table_open(TableSpaceRelationId, RowExclusiveLock);
 
    MemSet(nulls, false, sizeof(nulls));
 
    pfree(location);
 
    /* We keep the lock on pg_tablespace until commit */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return tablespaceoid;
 #else                          /* !HAVE_SYMLINK */
    /*
     * Find the target tuple
     */
-   rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+   rel = table_open(TableSpaceRelationId, RowExclusiveLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_tablespace_spcname,
                            tablespacename)));
            /* XXX I assume I need one or both of these next two calls */
            heap_endscan(scandesc);
-           heap_close(rel, NoLock);
+           table_close(rel, NoLock);
        }
        return;
    }
    LWLockRelease(TablespaceCreateLock);
 
    /* We keep the lock on pg_tablespace until commit */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 #else                          /* !HAVE_SYMLINK */
    ereport(ERROR,
            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
    ObjectAddress address;
 
    /* Search pg_tablespace */
-   rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+   rel = table_open(TableSpaceRelationId, RowExclusiveLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_tablespace_spcname,
 
    ObjectAddressSet(address, TableSpaceRelationId, tspId);
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return address;
 }
    HeapTuple   newtuple;
 
    /* Search pg_tablespace */
-   rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+   rel = table_open(TableSpaceRelationId, RowExclusiveLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_tablespace_spcname,
 
    /* Conclude heap scan. */
    heap_endscan(scandesc);
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return tablespaceoid;
 }
     * index on name, on the theory that pg_tablespace will usually have just
     * a few entries and so an indexed lookup is a waste of effort.
     */
-   rel = heap_open(TableSpaceRelationId, AccessShareLock);
+   rel = table_open(TableSpaceRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_tablespace_spcname,
        result = InvalidOid;
 
    heap_endscan(scandesc);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    if (!OidIsValid(result) && !missing_ok)
        ereport(ERROR,
     * index on oid, on the theory that pg_tablespace will usually have just a
     * few entries and so an indexed lookup is a waste of effort.
     */
-   rel = heap_open(TableSpaceRelationId, AccessShareLock);
+   rel = table_open(TableSpaceRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
                Anum_pg_tablespace_oid,
        result = NULL;
 
    heap_endscan(scandesc);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return result;
 }
 
    bool        partition_recurse;
 
    if (OidIsValid(relOid))
-       rel = heap_open(relOid, ShareRowExclusiveLock);
+       rel = table_open(relOid, ShareRowExclusiveLock);
    else
-       rel = heap_openrv(stmt->relation, ShareRowExclusiveLock);
+       rel = table_openrv(stmt->relation, ShareRowExclusiveLock);
 
    /*
     * Triggers must be on tables or views, and there are additional
        RI_FKey_trigger_type(funcoid) != RI_TRIGGER_NONE)
    {
        /* Keep lock on target rel until end of xact */
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
 
        ConvertTriggerToFK(stmt, funcoid);
 
     * Generate the trigger's OID now, so that we can use it in the name if
     * needed.
     */
-   tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(TriggerRelationId, RowExclusiveLock);
 
    trigoid = GetNewOidWithIndex(tgrel, TriggerOidIndexId,
                                 Anum_pg_trigger_oid);
    CatalogTupleInsert(tgrel, tuple);
 
    heap_freetuple(tuple);
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 
    pfree(DatumGetPointer(values[Anum_pg_trigger_tgname - 1]));
    pfree(DatumGetPointer(values[Anum_pg_trigger_tgargs - 1]));
     * Update relation's pg_class entry; if necessary; and if not, send an SI
     * message to make other backends (and this one) rebuild relcache entries.
     */
-   pgrel = heap_open(RelationRelationId, RowExclusiveLock);
+   pgrel = table_open(RelationRelationId, RowExclusiveLock);
    tuple = SearchSysCacheCopy1(RELOID,
                                ObjectIdGetDatum(RelationGetRelid(rel)));
    if (!HeapTupleIsValid(tuple))
        CacheInvalidateRelcacheByTuple(tuple);
 
    heap_freetuple(tuple);
-   heap_close(pgrel, RowExclusiveLock);
+   table_close(pgrel, RowExclusiveLock);
 
    /*
     * Record dependencies for trigger.  Always place a normal dependency on
            Node       *qual;
            bool        found_whole_row;
 
-           childTbl = heap_open(partdesc->oids[i], ShareRowExclusiveLock);
+           childTbl = table_open(partdesc->oids[i], ShareRowExclusiveLock);
 
            /* Find which of the child indexes is the one on this partition */
            if (OidIsValid(indexOid))
                          funcoid, trigoid, qual,
                          isInternal, true);
 
-           heap_close(childTbl, NoLock);
+           table_close(childTbl, NoLock);
 
            MemoryContextReset(perChildCxt);
        }
    }
 
    /* Keep lock on target rel until end of xact */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return myself;
 }
    Oid         relid;
    Relation    rel;
 
-   tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(TriggerRelationId, RowExclusiveLock);
 
    /*
     * Find the trigger to delete.
     */
    relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
 
-   rel = heap_open(relid, AccessExclusiveLock);
+   rel = table_open(relid, AccessExclusiveLock);
 
    if (rel->rd_rel->relkind != RELKIND_RELATION &&
        rel->rd_rel->relkind != RELKIND_VIEW &&
    CatalogTupleDelete(tgrel, &tup->t_self);
 
    systable_endscan(tgscan);
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 
    /*
     * We do not bother to try to determine whether any other triggers remain,
    CacheInvalidateRelcache(rel);
 
    /* Keep lock on trigger's rel until end of xact */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 /*
    /*
     * Find the trigger, verify permissions, set up object address
     */
-   tgrel = heap_open(TriggerRelationId, AccessShareLock);
+   tgrel = table_open(TriggerRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_trigger_tgrelid,
    }
 
    systable_endscan(tgscan);
-   heap_close(tgrel, AccessShareLock);
+   table_close(tgrel, AccessShareLock);
    return oid;
 }
 
     * NOTE that this is cool only because we have AccessExclusiveLock on the
     * relation, so the trigger set won't be changing underneath us.
     */
-   tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(TriggerRelationId, RowExclusiveLock);
 
    /*
     * First pass -- look for name conflict
 
    systable_endscan(tgscan);
 
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 
    /*
     * Close rel, but keep exclusive lock!
    bool        changed;
 
    /* Scan the relevant entries in pg_triggers */
-   tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+   tgrel = table_open(TriggerRelationId, RowExclusiveLock);
 
    ScanKeyInit(&keys[0],
                Anum_pg_trigger_tgrelid,
                    part = relation_open(partdesc->oids[i], lockmode);
                    EnableDisableTrigger(part, NameStr(oldtrig->tgname),
                                         fires_when, skip_system, lockmode);
-                   heap_close(part, NoLock);   /* keep lock till commit */
+                   table_close(part, NoLock);  /* keep lock till commit */
                }
            }
 
 
    systable_endscan(tgscan);
 
-   heap_close(tgrel, RowExclusiveLock);
+   table_close(tgrel, RowExclusiveLock);
 
    if (tgname && !found)
        ereport(ERROR,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(RelationGetRelid(relation)));
 
-   tgrel = heap_open(TriggerRelationId, AccessShareLock);
+   tgrel = table_open(TriggerRelationId, AccessShareLock);
    tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
                                NULL, 1, &skey);
 
    }
 
    systable_endscan(tgscan);
-   heap_close(tgrel, AccessShareLock);
+   table_close(tgrel, AccessShareLock);
 
    /* There might not be any triggers */
    if (numtrigs == 0)
         * A constraint in a partitioned table may have corresponding
         * constraints in the partitions.  Grab those too.
         */
-       conrel = heap_open(ConstraintRelationId, AccessShareLock);
+       conrel = table_open(ConstraintRelationId, AccessShareLock);
 
        foreach(lc, stmt->constraints)
        {
            systable_endscan(scan);
        }
 
-       heap_close(conrel, AccessShareLock);
+       table_close(conrel, AccessShareLock);
 
        /*
         * Now, locate the trigger(s) implementing each of these constraints,
         * and make a list of their OIDs.
         */
-       tgrel = heap_open(TriggerRelationId, AccessShareLock);
+       tgrel = table_open(TriggerRelationId, AccessShareLock);
 
        foreach(lc, conoidlist)
        {
                     conoid);
        }
 
-       heap_close(tgrel, AccessShareLock);
+       table_close(tgrel, AccessShareLock);
 
        /*
         * Now we can set the trigger states of individual triggers for this
 
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to create text search parsers")));
 
-   prsRel = heap_open(TSParserRelationId, RowExclusiveLock);
+   prsRel = table_open(TSParserRelationId, RowExclusiveLock);
 
    /* Convert list of names to a name and namespace */
    namespaceoid = QualifiedNameGetCreationNamespace(names, &prsname);
 
    heap_freetuple(tup);
 
-   heap_close(prsRel, RowExclusiveLock);
+   table_close(prsRel, RowExclusiveLock);
 
    return address;
 }
    Relation    relation;
    HeapTuple   tup;
 
-   relation = heap_open(TSParserRelationId, RowExclusiveLock);
+   relation = table_open(TSParserRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /* ---------------------- TS Dictionary commands -----------------------*/
    verify_dictoptions(templId, dictoptions);
 
 
-   dictRel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+   dictRel = table_open(TSDictionaryRelationId, RowExclusiveLock);
 
    /*
     * Looks good, insert
 
    heap_freetuple(tup);
 
-   heap_close(dictRel, RowExclusiveLock);
+   table_close(dictRel, RowExclusiveLock);
 
    return address;
 }
    Relation    relation;
    HeapTuple   tup;
 
-   relation = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+   relation = table_open(TSDictionaryRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /*
 
    dictId = get_ts_dict_oid(stmt->dictname, false);
 
-   rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+   rel = table_open(TSDictionaryRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId));
 
    heap_freetuple(newtup);
    ReleaseSysCache(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    /* Convert list of names to a name and namespace */
    namespaceoid = QualifiedNameGetCreationNamespace(names, &tmplname);
 
-   tmplRel = heap_open(TSTemplateRelationId, RowExclusiveLock);
+   tmplRel = table_open(TSTemplateRelationId, RowExclusiveLock);
 
    for (i = 0; i < Natts_pg_ts_template; i++)
    {
 
    heap_freetuple(tup);
 
-   heap_close(tmplRel, RowExclusiveLock);
+   table_close(tmplRel, RowExclusiveLock);
 
    return address;
 }
    Relation    relation;
    HeapTuple   tup;
 
-   relation = heap_open(TSTemplateRelationId, RowExclusiveLock);
+   relation = table_open(TSTemplateRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 /* ---------------------- TS Configuration commands -----------------------*/
                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                 errmsg("text search parser is required")));
 
-   cfgRel = heap_open(TSConfigRelationId, RowExclusiveLock);
+   cfgRel = table_open(TSConfigRelationId, RowExclusiveLock);
 
    /*
     * Looks good, build tuple and insert
        SysScanDesc scan;
        HeapTuple   maptup;
 
-       mapRel = heap_open(TSConfigMapRelationId, RowExclusiveLock);
+       mapRel = table_open(TSConfigMapRelationId, RowExclusiveLock);
 
        ScanKeyInit(&skey,
                    Anum_pg_ts_config_map_mapcfg,
    heap_freetuple(tup);
 
    if (mapRel)
-       heap_close(mapRel, RowExclusiveLock);
-   heap_close(cfgRel, RowExclusiveLock);
+       table_close(mapRel, RowExclusiveLock);
+   table_close(cfgRel, RowExclusiveLock);
 
    return address;
 }
    SysScanDesc scan;
 
    /* Remove the pg_ts_config entry */
-   relCfg = heap_open(TSConfigRelationId, RowExclusiveLock);
+   relCfg = table_open(TSConfigRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
 
 
    ReleaseSysCache(tup);
 
-   heap_close(relCfg, RowExclusiveLock);
+   table_close(relCfg, RowExclusiveLock);
 
    /* Remove any pg_ts_config_map entries */
-   relMap = heap_open(TSConfigMapRelationId, RowExclusiveLock);
+   relMap = table_open(TSConfigMapRelationId, RowExclusiveLock);
 
    ScanKeyInit(&skey,
                Anum_pg_ts_config_map_mapcfg,
 
    systable_endscan(scan);
 
-   heap_close(relMap, RowExclusiveLock);
+   table_close(relMap, RowExclusiveLock);
 }
 
 /*
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TSCONFIGURATION,
                       NameListToString(stmt->cfgname));
 
-   relMap = heap_open(TSConfigMapRelationId, RowExclusiveLock);
+   relMap = table_open(TSConfigMapRelationId, RowExclusiveLock);
 
    /* Add or drop mappings */
    if (stmt->dicts)
 
    ObjectAddressSet(address, TSConfigRelationId, cfgId);
 
-   heap_close(relMap, RowExclusiveLock);
+   table_close(relMap, RowExclusiveLock);
 
    ReleaseSysCache(tup);
 
 
    Relation    relation;
    HeapTuple   tup;
 
-   relation = heap_open(TypeRelationId, RowExclusiveLock);
+   relation = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
    if (!HeapTupleIsValid(tup))
 
    ReleaseSysCache(tup);
 
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 }
 
 
    }
    else
    {
-       Relation    pg_type = heap_open(TypeRelationId, AccessShareLock);
+       Relation    pg_type = table_open(TypeRelationId, AccessShareLock);
 
        type_array_oid = GetNewOidWithIndex(pg_type, TypeOidIndexId,
                                            Anum_pg_type_oid);
-       heap_close(pg_type, AccessShareLock);
+       table_close(pg_type, AccessShareLock);
    }
 
    return type_array_oid;
    domainoid = typenameTypeId(NULL, typename);
 
    /* Look up the domain in the type table */
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
    if (!HeapTupleIsValid(tup))
    ObjectAddressSet(address, TypeRelationId, domainoid);
 
    /* Clean up */
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
    heap_freetuple(newtuple);
 
    return address;
    domainoid = typenameTypeId(NULL, typename);
 
    /* Look up the domain in the type table */
-   typrel = heap_open(TypeRelationId, RowExclusiveLock);
+   typrel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
    if (!HeapTupleIsValid(tup))
    /* Is the domain already set to the desired constraint? */
    if (typTup->typnotnull == notNull)
    {
-       heap_close(typrel, RowExclusiveLock);
+       table_close(typrel, RowExclusiveLock);
        return address;
    }
 
            UnregisterSnapshot(snapshot);
 
            /* Close each rel after processing, but keep lock */
-           heap_close(testrel, NoLock);
+           table_close(testrel, NoLock);
        }
    }
 
 
    /* Clean up */
    heap_freetuple(tup);
-   heap_close(typrel, RowExclusiveLock);
+   table_close(typrel, RowExclusiveLock);
 
    return address;
 }
    domainoid = typenameTypeId(NULL, typename);
 
    /* Look up the domain in the type table */
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
    if (!HeapTupleIsValid(tup))
    checkDomainOwner(tup);
 
    /* Grab an appropriate lock on the pg_constraint relation */
-   conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conrel = table_open(ConstraintRelationId, RowExclusiveLock);
 
    /* Find and remove the target constraint */
    ScanKeyInit(&skey[0],
 
    /* Clean up after the scan */
    systable_endscan(conscan);
-   heap_close(conrel, RowExclusiveLock);
+   table_close(conrel, RowExclusiveLock);
 
    if (!found)
    {
    ObjectAddressSet(address, TypeRelationId, domainoid);
 
    /* Clean up */
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    domainoid = typenameTypeId(NULL, typename);
 
    /* Look up the domain in the type table */
-   typrel = heap_open(TypeRelationId, RowExclusiveLock);
+   typrel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
    if (!HeapTupleIsValid(tup))
    ObjectAddressSet(address, TypeRelationId, domainoid);
 
    /* Clean up */
-   heap_close(typrel, RowExclusiveLock);
+   table_close(typrel, RowExclusiveLock);
 
    return address;
 }
    domainoid = typenameTypeId(NULL, typename);
 
    /* Look up the domain in the type table */
-   typrel = heap_open(TypeRelationId, AccessShareLock);
+   typrel = table_open(TypeRelationId, AccessShareLock);
 
    tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(domainoid));
    if (!HeapTupleIsValid(tup))
    /*
     * Find and check the target constraint
     */
-   conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+   conrel = table_open(ConstraintRelationId, RowExclusiveLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_constraint_conrelid,
 
    systable_endscan(scan);
 
-   heap_close(typrel, AccessShareLock);
-   heap_close(conrel, RowExclusiveLock);
+   table_close(typrel, AccessShareLock);
+   table_close(conrel, RowExclusiveLock);
 
    ReleaseSysCache(tup);
 
        UnregisterSnapshot(snapshot);
 
        /* Hold relation lock till commit (XXX bad for concurrency) */
-       heap_close(testrel, NoLock);
+       table_close(testrel, NoLock);
    }
 
    FreeExecutorState(estate);
     * We scan pg_depend to find those things that depend on the domain. (We
     * assume we can ignore refobjsubid for a domain.)
     */
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_refclassid,
    typeOid = typenameTypeId(NULL, typename);
 
    /* Look up the type in the type table */
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
    if (!HeapTupleIsValid(tup))
 
    ObjectAddressSet(address, TypeRelationId, typeOid);
    /* Clean up */
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    AclResult   aclresult;
    ObjectAddress address;
 
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    /* Make a TypeName so we can use standard type lookup machinery */
    typename = makeTypeNameFromNameList(names);
    ObjectAddressSet(address, TypeRelationId, typeOid);
 
    /* Clean up */
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    return address;
 }
    HeapTuple   tup;
    Form_pg_type typTup;
 
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
    if (!HeapTupleIsValid(tup))
    InvokeObjectPostAlterHook(TypeRelationId, typeOid, 0);
 
    ReleaseSysCache(tup);
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    Datum       aclDatum;
    bool        isNull;
 
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
    if (!HeapTupleIsValid(tup))
        AlterTypeOwnerInternal(typTup->typarray, newOwnerId);
 
    /* Clean up */
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 }
 
 /*
    if (object_address_present(&thisobj, objsMoved))
        return InvalidOid;
 
-   rel = heap_open(TypeRelationId, RowExclusiveLock);
+   rel = table_open(TypeRelationId, RowExclusiveLock);
 
    tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
    if (!HeapTupleIsValid(tup))
    {
        Relation    classRel;
 
-       classRel = heap_open(RelationRelationId, RowExclusiveLock);
+       classRel = table_open(RelationRelationId, RowExclusiveLock);
 
        AlterRelationNamespaceInternal(classRel, typform->typrelid,
                                       oldNspOid, nspOid,
                                       false, objsMoved);
 
-       heap_close(classRel, RowExclusiveLock);
+       table_close(classRel, RowExclusiveLock);
 
        /*
         * Check for constraints associated with the composite type (we don't
 
    heap_freetuple(tup);
 
-   heap_close(rel, RowExclusiveLock);
+   table_close(rel, RowExclusiveLock);
 
    add_exact_object_address(&thisobj, objsMoved);
 
 
     * Check the pg_authid relation to be certain the role doesn't already
     * exist.
     */
-   pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
+   pg_authid_rel = table_open(AuthIdRelationId, RowExclusiveLock);
    pg_authid_dsc = RelationGetDescr(pg_authid_rel);
 
    if (OidIsValid(get_role_oid(stmt->role, true)))
    /*
     * Close pg_authid, but keep lock till commit.
     */
-   heap_close(pg_authid_rel, NoLock);
+   table_close(pg_authid_rel, NoLock);
 
    return roleid;
 }
    /*
     * Scan the pg_authid relation to be certain the user exists.
     */
-   pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
+   pg_authid_rel = table_open(AuthIdRelationId, RowExclusiveLock);
    pg_authid_dsc = RelationGetDescr(pg_authid_rel);
 
    tuple = get_rolespec_tuple(stmt->role);
    /*
     * Close pg_authid, but keep lock till commit.
     */
-   heap_close(pg_authid_rel, NoLock);
+   table_close(pg_authid_rel, NoLock);
 
    return roleid;
 }
     * Scan the pg_authid relation to find the Oid of the role(s) to be
     * deleted.
     */
-   pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
-   pg_auth_members_rel = heap_open(AuthMemRelationId, RowExclusiveLock);
+   pg_authid_rel = table_open(AuthIdRelationId, RowExclusiveLock);
+   pg_auth_members_rel = table_open(AuthMemRelationId, RowExclusiveLock);
 
    foreach(item, stmt->roles)
    {
    /*
     * Now we can clean up; but keep locks until commit.
     */
-   heap_close(pg_auth_members_rel, NoLock);
-   heap_close(pg_authid_rel, NoLock);
+   table_close(pg_auth_members_rel, NoLock);
+   table_close(pg_authid_rel, NoLock);
 }
 
 /*
    ObjectAddress address;
    Form_pg_authid authform;
 
-   rel = heap_open(AuthIdRelationId, RowExclusiveLock);
+   rel = table_open(AuthIdRelationId, RowExclusiveLock);
    dsc = RelationGetDescr(rel);
 
    oldtuple = SearchSysCache1(AUTHNAME, CStringGetDatum(oldname));
    /*
     * Close pg_authid, but keep lock till commit.
     */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    return address;
 }
    grantee_ids = roleSpecsToIds(stmt->grantee_roles);
 
    /* AccessShareLock is enough since we aren't modifying pg_authid */
-   pg_authid_rel = heap_open(AuthIdRelationId, AccessShareLock);
+   pg_authid_rel = table_open(AuthIdRelationId, AccessShareLock);
 
    /*
     * Step through all of the granted roles and add/remove entries for the
    /*
     * Close pg_authid, but keep lock till commit.
     */
-   heap_close(pg_authid_rel, NoLock);
+   table_close(pg_authid_rel, NoLock);
 }
 
 /*
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to set grantor")));
 
-   pg_authmem_rel = heap_open(AuthMemRelationId, RowExclusiveLock);
+   pg_authmem_rel = table_open(AuthMemRelationId, RowExclusiveLock);
    pg_authmem_dsc = RelationGetDescr(pg_authmem_rel);
 
    forboth(specitem, memberSpecs, iditem, memberIds)
    /*
     * Close pg_authmem, but keep lock till commit.
     */
-   heap_close(pg_authmem_rel, NoLock);
+   table_close(pg_authmem_rel, NoLock);
 }
 
 /*
                            rolename)));
    }
 
-   pg_authmem_rel = heap_open(AuthMemRelationId, RowExclusiveLock);
+   pg_authmem_rel = table_open(AuthMemRelationId, RowExclusiveLock);
    pg_authmem_dsc = RelationGetDescr(pg_authmem_rel);
 
    forboth(specitem, memberSpecs, iditem, memberIds)
    /*
     * Close pg_authmem, but keep lock till commit.
     */
-   heap_close(pg_authmem_rel, NoLock);
+   table_close(pg_authmem_rel, NoLock);
 }
 
    HeapScanDesc scan;
    HeapTuple   tuple;
 
-   pgclass = heap_open(RelationRelationId, AccessShareLock);
+   pgclass = table_open(RelationRelationId, AccessShareLock);
 
    scan = heap_beginscan_catalog(pgclass, 0, NULL);
 
    }
 
    heap_endscan(scan);
-   heap_close(pgclass, AccessShareLock);
+   table_close(pgclass, AccessShareLock);
 
    return vacrels;
 }
    Form_pg_class pgcform;
    bool        dirty;
 
-   rd = heap_open(RelationRelationId, RowExclusiveLock);
+   rd = table_open(RelationRelationId, RowExclusiveLock);
 
    /* Fetch a copy of the tuple to scribble on */
    ctup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
    if (dirty)
        heap_inplace_update(rd, ctup);
 
-   heap_close(rd, RowExclusiveLock);
+   table_close(rd, RowExclusiveLock);
 }
 
 
     * We must seqscan pg_class to find the minimum Xid, because there is no
     * index that can help us here.
     */
-   relation = heap_open(RelationRelationId, AccessShareLock);
+   relation = table_open(RelationRelationId, AccessShareLock);
 
    scan = systable_beginscan(relation, InvalidOid, false,
                              NULL, 0, NULL);
 
    /* we're done with pg_class */
    systable_endscan(scan);
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    /* chicken out if bogus data found */
    if (bogus)
    Assert(MultiXactIdIsValid(newMinMulti));
 
    /* Now fetch the pg_database tuple we need to update. */
-   relation = heap_open(DatabaseRelationId, RowExclusiveLock);
+   relation = table_open(DatabaseRelationId, RowExclusiveLock);
 
    /* Fetch a copy of the tuple to scribble on */
    tuple = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
        heap_inplace_update(relation, tuple);
 
    heap_freetuple(tuple);
-   heap_close(relation, RowExclusiveLock);
+   table_close(relation, RowExclusiveLock);
 
    /*
     * If we were able to advance datfrozenxid or datminmxid, see if we can
     * worst possible outcome is that pg_xact is not truncated as aggressively
     * as it could be.
     */
-   relation = heap_open(DatabaseRelationId, AccessShareLock);
+   relation = table_open(DatabaseRelationId, AccessShareLock);
 
    scan = heap_beginscan_catalog(relation, 0, NULL);
 
 
    heap_endscan(scan);
 
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    /*
     * Do not truncate CLOG if we seem to have suffered wraparound already;
 
     * event got queued, so we need take no new lock here.  Also, we need not
     * recheck the relkind, so no need for CheckValidResultRel.
     */
-   rel = heap_open(relid, NoLock);
+   rel = table_open(relid, NoLock);
 
    /*
     * Make the new entry in the right context.
         */
        Assert(resultRelInfo->ri_NumIndices == 0);
 
-       heap_close(resultRelInfo->ri_RelationDesc, NoLock);
+       table_close(resultRelInfo->ri_RelationDesc, NoLock);
    }
 }
 
    for (i = 0; i < num_relations; i++)
    {
        if (estate->es_relations[i])
-           heap_close(estate->es_relations[i], NoLock);
+           table_close(estate->es_relations[i], NoLock);
    }
 
    /* likewise close any trigger target relations */
 
     * We locked all the partitions in ExecSetupPartitionTupleRouting
     * including the leaf partitions.
     */
-   partrel = heap_open(dispatch->partdesc->oids[partidx], NoLock);
+   partrel = table_open(dispatch->partdesc->oids[partidx], NoLock);
 
    leaf_part_rri = makeNode(ResultRelInfo);
    InitResultRelInfo(leaf_part_rri,
    oldcxt = MemoryContextSwitchTo(proute->memcxt);
 
    if (partoid != RelationGetRelid(proute->partition_root))
-       rel = heap_open(partoid, NoLock);
+       rel = table_open(partoid, NoLock);
    else
        rel = proute->partition_root;
    partdesc = RelationGetPartitionDesc(rel);
    {
        PartitionDispatch pd = proute->partition_dispatch_info[i];
 
-       heap_close(pd->reldesc, NoLock);
+       table_close(pd->reldesc, NoLock);
 
        if (pd->tupslot)
            ExecDropSingleTupleTableSlot(pd->tupslot);
                                                           resultRelInfo);
 
        ExecCloseIndices(resultRelInfo);
-       heap_close(resultRelInfo->ri_RelationDesc, NoLock);
+       table_close(resultRelInfo->ri_RelationDesc, NoLock);
    }
 }
 
 
            /*
             * In a normal query, we should already have the appropriate lock,
             * but verify that through an Assert.  Since there's already an
-            * Assert inside heap_open that insists on holding some lock, it
+            * Assert inside table_open that insists on holding some lock, it
             * seems sufficient to check this only when rellockmode is higher
             * than the minimum.
             */
-           rel = heap_open(rte->relid, NoLock);
+           rel = table_open(rte->relid, NoLock);
            Assert(rte->rellockmode == AccessShareLock ||
                   CheckRelationLockedByMe(rel, rte->rellockmode, false));
        }
             * lock on the relation.  This ensures sane behavior in case the
             * parent process exits before we do.
             */
-           rel = heap_open(rte->relid, rte->rellockmode);
+           rel = table_open(rte->relid, rte->rellockmode);
        }
 
        estate->es_relations[rti - 1] = rel;
 
    /* Build RelOptInfo */
    rel = build_simple_rel(root, 1, NULL);
 
-   heap = heap_open(tableOid, NoLock);
+   heap = table_open(tableOid, NoLock);
    index = index_open(indexOid, NoLock);
 
    /*
 
 done:
    index_close(index, NoLock);
-   heap_close(heap, NoLock);
+   table_close(heap, NoLock);
 
    return parallel_workers;
 }
 
        if (target_rte->rtekind != RTE_RELATION)
            elog(ERROR, "result relation must be a regular relation");
 
-       target_relation = heap_open(target_rte->relid, NoLock);
+       target_relation = table_open(target_rte->relid, NoLock);
    }
    else
        Assert(command_type == CMD_SELECT);
                              target_relation);
 
    if (target_relation)
-       heap_close(target_relation, NoLock);
+       table_close(target_relation, NoLock);
 
    return tlist;
 }
 
     * Must open the parent relation to examine its tupdesc.  We need not lock
     * it; we assume the rewriter already did.
     */
-   oldrelation = heap_open(parentOID, NoLock);
+   oldrelation = table_open(parentOID, NoLock);
 
    /* Scan the inheritance set and expand it */
    if (RelationGetPartitionDesc(oldrelation) != NULL)
 
            /* Open rel if needed; we already have required locks */
            if (childOID != parentOID)
-               newrelation = heap_open(childOID, NoLock);
+               newrelation = table_open(childOID, NoLock);
            else
                newrelation = oldrelation;
 
             */
            if (childOID != parentOID && RELATION_IS_OTHER_TEMP(newrelation))
            {
-               heap_close(newrelation, lockmode);
+               table_close(newrelation, lockmode);
                continue;
            }
 
 
            /* Close child relations, but keep locks */
            if (childOID != parentOID)
-               heap_close(newrelation, NoLock);
+               table_close(newrelation, NoLock);
        }
 
        /*
 
    }
 
-   heap_close(oldrelation, NoLock);
+   table_close(oldrelation, NoLock);
 }
 
 /*
        Relation    childrel;
 
        /* Open rel; we already have required locks */
-       childrel = heap_open(childOID, NoLock);
+       childrel = table_open(childOID, NoLock);
 
        /*
         * Temporary partitions belonging to other sessions should have been
                                       appinfos);
 
        /* Close child relation, but keep locks */
-       heap_close(childrel, NoLock);
+       table_close(childrel, NoLock);
    }
 }
 
 
     * the rewriter or when expand_inherited_rtentry() added it to the query's
     * rangetable.
     */
-   relation = heap_open(relationObjectId, NoLock);
+   relation = table_open(relationObjectId, NoLock);
 
    /* Temporary and unlogged relations are inaccessible during recovery. */
    if (!RelationNeedsWAL(relation) && RecoveryInProgress())
    if (inhparent && relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
        set_relation_partition_info(root, rel, relation);
 
-   heap_close(relation, NoLock);
+   table_close(relation, NoLock);
 
    /*
     * Allow a plugin to editorialize on the info we obtained from the
    relationObjectId = rt_fetch(root->parse->resultRelation,
                                root->parse->rtable)->relid;
 
-   relation = heap_open(relationObjectId, NoLock);
+   relation = table_open(relationObjectId, NoLock);
 
    /*
     * Build normalized/BMS representation of plain indexed attributes, as
            results = lappend_oid(results, idxForm->indexrelid);
            list_free(indexList);
            index_close(idxRel, NoLock);
-           heap_close(relation, NoLock);
+           table_close(relation, NoLock);
            return results;
        }
        else if (indexOidFromConstraint != InvalidOid)
    }
 
    list_free(indexList);
-   heap_close(relation, NoLock);
+   table_close(relation, NoLock);
 
    if (results == NIL)
        ereport(ERROR,
    Relation    relation;
 
    /* As above, assume relation is already locked */
-   relation = heap_open(relid, NoLock);
+   relation = table_open(relid, NoLock);
 
    result = get_rel_data_width(relation, attr_widths);
 
-   heap_close(relation, NoLock);
+   table_close(relation, NoLock);
 
    return result;
 }
    /*
     * We assume the relation has already been safely locked.
     */
-   relation = heap_open(relationObjectId, NoLock);
+   relation = table_open(relationObjectId, NoLock);
 
    constr = relation->rd_att->constr;
    if (constr != NULL)
        }
    }
 
-   heap_close(relation, NoLock);
+   table_close(relation, NoLock);
 
    return result;
 }
    {
        case RTE_RELATION:
            /* Assume we already have adequate lock */
-           relation = heap_open(rte->relid, NoLock);
+           relation = table_open(rte->relid, NoLock);
 
            numattrs = RelationGetNumberOfAttributes(relation);
            for (attrno = 1; attrno <= numattrs; attrno++)
                                                false));
            }
 
-           heap_close(relation, NoLock);
+           table_close(relation, NoLock);
            break;
 
        case RTE_SUBQUERY:
    bool        result = false;
 
    /* Assume we already have adequate lock */
-   relation = heap_open(rte->relid, NoLock);
+   relation = table_open(rte->relid, NoLock);
 
    trigDesc = relation->trigdesc;
    switch (event)
            break;
    }
 
-   heap_close(relation, NoLock);
+   table_close(relation, NoLock);
    return result;
 }
 
 
 
    /* Close old target; this could only happen for multi-action rules */
    if (pstate->p_target_relation != NULL)
-       heap_close(pstate->p_target_relation, NoLock);
+       table_close(pstate->p_target_relation, NoLock);
 
    /*
     * Open target rel and grab suitable lock (which we will hold till end of
     * transaction).
     *
-    * free_parsestate() will eventually do the corresponding heap_close(),
+    * free_parsestate() will eventually do the corresponding table_close(),
     * but *not* release the lock.
     */
    pstate->p_target_relation = parserOpenTable(pstate, relation,
 
                        MaxTupleAttributeNumber)));
 
    if (pstate->p_target_relation != NULL)
-       heap_close(pstate->p_target_relation, NoLock);
+       table_close(pstate->p_target_relation, NoLock);
 
    pfree(pstate);
 }
 
 /*
  * Open a table during parse analysis
  *
- * This is essentially just the same as heap_openrv(), except that it caters
+ * This is essentially just the same as table_openrv(), except that it caters
  * to some parser-specific error reporting needs, notably that it arranges
  * to include the RangeVar's parse location in any resulting error.
  *
    ParseCallbackState pcbstate;
 
    setup_parser_errposition_callback(&pcbstate, pstate, relation->location);
-   rel = heap_openrv_extended(relation, lockmode, true);
+   rel = table_openrv_extended(relation, lockmode, true);
    if (rel == NULL)
    {
        if (relation->schemaname)
     * so that the table can't be deleted or have its schema modified
     * underneath us.
     */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /*
     * Set flags and access permissions.
  * Returns InvalidAttrNumber if the attr doesn't exist (or is dropped).
  *
  * This should only be used if the relation is already
- * heap_open()'ed.  Use the cache version get_attnum()
+ * table_open()'ed.  Use the cache version get_attnum()
  * for access to non-opened relations.
  */
 int
  * given attribute id, return name of that attribute
  *
  * This should only be used if the relation is already
- * heap_open()'ed.  Use the cache version get_atttype()
+ * table_open()'ed.  Use the cache version get_atttype()
  * for access to non-opened relations.
  */
 const NameData *
  * given attribute id, return type of that attribute
  *
  * This should only be used if the relation is already
- * heap_open()'ed.  Use the cache version get_atttype()
+ * table_open()'ed.  Use the cache version get_atttype()
  * for access to non-opened relations.
  */
 Oid
 /*
  * given attribute id, return collation of that attribute
  *
- * This should only be used if the relation is already heap_open()'ed.
+ * This should only be used if the relation is already table_open()'ed.
  */
 Oid
 attnumCollationId(Relation rd, int attid)
 
            if (rte->rtekind == RTE_RELATION)
            {
-               Relation    rel = heap_open(rte->relid, AccessShareLock);
+               Relation    rel = table_open(rte->relid, AccessShareLock);
                char        relpersistence = rel->rd_rel->relpersistence;
 
-               heap_close(rel, AccessShareLock);
+               table_close(rel, AccessShareLock);
                if (relpersistence == RELPERSISTENCE_TEMP)
                    return true;
            }
 
     * commit.  That will prevent someone else from deleting or ALTERing the
     * parent before the child is committed.
     */
-   heap_close(relation, NoLock);
+   table_close(relation, NoLock);
 }
 
 static void
                    Relation    rel;
                    int         count;
 
-                   rel = heap_openrv(inh, AccessShareLock);
+                   rel = table_openrv(inh, AccessShareLock);
                    /* check user requested inheritance from valid relkind */
                    if (rel->rd_rel->relkind != RELKIND_RELATION &&
                        rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
                            break;
                        }
                    }
-                   heap_close(rel, NoLock);
+                   table_close(rel, NoLock);
                    if (found)
                        break;
                }
                    Relation    rel;
                    int         count;
 
-                   rel = heap_openrv(inh, AccessShareLock);
+                   rel = table_openrv(inh, AccessShareLock);
                    /* check user requested inheritance from valid relkind */
                    if (rel->rd_rel->relkind != RELKIND_RELATION &&
                        rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
                            break;
                        }
                    }
-                   heap_close(rel, NoLock);
+                   table_close(rel, NoLock);
                    if (found)
                        break;
                }
    free_parsestate(pstate);
 
    /* Close relation */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /* Mark statement as successfully transformed */
    stmt->transformed = true;
     * DefineQueryRewrite(), and we don't want to grab a lesser lock
     * beforehand.
     */
-   rel = heap_openrv(stmt->relation, AccessExclusiveLock);
+   rel = table_openrv(stmt->relation, AccessExclusiveLock);
 
    if (rel->rd_rel->relkind == RELKIND_MATVIEW)
        ereport(ERROR,
    free_parsestate(pstate);
 
    /* Close relation, but keep the exclusive lock */
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 }
 
 
 
        /* Lock already taken above. */
        if (part_relid != RelationGetRelid(default_rel))
        {
-           part_rel = heap_open(part_relid, NoLock);
+           part_rel = table_open(part_relid, NoLock);
 
            /*
             * If the partition constraints on default partition child imply
                        (errmsg("updated partition constraint for default partition \"%s\" is implied by existing constraints",
                                RelationGetRelationName(part_rel))));
 
-               heap_close(part_rel, NoLock);
+               table_close(part_rel, NoLock);
                continue;
            }
        }
                                RelationGetRelationName(default_rel))));
 
            if (RelationGetRelid(default_rel) != RelationGetRelid(part_rel))
-               heap_close(part_rel, NoLock);
+               table_close(part_rel, NoLock);
 
            continue;
        }
        FreeExecutorState(estate);
 
        if (RelationGetRelid(default_rel) != RelationGetRelid(part_rel))
-           heap_close(part_rel, NoLock);   /* keep the lock until commit */
+           table_close(part_rel, NoLock);  /* keep the lock until commit */
    }
 }
 
 
    StartTransactionCommand();
    (void) GetTransactionSnapshot();
 
-   rel = heap_open(DatabaseRelationId, AccessShareLock);
+   rel = table_open(DatabaseRelationId, AccessShareLock);
    scan = heap_beginscan_catalog(rel, 0, NULL);
 
    while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
    }
 
    heap_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    CommitTransactionCommand();
 
    /* The database hash where pgstat keeps shared relations */
    shared = pgstat_fetch_stat_dbentry(InvalidOid);
 
-   classRel = heap_open(RelationRelationId, AccessShareLock);
+   classRel = table_open(RelationRelationId, AccessShareLock);
 
    /* create a copy so we can use it after closing pg_class */
    pg_class_desc = CreateTupleDescCopy(RelationGetDescr(classRel));
    }
 
    heap_endscan(relScan);
-   heap_close(classRel, AccessShareLock);
+   table_close(classRel, AccessShareLock);
 
    /*
     * Recheck orphan temporary tables, and if they still seem orphaned, drop
 
                       &hash_ctl,
                       HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
 
-   rel = heap_open(catalogid, AccessShareLock);
+   rel = table_open(catalogid, AccessShareLock);
    snapshot = RegisterSnapshot(GetLatestSnapshot());
    scan = heap_beginscan(rel, snapshot, 0, NULL);
    while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
    }
    heap_endscan(scan);
    UnregisterSnapshot(snapshot);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    return htab;
 }
 
    StartTransactionCommand();
    (void) GetTransactionSnapshot();
 
-   rel = heap_open(SubscriptionRelationId, AccessShareLock);
+   rel = table_open(SubscriptionRelationId, AccessShareLock);
    scan = heap_beginscan_catalog(rel, 0, NULL);
 
    while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
    }
 
    heap_endscan(scan);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    CommitTransactionCommand();
 
 
     */
    InitDirtySnapshot(SnapshotDirty);
 
-   rel = heap_open(ReplicationOriginRelationId, ExclusiveLock);
+   rel = table_open(ReplicationOriginRelationId, ExclusiveLock);
 
    for (roident = InvalidOid + 1; roident < PG_UINT16_MAX; roident++)
    {
    }
 
    /* now release lock again,  */
-   heap_close(rel, ExclusiveLock);
+   table_close(rel, ExclusiveLock);
 
    if (tuple == NULL)
        ereport(ERROR,
     * To interlock against concurrent drops, we hold ExclusiveLock on
     * pg_replication_origin throughout this function.
     */
-   rel = heap_open(ReplicationOriginRelationId, ExclusiveLock);
+   rel = table_open(ReplicationOriginRelationId, ExclusiveLock);
 
    /*
     * First, clean up the slot state info, if there is any matching slot.
    CommandCounterIncrement();
 
    /* now release lock again */
-   heap_close(rel, ExclusiveLock);
+   table_close(rel, ExclusiveLock);
 }
 
 
 
                    (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                     errmsg("logical replication target relation \"%s.%s\" does not exist",
                            remoterel->nspname, remoterel->relname)));
-       entry->localrel = heap_open(relid, NoLock);
+       entry->localrel = table_open(relid, NoLock);
 
        /* Check for supported relkind. */
        CheckSubscriptionRelkind(entry->localrel->rd_rel->relkind,
        entry->localreloid = relid;
    }
    else
-       entry->localrel = heap_open(entry->localreloid, lockmode);
+       entry->localrel = table_open(entry->localreloid, lockmode);
 
    if (entry->state != SUBREL_STATE_READY)
        entry->state = GetSubscriptionRelState(MySubscription->oid,
 void
 logicalrep_rel_close(LogicalRepRelMapEntry *rel, LOCKMODE lockmode)
 {
-   heap_close(rel->localrel, lockmode);
+   table_close(rel->localrel, lockmode);
    rel->localrel = NULL;
 }
 
 
                 * working and it has to open the relation in RowExclusiveLock
                 * when remapping remote relation id to local one.
                 */
-               rel = heap_open(MyLogicalRepWorker->relid, RowExclusiveLock);
+               rel = table_open(MyLogicalRepWorker->relid, RowExclusiveLock);
 
                /*
                 * Create a temporary slot for the sync process. We do this
                             errdetail("The error was: %s", res->err)));
                walrcv_clear_result(res);
 
-               heap_close(rel, NoLock);
+               table_close(rel, NoLock);
 
                /* Make the copy visible. */
                CommandCounterIncrement();
 
    /*
     * 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
    /* Post creation hook for new rule */
    InvokeObjectPostCreateHook(RewriteRelationId, rewriteObjectId, 0);
 
-   heap_close(pg_rewrite_desc, RowExclusiveLock);
+   table_close(pg_rewrite_desc, RowExclusiveLock);
 
    return rewriteObjectId;
 }
     *
     * 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.
        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  */
        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;
 }
    /*
     * 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));
    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
    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,
    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
 
                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,
                 */
                rte->relkind = rel->rd_rel->relkind;
 
-               heap_close(rel, NoLock);
+               table_close(rel, NoLock);
                break;
 
            case RTE_JOIN:
         * 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
            }
        }
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 
    /* Recurse into subqueries in WITH */
             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.
        if (hasSubLinks)
            parsetree->hasSubLinks = true;
 
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 
    return parsetree;
     * 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
        }
    }
 
-   heap_close(base_rel, NoLock);
+   table_close(base_rel, NoLock);
 
    return parsetree;
 }
         * 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.
                    (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);
    }
 
    /*
 
    /*
     * Open the pg_rewrite relation.
     */
-   RewriteRelation = heap_open(RewriteRelationId, RowExclusiveLock);
+   RewriteRelation = table_open(RewriteRelationId, RowExclusiveLock);
 
    /*
     * Find the tuple for the target rule.
     * 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
 
    systable_endscan(rcscan);
 
-   heap_close(RewriteRelation, RowExclusiveLock);
+   table_close(RewriteRelation, RowExclusiveLock);
 
    /*
     * Issue shared-inval notice to force all backends (including me!) to
    CacheInvalidateRelcache(event_relation);
 
    /* Close rel, but keep lock till commit... */
-   heap_close(event_relation, NoLock);
+   table_close(event_relation, NoLock);
 }
 
    /*
     * 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);
    }
 
    heap_freetuple(tuple);
-   heap_close(relationRelation, RowExclusiveLock);
+   table_close(relationRelation, RowExclusiveLock);
 }
 
 /*
 
     * 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;
        }
    }
 
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    /*
     * Mark this query as having row security, so plancache can invalidate it
 
                                ALLOCSET_DEFAULT_SIZES);
    oldcxt = MemoryContextSwitchTo(cxt);
 
-   pg_stext = heap_open(StatisticExtRelationId, RowExclusiveLock);
+   pg_stext = table_open(StatisticExtRelationId, RowExclusiveLock);
    stats = fetch_statentries_for_relation(pg_stext, RelationGetRelid(onerel));
 
    foreach(lc, stats)
        statext_store(pg_stext, stat->statOid, ndistinct, dependencies, stats);
    }
 
-   heap_close(pg_stext, RowExclusiveLock);
+   table_close(pg_stext, RowExclusiveLock);
 
    MemoryContextSwitchTo(oldcxt);
    MemoryContextDelete(cxt);
 
 
    /* Use RowExclusiveLock since we might either read or write */
    if (lo_heap_r == NULL)
-       lo_heap_r = heap_open(LargeObjectRelationId, RowExclusiveLock);
+       lo_heap_r = table_open(LargeObjectRelationId, RowExclusiveLock);
    if (lo_index_r == NULL)
        lo_index_r = index_open(LargeObjectLOidPNIndexId, RowExclusiveLock);
 
            if (lo_index_r)
                index_close(lo_index_r, NoLock);
            if (lo_heap_r)
-               heap_close(lo_heap_r, NoLock);
+               table_close(lo_heap_r, NoLock);
 
            CurrentResourceOwner = currentOwner;
        }
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(loid));
 
-   pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
-                          AccessShareLock);
+   pg_lo_meta = table_open(LargeObjectMetadataRelationId,
+                           AccessShareLock);
 
    sd = systable_beginscan(pg_lo_meta,
                            LargeObjectMetadataOidIndexId, true,
 
    systable_endscan(sd);
 
-   heap_close(pg_lo_meta, AccessShareLock);
+   table_close(pg_lo_meta, AccessShareLock);
 
    return retval;
 }
 
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(enumtypoid));
 
-   enum_rel = heap_open(EnumRelationId, AccessShareLock);
+   enum_rel = table_open(EnumRelationId, AccessShareLock);
    enum_idx = index_open(EnumTypIdSortOrderIndexId, AccessShareLock);
    enum_scan = systable_beginscan_ordered(enum_rel, enum_idx, NULL,
                                           1, &skey);
 
    systable_endscan_ordered(enum_scan);
    index_close(enum_idx, AccessShareLock);
-   heap_close(enum_rel, AccessShareLock);
+   table_close(enum_rel, AccessShareLock);
 
    return minmax;
 }
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(enumtypoid));
 
-   enum_rel = heap_open(EnumRelationId, AccessShareLock);
+   enum_rel = table_open(EnumRelationId, AccessShareLock);
    enum_idx = index_open(EnumTypIdSortOrderIndexId, AccessShareLock);
    enum_scan = systable_beginscan_ordered(enum_rel, enum_idx, NULL, 1, &skey);
 
 
    systable_endscan_ordered(enum_scan);
    index_close(enum_idx, AccessShareLock);
-   heap_close(enum_rel, AccessShareLock);
+   table_close(enum_rel, AccessShareLock);
 
    /* and build the result array */
    /* note this hardwires some details about the representation of Oid */
 
    Oid         idxoid;
    Relation    rel;
 
-   rel = heap_open(reloid, AccessShareLock);
+   rel = table_open(reloid, AccessShareLock);
    idxoid = RelationGetReplicaIndex(rel);
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    if (OidIsValid(idxoid))
        PG_RETURN_OID(idxoid);
 
     * SELECT FOR KEY SHARE will get on it.
     */
    fk_rel = trigdata->tg_relation;
-   pk_rel = heap_open(riinfo->pk_relid, RowShareLock);
+   pk_rel = table_open(riinfo->pk_relid, RowShareLock);
 
    if (riinfo->confmatchtype == FKCONSTR_MATCH_PARTIAL)
        ereport(ERROR,
             * No further check needed - an all-NULL key passes every type of
             * foreign key constraint.
             */
-           heap_close(pk_rel, RowShareLock);
+           table_close(pk_rel, RowShareLock);
            return PointerGetDatum(NULL);
 
        case RI_KEYS_SOME_NULL:
                             errdetail("MATCH FULL does not allow mixing of null and nonnull key values."),
                             errtableconstraint(fk_rel,
                                                NameStr(riinfo->conname))));
-                   heap_close(pk_rel, RowShareLock);
+                   table_close(pk_rel, RowShareLock);
                    return PointerGetDatum(NULL);
 
                case FKCONSTR_MATCH_SIMPLE:
                     * MATCH SIMPLE - if ANY column is null, the key passes
                     * the constraint.
                     */
-                   heap_close(pk_rel, RowShareLock);
+                   table_close(pk_rel, RowShareLock);
                    return PointerGetDatum(NULL);
 
                case FKCONSTR_MATCH_PARTIAL:
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                             errmsg("MATCH PARTIAL not yet implemented")));
-                   heap_close(pk_rel, RowShareLock);
+                   table_close(pk_rel, RowShareLock);
                    return PointerGetDatum(NULL);
 
                default:
    if (SPI_finish() != SPI_OK_FINISH)
        elog(ERROR, "SPI_finish failed");
 
-   heap_close(pk_rel, RowShareLock);
+   table_close(pk_rel, RowShareLock);
 
    return PointerGetDatum(NULL);
 }
     * fk_rel is opened in RowShareLock mode since that's what our eventual
     * SELECT FOR KEY SHARE will get on it.
     */
-   fk_rel = heap_open(riinfo->fk_relid, RowShareLock);
+   fk_rel = table_open(riinfo->fk_relid, RowShareLock);
    pk_rel = trigdata->tg_relation;
    old_row = trigdata->tg_trigtuple;
 
            if (is_no_action &&
                ri_Check_Pk_Match(pk_rel, fk_rel, old_row, riinfo))
            {
-               heap_close(fk_rel, RowShareLock);
+               table_close(fk_rel, RowShareLock);
                return PointerGetDatum(NULL);
            }
 
            if (SPI_finish() != SPI_OK_FINISH)
                elog(ERROR, "SPI_finish failed");
 
-           heap_close(fk_rel, RowShareLock);
+           table_close(fk_rel, RowShareLock);
 
            return PointerGetDatum(NULL);
 
     * fk_rel is opened in RowExclusiveLock mode since that's what our
     * eventual DELETE will get on it.
     */
-   fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+   fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
    pk_rel = trigdata->tg_relation;
    old_row = trigdata->tg_trigtuple;
 
            if (SPI_finish() != SPI_OK_FINISH)
                elog(ERROR, "SPI_finish failed");
 
-           heap_close(fk_rel, RowExclusiveLock);
+           table_close(fk_rel, RowExclusiveLock);
 
            return PointerGetDatum(NULL);
 
     * fk_rel is opened in RowExclusiveLock mode since that's what our
     * eventual UPDATE will get on it.
     */
-   fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+   fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
    pk_rel = trigdata->tg_relation;
    new_row = trigdata->tg_newtuple;
    old_row = trigdata->tg_trigtuple;
            if (SPI_finish() != SPI_OK_FINISH)
                elog(ERROR, "SPI_finish failed");
 
-           heap_close(fk_rel, RowExclusiveLock);
+           table_close(fk_rel, RowExclusiveLock);
 
            return PointerGetDatum(NULL);
 
     * fk_rel is opened in RowExclusiveLock mode since that's what our
     * eventual UPDATE will get on it.
     */
-   fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+   fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
    pk_rel = trigdata->tg_relation;
    old_row = trigdata->tg_trigtuple;
 
            if (SPI_finish() != SPI_OK_FINISH)
                elog(ERROR, "SPI_finish failed");
 
-           heap_close(fk_rel, RowExclusiveLock);
+           table_close(fk_rel, RowExclusiveLock);
 
            return PointerGetDatum(NULL);
 
     * fk_rel is opened in RowExclusiveLock mode since that's what our
     * eventual UPDATE will get on it.
     */
-   fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+   fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
    pk_rel = trigdata->tg_relation;
    old_row = trigdata->tg_trigtuple;
 
            if (SPI_finish() != SPI_OK_FINISH)
                elog(ERROR, "SPI_finish failed");
 
-           heap_close(fk_rel, RowExclusiveLock);
+           table_close(fk_rel, RowExclusiveLock);
 
            /*
             * If we just deleted or updated the PK row whose key was equal to
 
    /*
     * Fetch the pg_trigger tuple by the Oid of the trigger
     */
-   tgrel = heap_open(TriggerRelationId, AccessShareLock);
+   tgrel = table_open(TriggerRelationId, AccessShareLock);
 
    ScanKeyInit(&skey[0],
                Anum_pg_trigger_oid,
    if (!HeapTupleIsValid(ht_trig))
    {
        systable_endscan(tgscan);
-       heap_close(tgrel, AccessShareLock);
+       table_close(tgrel, AccessShareLock);
        return NULL;
    }
 
    /* Clean up */
    systable_endscan(tgscan);
 
-   heap_close(tgrel, AccessShareLock);
+   table_close(tgrel, AccessShareLock);
 
    return buf.data;
 }
    SysScanDesc scandesc;
    ScanKeyData scankey[1];
    Snapshot    snapshot = RegisterSnapshot(GetTransactionSnapshot());
-   Relation    relation = heap_open(ConstraintRelationId, AccessShareLock);
+   Relation    relation = table_open(ConstraintRelationId, AccessShareLock);
 
    ScanKeyInit(&scankey[0],
                Anum_pg_constraint_oid,
        if (missing_ok)
        {
            systable_endscan(scandesc);
-           heap_close(relation, AccessShareLock);
+           table_close(relation, AccessShareLock);
            return NULL;
        }
        elog(ERROR, "could not find tuple for constraint %u", constraintId);
 
    /* Cleanup */
    systable_endscan(scandesc);
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    return buf.data;
 }
                        column, tablerv->relname)));
 
    /* Search the dependency table for the dependent sequence */
-   depRel = heap_open(DependRelationId, AccessShareLock);
+   depRel = table_open(DependRelationId, AccessShareLock);
 
    ScanKeyInit(&key[0],
                Anum_pg_depend_refclassid,
    }
 
    systable_endscan(scan);
-   heap_close(depRel, AccessShareLock);
+   table_close(depRel, AccessShareLock);
 
    if (OidIsValid(sequenceId))
    {
    if (ev_action != NULL)
        actions = (List *) stringToNode(ev_action);
 
-   ev_relation = heap_open(ev_class, AccessShareLock);
+   ev_relation = table_open(ev_class, AccessShareLock);
 
    /*
     * Build the rules definition text
        appendStringInfoChar(buf, ';');
    }
 
-   heap_close(ev_relation, AccessShareLock);
+   table_close(ev_relation, AccessShareLock);
 }
 
 
        return;
    }
 
-   ev_relation = heap_open(ev_class, AccessShareLock);
+   ev_relation = table_open(ev_class, AccessShareLock);
 
    get_query_def(query, buf, NIL, RelationGetDescr(ev_relation),
                  prettyFlags, wrapColumn, 0);
    appendStringInfoChar(buf, ';');
 
-   heap_close(ev_relation, AccessShareLock);
+   table_close(ev_relation, AccessShareLock);
 }
 
 
 
             * already have at least AccessShareLock on the table, but not
             * necessarily on the index.
             */
-           heapRel = heap_open(rte->relid, NoLock);
+           heapRel = table_open(rte->relid, NoLock);
            indexRel = index_open(index->indexoid, AccessShareLock);
 
            /* extract index key information from the index's pg_index info */
            ExecDropSingleTupleTableSlot(slot);
 
            index_close(indexRel, AccessShareLock);
-           heap_close(heapRel, NoLock);
+           table_close(heapRel, NoLock);
 
            MemoryContextSwitchTo(oldcontext);
            FreeExecutorState(estate);
 
                    rte = rt_fetch(var->varno, query->rtable);
                    if (rte)
                    {
-                       heap_close(viewrel, AccessShareLock);
+                       table_close(viewrel, AccessShareLock);
                        return DirectFunctionCall2(currtid_byreloid, ObjectIdGetDatum(rte->relid), PointerGetDatum(tid));
                    }
                }
        PG_RETURN_ITEMPOINTER(result);
    }
 
-   rel = heap_open(reloid, AccessShareLock);
+   rel = table_open(reloid, AccessShareLock);
 
    aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
                                  ACL_SELECT);
    heap_get_latest_tid(rel, snapshot, result);
    UnregisterSnapshot(snapshot);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    PG_RETURN_ITEMPOINTER(result);
 }
    Snapshot    snapshot;
 
    relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
-   rel = heap_openrv(relrv, AccessShareLock);
+   rel = table_openrv(relrv, AccessShareLock);
 
    aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
                                  ACL_SELECT);
    heap_get_latest_tid(rel, snapshot, result);
    UnregisterSnapshot(snapshot);
 
-   heap_close(rel, AccessShareLock);
+   table_close(rel, AccessShareLock);
 
    PG_RETURN_ITEMPOINTER(result);
 }
 
    const char *result;
    Relation    rel;
 
-   rel = heap_open(relid, AccessShareLock);
+   rel = table_open(relid, AccessShareLock);
    result = map_sql_table_to_xmlschema(rel->rd_att, relid, nulls,
                                        tableforest, targetns);
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    PG_RETURN_XML_P(cstring_to_xmltype(result));
 }
    Relation    rel;
    const char *xmlschema;
 
-   rel = heap_open(relid, AccessShareLock);
+   rel = table_open(relid, AccessShareLock);
    xmlschema = map_sql_table_to_xmlschema(rel->rd_att, relid, nulls,
                                           tableforest, targetns);
-   heap_close(rel, NoLock);
+   table_close(rel, NoLock);
 
    PG_RETURN_XML_P(stringinfo_to_xmltype(table_to_xml_internal(relid,
                                                                xmlschema, nulls, tableforest,
    {
        Relation    rel;
 
-       rel = heap_open(lfirst_oid(cell), AccessShareLock);
+       rel = table_open(lfirst_oid(cell), AccessShareLock);
        tupdesc_list = lappend(tupdesc_list, CreateTupleDescCopy(rel->rd_att));
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 
    appendStringInfoString(result,
    {
        Relation    rel;
 
-       rel = heap_open(lfirst_oid(cell), AccessShareLock);
+       rel = table_open(lfirst_oid(cell), AccessShareLock);
        tupdesc_list = lappend(tupdesc_list, CreateTupleDescCopy(rel->rd_att));
-       heap_close(rel, NoLock);
+       table_close(rel, NoLock);
    }
 
    appendStringInfoString(result,
 
 
    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
     */
    MemoryContextSwitchTo(oldcxt);
 
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    CACHE3_elog(DEBUG2, "CatalogCacheInitializeCache: %s, %d keys",
                cache->cc_relname, cache->cc_nkeys);
     *
     * 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
     * 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,
 
    systable_endscan(scandesc);
 
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    /*
     * If tuple was not found, we need to build a negative cache entry
        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,
 
        systable_endscan(scandesc);
 
-       heap_close(relation, AccessShareLock);
+       table_close(relation, AccessShareLock);
 
        /* Now we can build the CatCList entry. */
        oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
 
     * 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
 
    /* all done */
    systable_endscan(pg_class_scan);
-   heap_close(pg_class_desc, AccessShareLock);
+   table_close(pg_class_desc, AccessShareLock);
 
    return pg_class_tuple;
 }
     * 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,
     * 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",
     * 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,
     * 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)
                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);
 
        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
                    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);
 
        }
 
        systable_endscan(scan);
-       heap_close(rel, AccessShareLock);
+       table_close(rel, AccessShareLock);
    }
 
    opcentry->valid = true;
    /*
     * 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)));
 
    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
                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;
    }
 
    systable_endscan(adscan);
-   heap_close(adrel, AccessShareLock);
+   table_close(adrel, AccessShareLock);
 }
 
 /*
                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);
 
    }
 
    systable_endscan(conscan);
-   heap_close(conrel, AccessShareLock);
+   table_close(conrel, AccessShareLock);
 
    if (found != ncheck)
        elog(ERROR, "%d constraint record(s) missing for rel %s",
                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);
 
    }
 
    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);
                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);
 
 
    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);
                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);
 
 
    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);
                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;
    }
 
    systable_endscan(conscan);
-   heap_close(conrel, AccessShareLock);
+   table_close(conrel, AccessShareLock);
 
    if (!found)
        elog(ERROR, "exclusion constraint record missing for rel %s",
 
         */
 
        /* 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));
        }
 
        systable_endscan(scandesc);
-       heap_close(relation, AccessShareLock);
+       table_close(relation, AccessShareLock);
 
        /* check for tables that are mapped but not shared */
        if (!found)
 
                    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);
 
        systable_endscan_ordered(mapscan);
        index_close(mapidx, AccessShareLock);
-       heap_close(maprel, AccessShareLock);
+       table_close(maprel, AccessShareLock);
 
        if (ndicts > 0)
        {
 
     * 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 (;;)
    {
        ReleaseSysCache(tup);
    }
 
-   heap_close(conRel, AccessShareLock);
+   table_close(conRel, AccessShareLock);
 
    /*
     * Only need to add one NOT NULL check regardless of how many domains in
                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,
    }
 
    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);
 
     * built the critical shared relcache entries (i.e., we're starting up
     * without a shared relcache cache file).
     */
-   relation = heap_open(DatabaseRelationId, AccessShareLock);
+   relation = table_open(DatabaseRelationId, AccessShareLock);
    scan = systable_beginscan(relation, DatabaseNameIndexId,
                              criticalSharedRelcachesBuilt,
                              NULL,
 
    /* all done */
    systable_endscan(scan);
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    return tuple;
 }
     * built the critical shared relcache entries (i.e., we're starting up
     * without a shared relcache cache file).
     */
-   relation = heap_open(DatabaseRelationId, AccessShareLock);
+   relation = table_open(DatabaseRelationId, AccessShareLock);
    scan = systable_beginscan(relation, DatabaseOidIndexId,
                              criticalSharedRelcachesBuilt,
                              NULL,
 
    /* all done */
    systable_endscan(scan);
-   heap_close(relation, AccessShareLock);
+   table_close(relation, AccessShareLock);
 
    return tuple;
 }
    if (!IsUnderPostmaster)
        return;
 
-   relsetting = heap_open(DbRoleSettingRelationId, AccessShareLock);
+   relsetting = table_open(DbRoleSettingRelationId, AccessShareLock);
 
    /* read all the settings under the same snapshot for efficiency */
    snapshot = RegisterSnapshot(GetCatalogSnapshot(DbRoleSettingRelationId));
    ApplySetting(snapshot, InvalidOid, InvalidOid, relsetting, PGC_S_GLOBAL);
 
    UnregisterSnapshot(snapshot);
-   heap_close(relsetting, AccessShareLock);
+   table_close(relsetting, AccessShareLock);
 }
 
 /*
    HeapScanDesc scan;
    bool        result;
 
-   pg_authid_rel = heap_open(AuthIdRelationId, AccessShareLock);
+   pg_authid_rel = table_open(AuthIdRelationId, AccessShareLock);
 
    scan = heap_beginscan_catalog(pg_authid_rel, 0, NULL);
    result = (heap_getnext(scan, ForwardScanDirection) != NULL);
 
    heap_endscan(scan);
-   heap_close(pg_authid_rel, AccessShareLock);
+   table_close(pg_authid_rel, AccessShareLock);
 
    return result;
 }
 
    {
        Relation    relation;
 
-       relation = heap_open(enrmd->reliddesc, NoLock);
+       relation = table_open(enrmd->reliddesc, NoLock);
        tupdesc = relation->rd_att;
-       heap_close(relation, NoLock);
+       table_close(relation, NoLock);
    }
 
    return tupdesc;