Make more use of RELKIND_HAS_STORAGE()
Make use of RELKIND_HAS_STORAGE() where appropriate, instead of listing out the relkinds individually. No behavior change intended. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/7a22bf51-2480-d999-1794-191ba67ff47c%402ndquadrant.com
This commit is contained in:
parent
7aa4fb5925
commit
ffd2582297
|
@ -1943,13 +1943,8 @@ heap_drop_with_catalog(Oid relid)
|
||||||
/*
|
/*
|
||||||
* Schedule unlinking of the relation's physical files at commit.
|
* Schedule unlinking of the relation's physical files at commit.
|
||||||
*/
|
*/
|
||||||
if (rel->rd_rel->relkind != RELKIND_VIEW &&
|
if (RELKIND_HAS_STORAGE(rel->rd_rel->relkind))
|
||||||
rel->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
|
|
||||||
rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
|
|
||||||
rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
|
|
||||||
{
|
|
||||||
RelationDropStorage(rel);
|
RelationDropStorage(rel);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close relcache entry, but *keep* AccessExclusiveLock on the relation
|
* Close relcache entry, but *keep* AccessExclusiveLock on the relation
|
||||||
|
|
|
@ -1807,11 +1807,7 @@ pgstat_initstats(Relation rel)
|
||||||
char relkind = rel->rd_rel->relkind;
|
char relkind = rel->rd_rel->relkind;
|
||||||
|
|
||||||
/* We only count stats for things that have storage */
|
/* We only count stats for things that have storage */
|
||||||
if (!(relkind == RELKIND_RELATION ||
|
if (!RELKIND_HAS_STORAGE(relkind))
|
||||||
relkind == RELKIND_MATVIEW ||
|
|
||||||
relkind == RELKIND_INDEX ||
|
|
||||||
relkind == RELKIND_TOASTVALUE ||
|
|
||||||
relkind == RELKIND_SEQUENCE))
|
|
||||||
{
|
{
|
||||||
rel->pgstat_info = NULL;
|
rel->pgstat_info = NULL;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -874,25 +874,18 @@ pg_relation_filenode(PG_FUNCTION_ARGS)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
relform = (Form_pg_class) GETSTRUCT(tuple);
|
relform = (Form_pg_class) GETSTRUCT(tuple);
|
||||||
|
|
||||||
switch (relform->relkind)
|
if (RELKIND_HAS_STORAGE(relform->relkind))
|
||||||
{
|
{
|
||||||
case RELKIND_RELATION:
|
if (relform->relfilenode)
|
||||||
case RELKIND_MATVIEW:
|
result = relform->relfilenode;
|
||||||
case RELKIND_INDEX:
|
else /* Consult the relation mapper */
|
||||||
case RELKIND_SEQUENCE:
|
result = RelationMapOidToFilenode(relid,
|
||||||
case RELKIND_TOASTVALUE:
|
relform->relisshared);
|
||||||
/* okay, these have storage */
|
}
|
||||||
if (relform->relfilenode)
|
else
|
||||||
result = relform->relfilenode;
|
{
|
||||||
else /* Consult the relation mapper */
|
/* no storage, return NULL */
|
||||||
result = RelationMapOidToFilenode(relid,
|
result = InvalidOid;
|
||||||
relform->relisshared);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/* no storage, return NULL */
|
|
||||||
result = InvalidOid;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
@ -951,38 +944,30 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
relform = (Form_pg_class) GETSTRUCT(tuple);
|
relform = (Form_pg_class) GETSTRUCT(tuple);
|
||||||
|
|
||||||
switch (relform->relkind)
|
if (RELKIND_HAS_STORAGE(relform->relkind))
|
||||||
|
{
|
||||||
|
/* This logic should match RelationInitPhysicalAddr */
|
||||||
|
if (relform->reltablespace)
|
||||||
|
rnode.spcNode = relform->reltablespace;
|
||||||
|
else
|
||||||
|
rnode.spcNode = MyDatabaseTableSpace;
|
||||||
|
if (rnode.spcNode == GLOBALTABLESPACE_OID)
|
||||||
|
rnode.dbNode = InvalidOid;
|
||||||
|
else
|
||||||
|
rnode.dbNode = MyDatabaseId;
|
||||||
|
if (relform->relfilenode)
|
||||||
|
rnode.relNode = relform->relfilenode;
|
||||||
|
else /* Consult the relation mapper */
|
||||||
|
rnode.relNode = RelationMapOidToFilenode(relid,
|
||||||
|
relform->relisshared);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
case RELKIND_RELATION:
|
|
||||||
case RELKIND_MATVIEW:
|
|
||||||
case RELKIND_INDEX:
|
|
||||||
case RELKIND_SEQUENCE:
|
|
||||||
case RELKIND_TOASTVALUE:
|
|
||||||
/* okay, these have storage */
|
|
||||||
|
|
||||||
/* This logic should match RelationInitPhysicalAddr */
|
|
||||||
if (relform->reltablespace)
|
|
||||||
rnode.spcNode = relform->reltablespace;
|
|
||||||
else
|
|
||||||
rnode.spcNode = MyDatabaseTableSpace;
|
|
||||||
if (rnode.spcNode == GLOBALTABLESPACE_OID)
|
|
||||||
rnode.dbNode = InvalidOid;
|
|
||||||
else
|
|
||||||
rnode.dbNode = MyDatabaseId;
|
|
||||||
if (relform->relfilenode)
|
|
||||||
rnode.relNode = relform->relfilenode;
|
|
||||||
else /* Consult the relation mapper */
|
|
||||||
rnode.relNode = RelationMapOidToFilenode(relid,
|
|
||||||
relform->relisshared);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/* no storage, return NULL */
|
/* no storage, return NULL */
|
||||||
rnode.relNode = InvalidOid;
|
rnode.relNode = InvalidOid;
|
||||||
/* some compilers generate warnings without these next two lines */
|
/* some compilers generate warnings without these next two lines */
|
||||||
rnode.dbNode = InvalidOid;
|
rnode.dbNode = InvalidOid;
|
||||||
rnode.spcNode = InvalidOid;
|
rnode.spcNode = InvalidOid;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OidIsValid(rnode.relNode))
|
if (!OidIsValid(rnode.relNode))
|
||||||
|
|
Loading…
Reference in New Issue