mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -306,9 +306,7 @@ verify_heapam(PG_FUNCTION_ARGS)
|
||||
/*
|
||||
* Check that a relation's relkind and access method are both supported.
|
||||
*/
|
||||
if (ctx.rel->rd_rel->relkind != RELKIND_RELATION &&
|
||||
ctx.rel->rd_rel->relkind != RELKIND_MATVIEW &&
|
||||
ctx.rel->rd_rel->relkind != RELKIND_TOASTVALUE &&
|
||||
if (!RELKIND_HAS_TABLE_AM(ctx.rel->rd_rel->relkind) &&
|
||||
ctx.rel->rd_rel->relkind != RELKIND_SEQUENCE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
|
@@ -103,9 +103,7 @@ heap_force_common(FunctionCallInfo fcinfo, HeapTupleForceOption heap_force_opt)
|
||||
/*
|
||||
* Check target relation.
|
||||
*/
|
||||
if (rel->rd_rel->relkind != RELKIND_RELATION &&
|
||||
rel->rd_rel->relkind != RELKIND_MATVIEW &&
|
||||
rel->rd_rel->relkind != RELKIND_TOASTVALUE)
|
||||
if (!RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot operate on relation \"%s\"",
|
||||
|
@@ -776,9 +776,7 @@ tuple_all_visible(HeapTuple tup, TransactionId OldestXmin, Buffer buffer)
|
||||
static void
|
||||
check_relation_relkind(Relation rel)
|
||||
{
|
||||
if (rel->rd_rel->relkind != RELKIND_RELATION &&
|
||||
rel->rd_rel->relkind != RELKIND_MATVIEW &&
|
||||
rel->rd_rel->relkind != RELKIND_TOASTVALUE)
|
||||
if (!RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("relation \"%s\" is of wrong relation kind",
|
||||
|
@@ -252,14 +252,13 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot access temporary tables of other sessions")));
|
||||
|
||||
switch (rel->rd_rel->relkind)
|
||||
if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind) ||
|
||||
rel->rd_rel->relkind == RELKIND_SEQUENCE)
|
||||
{
|
||||
case RELKIND_RELATION:
|
||||
case RELKIND_MATVIEW:
|
||||
case RELKIND_TOASTVALUE:
|
||||
case RELKIND_SEQUENCE:
|
||||
return pgstat_heap(rel, fcinfo);
|
||||
case RELKIND_INDEX:
|
||||
}
|
||||
else if (rel->rd_rel->relkind == RELKIND_INDEX)
|
||||
{
|
||||
switch (rel->rd_rel->relam)
|
||||
{
|
||||
case BTREE_AM_OID:
|
||||
@@ -288,9 +287,9 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("index \"%s\" (%s) is not supported",
|
||||
RelationGetRelationName(rel), err)));
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot get tuple-level statistics for relation \"%s\"",
|
||||
|
Reference in New Issue
Block a user