From 4098d33acb7576b13481ffc320aff1b88188582b Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Thu, 3 Dec 2020 16:31:40 +0100 Subject: [PATCH] Allow citus size functions on replicated tables --- .../distributed/metadata/metadata_utility.c | 8 -------- .../regress/expected/multi_size_queries.out | 19 ++++++++++++++++--- src/test/regress/sql/multi_size_queries.sql | 2 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/backend/distributed/metadata/metadata_utility.c b/src/backend/distributed/metadata/metadata_utility.c index 10a4ff5b6..6f4ae251f 100644 --- a/src/backend/distributed/metadata/metadata_utility.c +++ b/src/backend/distributed/metadata/metadata_utility.c @@ -367,14 +367,6 @@ ErrorIfNotSuitableToGetSize(Oid relationId) errmsg("cannot calculate the size because relation %s is not " "distributed", escapedQueryString))); } - - if (IsCitusTableType(relationId, HASH_DISTRIBUTED) && - !SingleReplicatedTable(relationId)) - { - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot calculate the size because replication factor " - "is greater than 1"))); - } } diff --git a/src/test/regress/expected/multi_size_queries.out b/src/test/regress/expected/multi_size_queries.out index 3e4961e1e..b99e897c6 100644 --- a/src/test/regress/expected/multi_size_queries.out +++ b/src/test/regress/expected/multi_size_queries.out @@ -22,12 +22,25 @@ SELECT citus_total_relation_size('non_distributed_table'); ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed DROP TABLE non_distributed_table; -- Tests on distributed table with replication factor > 1 +VACUUM (FULL) lineitem_hash_part; SELECT citus_table_size('lineitem_hash_part'); -ERROR: cannot calculate the size because replication factor is greater than 1 + citus_table_size +--------------------------------------------------------------------- + 3801088 +(1 row) + SELECT citus_relation_size('lineitem_hash_part'); -ERROR: cannot calculate the size because replication factor is greater than 1 + citus_relation_size +--------------------------------------------------------------------- + 3801088 +(1 row) + SELECT citus_total_relation_size('lineitem_hash_part'); -ERROR: cannot calculate the size because replication factor is greater than 1 + citus_total_relation_size +--------------------------------------------------------------------- + 3801088 +(1 row) + VACUUM (FULL) customer_copy_hash; -- Tests on distributed tables with streaming replication. SELECT citus_table_size('customer_copy_hash'); diff --git a/src/test/regress/sql/multi_size_queries.sql b/src/test/regress/sql/multi_size_queries.sql index 2c26dab6d..99ae6cef9 100644 --- a/src/test/regress/sql/multi_size_queries.sql +++ b/src/test/regress/sql/multi_size_queries.sql @@ -20,6 +20,8 @@ SELECT citus_total_relation_size('non_distributed_table'); DROP TABLE non_distributed_table; -- Tests on distributed table with replication factor > 1 +VACUUM (FULL) lineitem_hash_part; + SELECT citus_table_size('lineitem_hash_part'); SELECT citus_relation_size('lineitem_hash_part'); SELECT citus_total_relation_size('lineitem_hash_part');