mirror of https://github.com/citusdata/citus.git
Do the index check in the dedicated check function
And minor indentation fixes, removed old comment, update tests.remotes/c2main/clean-6496
parent
795b0d82ee
commit
6dfc402ace
|
@ -547,14 +547,7 @@ DistributedRelationSize(Oid relationId, SizeQueryType sizeQueryType,
|
|||
return false;
|
||||
}
|
||||
|
||||
Oid checkRelId = relationId;
|
||||
if (relation->rd_rel->relkind == RELKIND_INDEX)
|
||||
{
|
||||
bool missingOk = false;
|
||||
checkRelId = IndexGetRelation(relation->rd_id, missingOk);
|
||||
}
|
||||
|
||||
ErrorIfNotSuitableToGetSize(checkRelId);
|
||||
ErrorIfNotSuitableToGetSize(relationId);
|
||||
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
|
@ -584,7 +577,7 @@ DistributedRelationSize(Oid relationId, SizeQueryType sizeQueryType,
|
|||
/*
|
||||
* DistributedRelationSizeOnWorker gets the workerNode and relationId to calculate
|
||||
* size of that relation on the given workerNode by summing up the size of each
|
||||
* shard placement. If indexId is defined then the relation is an index.
|
||||
* shard placement.
|
||||
*/
|
||||
static bool
|
||||
DistributedRelationSizeOnWorker(WorkerNode *workerNode, Oid relationId,
|
||||
|
@ -604,12 +597,12 @@ DistributedRelationSizeOnWorker(WorkerNode *workerNode, Oid relationId,
|
|||
PGresult *result = NULL;
|
||||
|
||||
/* if the relation is an index, update relationId and define indexId */
|
||||
Oid indexId = InvalidOid;
|
||||
Oid indexId = InvalidOid;
|
||||
if (get_rel_relkind(relationId) == RELKIND_INDEX)
|
||||
{
|
||||
indexId = relationId;
|
||||
|
||||
bool missingOk = false;
|
||||
bool missingOk = false;
|
||||
relationId = IndexGetRelation(indexId, missingOk);
|
||||
}
|
||||
|
||||
|
@ -1051,11 +1044,31 @@ ErrorIfNotSuitableToGetSize(Oid relationId)
|
|||
{
|
||||
if (!IsCitusTable(relationId))
|
||||
{
|
||||
char *relationName = get_rel_name(relationId);
|
||||
char *escapedQueryString = quote_literal_cstr(relationName);
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
errmsg("cannot calculate the size because relation %s is not "
|
||||
"distributed", escapedQueryString)));
|
||||
if (get_rel_relkind(relationId) != RELKIND_INDEX)
|
||||
{
|
||||
char *relationName = get_rel_name(relationId);
|
||||
char *escapedQueryString = quote_literal_cstr(relationName);
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
errmsg(
|
||||
"cannot calculate the size because relation %s "
|
||||
"is not distributed",
|
||||
escapedQueryString)));
|
||||
}
|
||||
bool missingOk = false;
|
||||
Oid indexId = relationId;
|
||||
relationId = IndexGetRelation(relationId, missingOk);
|
||||
if (!IsCitusTable(relationId))
|
||||
{
|
||||
char *tableName = get_rel_name(relationId);
|
||||
char *escapedTableName = quote_literal_cstr(tableName);
|
||||
char *indexName = get_rel_name(indexId);
|
||||
char *escapedIndexName = quote_literal_cstr(indexName);
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg(
|
||||
"cannot calculate the size because table %s for "
|
||||
"index %s is not distributed",
|
||||
escapedTableName, escapedIndexName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ ERROR: cannot calculate the size because relation 'non_distributed_table' is no
|
|||
SELECT citus_total_relation_size('non_distributed_table');
|
||||
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
||||
SELECT citus_table_size('non_distributed_table_pkey');
|
||||
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
||||
ERROR: cannot calculate the size because table 'non_distributed_table' for index 'non_distributed_table_pkey' is not distributed
|
||||
SELECT citus_relation_size('non_distributed_table_pkey');
|
||||
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
||||
ERROR: cannot calculate the size because table 'non_distributed_table' for index 'non_distributed_table_pkey' is not distributed
|
||||
SELECT citus_total_relation_size('non_distributed_table_pkey');
|
||||
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
||||
ERROR: cannot calculate the size because table 'non_distributed_table' for index 'non_distributed_table_pkey' is not distributed
|
||||
DROP TABLE non_distributed_table;
|
||||
-- fix broken placements via disabling the node
|
||||
SET client_min_messages TO ERROR;
|
||||
|
|
Loading…
Reference in New Issue