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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Oid checkRelId = relationId;
|
ErrorIfNotSuitableToGetSize(relationId);
|
||||||
if (relation->rd_rel->relkind == RELKIND_INDEX)
|
|
||||||
{
|
|
||||||
bool missingOk = false;
|
|
||||||
checkRelId = IndexGetRelation(relation->rd_id, missingOk);
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorIfNotSuitableToGetSize(checkRelId);
|
|
||||||
|
|
||||||
table_close(relation, AccessShareLock);
|
table_close(relation, AccessShareLock);
|
||||||
|
|
||||||
|
@ -584,7 +577,7 @@ DistributedRelationSize(Oid relationId, SizeQueryType sizeQueryType,
|
||||||
/*
|
/*
|
||||||
* DistributedRelationSizeOnWorker gets the workerNode and relationId to calculate
|
* DistributedRelationSizeOnWorker gets the workerNode and relationId to calculate
|
||||||
* size of that relation on the given workerNode by summing up the size of each
|
* 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
|
static bool
|
||||||
DistributedRelationSizeOnWorker(WorkerNode *workerNode, Oid relationId,
|
DistributedRelationSizeOnWorker(WorkerNode *workerNode, Oid relationId,
|
||||||
|
@ -1050,12 +1043,32 @@ static void
|
||||||
ErrorIfNotSuitableToGetSize(Oid relationId)
|
ErrorIfNotSuitableToGetSize(Oid relationId)
|
||||||
{
|
{
|
||||||
if (!IsCitusTable(relationId))
|
if (!IsCitusTable(relationId))
|
||||||
|
{
|
||||||
|
if (get_rel_relkind(relationId) != RELKIND_INDEX)
|
||||||
{
|
{
|
||||||
char *relationName = get_rel_name(relationId);
|
char *relationName = get_rel_name(relationId);
|
||||||
char *escapedQueryString = quote_literal_cstr(relationName);
|
char *escapedQueryString = quote_literal_cstr(relationName);
|
||||||
ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||||
errmsg("cannot calculate the size because relation %s is not "
|
errmsg(
|
||||||
"distributed", escapedQueryString)));
|
"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');
|
SELECT citus_total_relation_size('non_distributed_table');
|
||||||
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
||||||
SELECT citus_table_size('non_distributed_table_pkey');
|
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');
|
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');
|
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;
|
DROP TABLE non_distributed_table;
|
||||||
-- fix broken placements via disabling the node
|
-- fix broken placements via disabling the node
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
|
|
Loading…
Reference in New Issue