mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Some RELKIND macro refactoring
Add more macros to group some RELKIND_* macros: - RELKIND_HAS_PARTITIONS() - RELKIND_HAS_TABLESPACE() - RELKIND_HAS_TABLE_AM() Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://www.postgresql.org/message-id/flat/a574c8f1-9c84-93ad-a9e5-65233d6fc00f%40enterprisedb.com
This commit is contained in:
@@ -965,17 +965,13 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
BlockNumber relallvisible;
|
||||
double density;
|
||||
|
||||
switch (rel->rd_rel->relkind)
|
||||
if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
|
||||
{
|
||||
case RELKIND_RELATION:
|
||||
case RELKIND_MATVIEW:
|
||||
case RELKIND_TOASTVALUE:
|
||||
table_relation_estimate_size(rel, attr_widths, pages, tuples,
|
||||
allvisfrac);
|
||||
break;
|
||||
|
||||
case RELKIND_INDEX:
|
||||
|
||||
}
|
||||
else if (rel->rd_rel->relkind == RELKIND_INDEX)
|
||||
{
|
||||
/*
|
||||
* XXX: It'd probably be good to move this into a callback,
|
||||
* individual index types e.g. know if they have a metapage.
|
||||
@@ -991,7 +987,7 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
{
|
||||
*tuples = 0;
|
||||
*allvisfrac = 0;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
/* coerce values in pg_class to more desirable types */
|
||||
@@ -1055,27 +1051,18 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
*allvisfrac = 1;
|
||||
else
|
||||
*allvisfrac = (double) relallvisible / curpages;
|
||||
break;
|
||||
|
||||
case RELKIND_SEQUENCE:
|
||||
/* Sequences always have a known size */
|
||||
*pages = 1;
|
||||
*tuples = 1;
|
||||
*allvisfrac = 0;
|
||||
break;
|
||||
case RELKIND_FOREIGN_TABLE:
|
||||
/* Just use whatever's in pg_class */
|
||||
/* Note that FDW must cope if reltuples is -1! */
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just use whatever's in pg_class. This covers foreign tables,
|
||||
* sequences, and also relkinds without storage (shouldn't get
|
||||
* here?); see initializations in AddNewRelationTuple(). Note
|
||||
* that FDW must cope if reltuples is -1!
|
||||
*/
|
||||
*pages = rel->rd_rel->relpages;
|
||||
*tuples = rel->rd_rel->reltuples;
|
||||
*allvisfrac = 0;
|
||||
break;
|
||||
default:
|
||||
/* else it has no disk storage; probably shouldn't get here? */
|
||||
*pages = 0;
|
||||
*tuples = 0;
|
||||
*allvisfrac = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user