From 772d1943578551a48944abb22ea22f52b0d47d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20Ozan=20Akg=C3=BCl?= Date: Tue, 13 Jun 2023 16:36:35 +0300 Subject: [PATCH] Changes citus_shard_sizes view's Shard Name Column to Shard Id (#7003) citus_shard_sizes view had a shard name column we use to extract shard id. This PR changes the column to shard id so we don't do unnecessary string operation. --- .../distributed/metadata/metadata_utility.c | 29 ++++++++----------- .../distributed/operations/stage_protocol.c | 2 +- .../distributed/sql/citus--11.3-1--12.0-1.sql | 4 +++ .../sql/downgrades/citus--12.0-1--11.3-1.sql | 8 +++++ .../sql/udfs/citus_shard_sizes/12.0-1.sql | 6 ++++ .../sql/udfs/citus_shard_sizes/latest.sql | 4 +-- .../sql/udfs/citus_shards/12.0-1.sql | 5 ++-- .../sql/udfs/citus_shards/latest.sql | 5 ++-- src/include/distributed/metadata_utility.h | 2 +- .../citus_update_table_statistics.out | 12 ++++---- .../expected/single_shard_table_udfs.out | 22 ++++++++++++-- .../regress/sql/single_shard_table_udfs.sql | 10 ++++++- 12 files changed, 74 insertions(+), 35 deletions(-) create mode 100644 src/backend/distributed/sql/udfs/citus_shard_sizes/12.0-1.sql diff --git a/src/backend/distributed/metadata/metadata_utility.c b/src/backend/distributed/metadata/metadata_utility.c index 7585769ad..a6ff93220 100644 --- a/src/backend/distributed/metadata/metadata_utility.c +++ b/src/backend/distributed/metadata/metadata_utility.c @@ -101,9 +101,9 @@ static char * GenerateAllShardStatisticsQueryForNode(WorkerNode *workerNode, static List * GenerateShardStatisticsQueryList(List *workerNodeList, List *citusTableIds); static void ErrorIfNotSuitableToGetSize(Oid relationId); static List * OpenConnectionToNodes(List *workerNodeList); -static void ReceiveShardNameAndSizeResults(List *connectionList, - Tuplestorestate *tupleStore, - TupleDesc tupleDescriptor); +static void ReceiveShardIdAndSizeResults(List *connectionList, + Tuplestorestate *tupleStore, + TupleDesc tupleDescriptor); static void AppendShardSizeQuery(StringInfo selectQuery, ShardInterval *shardInterval); static HeapTuple CreateDiskSpaceTuple(TupleDesc tupleDesc, uint64 availableBytes, @@ -253,7 +253,7 @@ GetNodeDiskSpaceStatsForConnection(MultiConnection *connection, uint64 *availabl /* - * citus_shard_sizes returns all shard names and their sizes. + * citus_shard_sizes returns all shard ids and their sizes. */ Datum citus_shard_sizes(PG_FUNCTION_ARGS) @@ -271,7 +271,7 @@ citus_shard_sizes(PG_FUNCTION_ARGS) TupleDesc tupleDescriptor = NULL; Tuplestorestate *tupleStore = SetupTuplestore(fcinfo, &tupleDescriptor); - ReceiveShardNameAndSizeResults(connectionList, tupleStore, tupleDescriptor); + ReceiveShardIdAndSizeResults(connectionList, tupleStore, tupleDescriptor); PG_RETURN_VOID(); } @@ -446,12 +446,12 @@ GenerateShardStatisticsQueryList(List *workerNodeList, List *citusTableIds) /* - * ReceiveShardNameAndSizeResults receives shard name and size results from the given + * ReceiveShardIdAndSizeResults receives shard id and size results from the given * connection list. */ static void -ReceiveShardNameAndSizeResults(List *connectionList, Tuplestorestate *tupleStore, - TupleDesc tupleDescriptor) +ReceiveShardIdAndSizeResults(List *connectionList, Tuplestorestate *tupleStore, + TupleDesc tupleDescriptor) { MultiConnection *connection = NULL; foreach_ptr(connection, connectionList) @@ -488,13 +488,9 @@ ReceiveShardNameAndSizeResults(List *connectionList, Tuplestorestate *tupleStore memset(values, 0, sizeof(values)); memset(isNulls, false, sizeof(isNulls)); - /* format is [0] shard id, [1] shard name, [2] size */ - char *tableName = PQgetvalue(result, rowIndex, 1); - Datum resultStringDatum = CStringGetDatum(tableName); - Datum textDatum = DirectFunctionCall1(textin, resultStringDatum); - - values[0] = textDatum; - values[1] = ParseIntField(result, rowIndex, 2); + /* format is [0] shard id, [1] size */ + values[0] = ParseIntField(result, rowIndex, 0); + values[1] = ParseIntField(result, rowIndex, 1); tuplestore_putvalues(tupleStore, tupleDescriptor, values, isNulls); } @@ -942,7 +938,7 @@ GenerateAllShardStatisticsQueryForNode(WorkerNode *workerNode, List *citusTableI } /* Add a dummy entry so that UNION ALL doesn't complain */ - appendStringInfo(allShardStatisticsQuery, "SELECT 0::bigint, NULL::text, 0::bigint;"); + appendStringInfo(allShardStatisticsQuery, "SELECT 0::bigint, 0::bigint;"); return allShardStatisticsQuery->data; } @@ -986,7 +982,6 @@ AppendShardSizeQuery(StringInfo selectQuery, ShardInterval *shardInterval) char *quotedShardName = quote_literal_cstr(shardQualifiedName); appendStringInfo(selectQuery, "SELECT " UINT64_FORMAT " AS shard_id, ", shardId); - appendStringInfo(selectQuery, "%s AS shard_name, ", quotedShardName); appendStringInfo(selectQuery, PG_TOTAL_RELATION_SIZE_FUNCTION, quotedShardName); } diff --git a/src/backend/distributed/operations/stage_protocol.c b/src/backend/distributed/operations/stage_protocol.c index db7ebefca..ddab3453b 100644 --- a/src/backend/distributed/operations/stage_protocol.c +++ b/src/backend/distributed/operations/stage_protocol.c @@ -863,7 +863,7 @@ ProcessShardStatisticsRow(PGresult *result, int64 rowIndex, uint64 *shardId, return false; } - *shardSize = ParseIntField(result, rowIndex, 2); + *shardSize = ParseIntField(result, rowIndex, 1); return true; } diff --git a/src/backend/distributed/sql/citus--11.3-1--12.0-1.sql b/src/backend/distributed/sql/citus--11.3-1--12.0-1.sql index 705f68a88..90ff57412 100644 --- a/src/backend/distributed/sql/citus--11.3-1--12.0-1.sql +++ b/src/backend/distributed/sql/citus--11.3-1--12.0-1.sql @@ -24,6 +24,10 @@ GRANT SELECT ON pg_catalog.pg_dist_tenant_schema TO public; #include "udfs/citus_internal_unregister_tenant_schema_globally/12.0-1.sql" #include "udfs/citus_drop_trigger/12.0-1.sql" +DROP VIEW citus_shards; +DROP FUNCTION citus_shard_sizes; +#include "udfs/citus_shard_sizes/12.0-1.sql" + #include "udfs/citus_tables/12.0-1.sql" #include "udfs/citus_shards/12.0-1.sql" diff --git a/src/backend/distributed/sql/downgrades/citus--12.0-1--11.3-1.sql b/src/backend/distributed/sql/downgrades/citus--12.0-1--11.3-1.sql index 104c16d7a..66e1001eb 100644 --- a/src/backend/distributed/sql/downgrades/citus--12.0-1--11.3-1.sql +++ b/src/backend/distributed/sql/downgrades/citus--12.0-1--11.3-1.sql @@ -43,6 +43,14 @@ DROP FUNCTION pg_catalog.citus_internal_unregister_tenant_schema_globally(Oid, t #include "../udfs/citus_drop_trigger/10.2-1.sql" +DROP VIEW pg_catalog.citus_shards; +DROP FUNCTION pg_catalog.citus_shard_sizes; +#include "../udfs/citus_shard_sizes/10.0-1.sql" +-- citus_shards/11.1-1.sql tries to create citus_shards in pg_catalog but it is not allowed. +-- Here we use citus_shards/10.0-1.sql to properly create the view in citus schema and +-- then alter it to pg_catalog, so citus_shards/11.1-1.sql can REPLACE it without any errors. +#include "../udfs/citus_shards/10.0-1.sql" + #include "../udfs/citus_tables/11.1-1.sql" #include "../udfs/citus_shards/11.1-1.sql" diff --git a/src/backend/distributed/sql/udfs/citus_shard_sizes/12.0-1.sql b/src/backend/distributed/sql/udfs/citus_shard_sizes/12.0-1.sql new file mode 100644 index 000000000..3a647a57b --- /dev/null +++ b/src/backend/distributed/sql/udfs/citus_shard_sizes/12.0-1.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE FUNCTION pg_catalog.citus_shard_sizes(OUT shard_id int, OUT size bigint) + RETURNS SETOF RECORD + LANGUAGE C STRICT + AS 'MODULE_PATHNAME', $$citus_shard_sizes$$; + COMMENT ON FUNCTION pg_catalog.citus_shard_sizes(OUT shard_id int, OUT size bigint) + IS 'returns shards sizes across citus cluster'; diff --git a/src/backend/distributed/sql/udfs/citus_shard_sizes/latest.sql b/src/backend/distributed/sql/udfs/citus_shard_sizes/latest.sql index fd619b0a2..3a647a57b 100644 --- a/src/backend/distributed/sql/udfs/citus_shard_sizes/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_shard_sizes/latest.sql @@ -1,6 +1,6 @@ -CREATE FUNCTION pg_catalog.citus_shard_sizes(OUT table_name text, OUT size bigint) +CREATE OR REPLACE FUNCTION pg_catalog.citus_shard_sizes(OUT shard_id int, OUT size bigint) RETURNS SETOF RECORD LANGUAGE C STRICT AS 'MODULE_PATHNAME', $$citus_shard_sizes$$; - COMMENT ON FUNCTION pg_catalog.citus_shard_sizes(OUT table_name text, OUT size bigint) + COMMENT ON FUNCTION pg_catalog.citus_shard_sizes(OUT shard_id int, OUT size bigint) IS 'returns shards sizes across citus cluster'; diff --git a/src/backend/distributed/sql/udfs/citus_shards/12.0-1.sql b/src/backend/distributed/sql/udfs/citus_shards/12.0-1.sql index 8215ab64a..be9b25167 100644 --- a/src/backend/distributed/sql/udfs/citus_shards/12.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_shards/12.0-1.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE VIEW pg_catalog.citus_shards AS +CREATE OR REPLACE VIEW citus.citus_shards AS SELECT pg_dist_shard.logicalrelid AS table_name, pg_dist_shard.shardid, @@ -27,7 +27,7 @@ JOIN ON pg_dist_partition.logicalrelid = pg_dist_shard.logicalrelid LEFT JOIN - (SELECT (regexp_matches(table_name,'_(\d+)$'))[1]::int as shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes + (SELECT shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes ON pg_dist_shard.shardid = shard_sizes.shard_id WHERE @@ -46,4 +46,5 @@ ORDER BY pg_dist_shard.logicalrelid::text, shardid ; +ALTER VIEW citus.citus_shards SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_shards TO public; diff --git a/src/backend/distributed/sql/udfs/citus_shards/latest.sql b/src/backend/distributed/sql/udfs/citus_shards/latest.sql index 8215ab64a..be9b25167 100644 --- a/src/backend/distributed/sql/udfs/citus_shards/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_shards/latest.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE VIEW pg_catalog.citus_shards AS +CREATE OR REPLACE VIEW citus.citus_shards AS SELECT pg_dist_shard.logicalrelid AS table_name, pg_dist_shard.shardid, @@ -27,7 +27,7 @@ JOIN ON pg_dist_partition.logicalrelid = pg_dist_shard.logicalrelid LEFT JOIN - (SELECT (regexp_matches(table_name,'_(\d+)$'))[1]::int as shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes + (SELECT shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes ON pg_dist_shard.shardid = shard_sizes.shard_id WHERE @@ -46,4 +46,5 @@ ORDER BY pg_dist_shard.logicalrelid::text, shardid ; +ALTER VIEW citus.citus_shards SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_shards TO public; diff --git a/src/include/distributed/metadata_utility.h b/src/include/distributed/metadata_utility.h index abed55e48..473d105e8 100644 --- a/src/include/distributed/metadata_utility.h +++ b/src/include/distributed/metadata_utility.h @@ -41,7 +41,7 @@ #define WORKER_PARTITIONED_RELATION_TOTAL_SIZE_FUNCTION \ "worker_partitioned_relation_total_size(%s)" -#define SHARD_SIZES_COLUMN_COUNT (3) +#define SHARD_SIZES_COLUMN_COUNT (2) /* * Flag to keep track of whether the process is currently in a function converting the diff --git a/src/test/regress/expected/citus_update_table_statistics.out b/src/test/regress/expected/citus_update_table_statistics.out index d908e433d..a8f90945b 100644 --- a/src/test/regress/expected/citus_update_table_statistics.out +++ b/src/test/regress/expected/citus_update_table_statistics.out @@ -64,15 +64,15 @@ SET citus.multi_shard_modify_mode TO sequential; SELECT citus_update_table_statistics('test_table_statistics_hash'); NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(xx, xx, 'xxxxxxx'); DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT 0::bigint, NULL::text, 0::bigint; +NOTICE: issuing SELECT 0::bigint, 0::bigint; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(xx, xx, 'xxxxxxx'); DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT 981000 AS shard_id, 'public.test_table_statistics_hash_981000' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981000') UNION ALL SELECT 981001 AS shard_id, 'public.test_table_statistics_hash_981001' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981001') UNION ALL SELECT 981002 AS shard_id, 'public.test_table_statistics_hash_981002' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981002') UNION ALL SELECT 981003 AS shard_id, 'public.test_table_statistics_hash_981003' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981003') UNION ALL SELECT 981004 AS shard_id, 'public.test_table_statistics_hash_981004' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981004') UNION ALL SELECT 981005 AS shard_id, 'public.test_table_statistics_hash_981005' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981005') UNION ALL SELECT 981006 AS shard_id, 'public.test_table_statistics_hash_981006' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981006') UNION ALL SELECT 981007 AS shard_id, 'public.test_table_statistics_hash_981007' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981007') UNION ALL SELECT 0::bigint, NULL::text, 0::bigint; +NOTICE: issuing SELECT 981000 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981000') UNION ALL SELECT 981001 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981001') UNION ALL SELECT 981002 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981002') UNION ALL SELECT 981003 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981003') UNION ALL SELECT 981004 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981004') UNION ALL SELECT 981005 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981005') UNION ALL SELECT 981006 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981006') UNION ALL SELECT 981007 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981007') UNION ALL SELECT 0::bigint, 0::bigint; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(xx, xx, 'xxxxxxx'); DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT 981000 AS shard_id, 'public.test_table_statistics_hash_981000' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981000') UNION ALL SELECT 981001 AS shard_id, 'public.test_table_statistics_hash_981001' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981001') UNION ALL SELECT 981002 AS shard_id, 'public.test_table_statistics_hash_981002' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981002') UNION ALL SELECT 981003 AS shard_id, 'public.test_table_statistics_hash_981003' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981003') UNION ALL SELECT 981004 AS shard_id, 'public.test_table_statistics_hash_981004' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981004') UNION ALL SELECT 981005 AS shard_id, 'public.test_table_statistics_hash_981005' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981005') UNION ALL SELECT 981006 AS shard_id, 'public.test_table_statistics_hash_981006' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981006') UNION ALL SELECT 981007 AS shard_id, 'public.test_table_statistics_hash_981007' AS shard_name, pg_total_relation_size('public.test_table_statistics_hash_981007') UNION ALL SELECT 0::bigint, NULL::text, 0::bigint; +NOTICE: issuing SELECT 981000 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981000') UNION ALL SELECT 981001 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981001') UNION ALL SELECT 981002 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981002') UNION ALL SELECT 981003 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981003') UNION ALL SELECT 981004 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981004') UNION ALL SELECT 981005 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981005') UNION ALL SELECT 981006 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981006') UNION ALL SELECT 981007 AS shard_id, pg_total_relation_size('public.test_table_statistics_hash_981007') UNION ALL SELECT 0::bigint, 0::bigint; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx @@ -158,15 +158,15 @@ SET citus.multi_shard_modify_mode TO sequential; SELECT citus_update_table_statistics('test_table_statistics_append'); NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(xx, xx, 'xxxxxxx'); DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT 0::bigint, NULL::text, 0::bigint; +NOTICE: issuing SELECT 0::bigint, 0::bigint; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(xx, xx, 'xxxxxxx'); DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT 981008 AS shard_id, 'public.test_table_statistics_append_981008' AS shard_name, pg_total_relation_size('public.test_table_statistics_append_981008') UNION ALL SELECT 981009 AS shard_id, 'public.test_table_statistics_append_981009' AS shard_name, pg_total_relation_size('public.test_table_statistics_append_981009') UNION ALL SELECT 0::bigint, NULL::text, 0::bigint; +NOTICE: issuing SELECT 981008 AS shard_id, pg_total_relation_size('public.test_table_statistics_append_981008') UNION ALL SELECT 981009 AS shard_id, pg_total_relation_size('public.test_table_statistics_append_981009') UNION ALL SELECT 0::bigint, 0::bigint; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(xx, xx, 'xxxxxxx'); DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT 981008 AS shard_id, 'public.test_table_statistics_append_981008' AS shard_name, pg_total_relation_size('public.test_table_statistics_append_981008') UNION ALL SELECT 981009 AS shard_id, 'public.test_table_statistics_append_981009' AS shard_name, pg_total_relation_size('public.test_table_statistics_append_981009') UNION ALL SELECT 0::bigint, NULL::text, 0::bigint; +NOTICE: issuing SELECT 981008 AS shard_id, pg_total_relation_size('public.test_table_statistics_append_981008') UNION ALL SELECT 981009 AS shard_id, pg_total_relation_size('public.test_table_statistics_append_981009') UNION ALL SELECT 0::bigint, 0::bigint; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx diff --git a/src/test/regress/expected/single_shard_table_udfs.out b/src/test/regress/expected/single_shard_table_udfs.out index 78b4ee25a..5d3314070 100644 --- a/src/test/regress/expected/single_shard_table_udfs.out +++ b/src/test/regress/expected/single_shard_table_udfs.out @@ -76,10 +76,11 @@ SELECT citus_relation_size('null_dist_key_table'); 8192 (1 row) -SELECT * FROM pg_catalog.citus_shard_sizes() WHERE table_name LIKE '%null_dist_key_table%'; - table_name | size +SELECT shard_name, shard_size FROM pg_catalog.citus_shard_sizes(), citus_shards +WHERE shardid = shard_id AND shard_name LIKE '%null_dist_key_table%' AND nodeport IN (:worker_1_port, :worker_2_port); + shard_name | shard_size --------------------------------------------------------------------- - null_dist_key_udfs.null_dist_key_table_1820000 | 24576 + null_dist_key_udfs.null_dist_key_table_1820000 | 24576 (1 row) BEGIN; @@ -1302,5 +1303,20 @@ SELECT :logseq = :txnlog; t (1 row) +-- test table with space in its name in citus_shards +CREATE TABLE "t b l" (a INT); +SELECT create_distributed_table('"t b l"', NULL, colocate_with:='none'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +SELECT table_name, shard_size FROM citus_shards +WHERE table_name = '"t b l"'::regclass AND nodeport IN (:worker_1_port, :worker_2_port); + table_name | shard_size +--------------------------------------------------------------------- + "t b l" | 0 +(1 row) + SET client_min_messages TO WARNING; DROP SCHEMA null_dist_key_udfs CASCADE; diff --git a/src/test/regress/sql/single_shard_table_udfs.sql b/src/test/regress/sql/single_shard_table_udfs.sql index aac01f085..0e516e107 100644 --- a/src/test/regress/sql/single_shard_table_udfs.sql +++ b/src/test/regress/sql/single_shard_table_udfs.sql @@ -58,7 +58,8 @@ CREATE INDEX null_dist_key_idx ON null_dist_key_table(a); SELECT citus_table_size('null_dist_key_table'); SELECT citus_total_relation_size('null_dist_key_table'); SELECT citus_relation_size('null_dist_key_table'); -SELECT * FROM pg_catalog.citus_shard_sizes() WHERE table_name LIKE '%null_dist_key_table%'; +SELECT shard_name, shard_size FROM pg_catalog.citus_shard_sizes(), citus_shards +WHERE shardid = shard_id AND shard_name LIKE '%null_dist_key_table%' AND nodeport IN (:worker_1_port, :worker_2_port); BEGIN; SELECT lock_relation_if_exists('null_dist_key_table', 'ACCESS SHARE'); @@ -654,5 +655,12 @@ WHERE nodeport = :clock_shard_nodeport \gset SELECT cluster_clock_logical(:'txnclock') as txnlog \gset SELECT :logseq = :txnlog; +-- test table with space in its name in citus_shards +CREATE TABLE "t b l" (a INT); +SELECT create_distributed_table('"t b l"', NULL, colocate_with:='none'); + +SELECT table_name, shard_size FROM citus_shards +WHERE table_name = '"t b l"'::regclass AND nodeport IN (:worker_1_port, :worker_2_port); + SET client_min_messages TO WARNING; DROP SCHEMA null_dist_key_udfs CASCADE;