diff --git a/sql/views.sql b/sql/views.sql index 35f8361aa..6ca667206 100644 --- a/sql/views.sql +++ b/sql/views.sql @@ -249,7 +249,7 @@ AS CREATE OR REPLACE VIEW timescaledb_information.data_node AS SELECT s.node_name, s.owner, s.options, s.node_up, - COUNT(s.node_name) AS num_dist_tables, + COUNT(size.table_name) AS num_dist_tables, SUM(size.num_chunks) AS num_dist_chunks, pg_size_pretty(SUM(size.total_bytes)) AS total_dist_size FROM (SELECT srvname AS node_name, srvowner::regrole::name AS owner, srvoptions AS options, _timescaledb_internal.ping_data_node(srvname) AS node_up diff --git a/tsl/src/dist_util.c b/tsl/src/dist_util.c index 508ba54f9..e5bc2a2f4 100644 --- a/tsl/src/dist_util.c +++ b/tsl/src/dist_util.c @@ -178,7 +178,7 @@ dist_util_remote_hypertable_info(PG_FUNCTION_ARGS) funcctx = SRF_PERCALL_SETUP(); result = ts_dist_cmd_get_data_node_result(funcctx->user_fctx, node_name); - if (funcctx->call_cntr < PQntuples((PGresult *) funcctx->user_fctx)) + if (funcctx->call_cntr < PQntuples(result)) { HeapTuple tuple; char **fields = palloc(sizeof(char *) * PQnfields(result)); diff --git a/tsl/test/expected/data_node.out b/tsl/test/expected/data_node.out index 5616c26b5..748686ec6 100644 --- a/tsl/test/expected/data_node.out +++ b/tsl/test/expected/data_node.out @@ -91,10 +91,10 @@ NOTICE: adding user mapping for "default_cluster_user" to connect to "data_node SELECT * FROM timescaledb_information.data_node; node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size -------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- - data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 1 | | - data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 1 | | - data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 1 | | - data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 1 | | + data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 0 | | + data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 0 | | + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 0 | | + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 0 | | (4 rows) RESET ROLE; @@ -132,9 +132,9 @@ NOTICE: drop cascades to user mapping for default_cluster_user on server data_n SELECT * FROM timescaledb_information.data_node; node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size -------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- - data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 1 | | - data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 1 | | - data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 1 | | + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 0 | | + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 0 | | + data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 0 | | (3 rows) RESET ROLE; @@ -166,9 +166,9 @@ NOTICE: data node "data_node_3" does not exist, skipping SELECT * FROM timescaledb_information.data_node; node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size -------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- - data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 1 | | - data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 1 | | - data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 1 | | + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 0 | | + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 0 | | + data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 0 | | (3 rows) DROP SERVER data_node_1 CASCADE; @@ -234,9 +234,9 @@ NOTICE: adding user mapping for "default_cluster_user" to connect to "data_node SELECT * FROM timescaledb_information.data_node; node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size -------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- - data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 1 | | - data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 1 | | - data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 1 | | + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 0 | | + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 0 | | + data_node_4 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_4} | t | 0 | | (3 rows) -- Switch to default user diff --git a/tsl/test/expected/hypertable_distributed-11.out b/tsl/test/expected/hypertable_distributed-11.out index a2a03e624..335674009 100644 --- a/tsl/test/expected/hypertable_distributed-11.out +++ b/tsl/test/expected/hypertable_distributed-11.out @@ -59,6 +59,15 @@ NOTICE: adding user mapping for "default_cluster_user" to connect to "data_node data_node_3 | localhost | 15432 | data_node_3 | t | t | t (1 row) +-- Verify lack of tables +SELECT * FROM timescaledb_information.data_node; + node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size +-------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- + data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 0 | | + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 0 | | + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 0 | | +(3 rows) + -- Create distributed hypertables. Add a trigger and primary key -- constraint to test how those work CREATE TABLE disttable(time timestamptz, device int CHECK (device > 0), color int, temp float, PRIMARY KEY (time,device)); @@ -388,9 +397,9 @@ Sun Jul 01 08:01:00 2018 PDT| 29| 1.5 SELECT * FROM timescaledb_information.data_node; node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size -------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- - data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 1 | 2 | 112 kB - data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 1 | 2 | 112 kB - data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 1 | 2 | 112 kB + data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 2 | 2 | 112 kB + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 2 | 2 | 112 kB + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 2 | 2 | 112 kB (3 rows) SELECT * FROM hypertable_data_node_relation_size('disttable'); @@ -1207,7 +1216,7 @@ ORDER BY table_schema, table_name; table_schema | table_name | table_owner | num_dimensions | num_chunks | table_size | index_size | toast_size | total_size | distributed --------------+-----------------+----------------------+----------------+------------+------------+------------+------------+------------+------------- public | disttable | default_cluster_user | 2 | 9 | 72 kB | 720 kB | | 792 kB | t - public | underreplicated | default_cluster_user | 1 | 1 | | | | | t + public | underreplicated | default_cluster_user | 1 | 1 | 24 kB | 48 kB | | 72 kB | t (2 rows) -- Test distributed hypertable creation with many parameters diff --git a/tsl/test/expected/hypertable_distributed-12.out b/tsl/test/expected/hypertable_distributed-12.out index 2d572be5b..3e4f7e537 100644 --- a/tsl/test/expected/hypertable_distributed-12.out +++ b/tsl/test/expected/hypertable_distributed-12.out @@ -59,6 +59,15 @@ NOTICE: adding user mapping for "default_cluster_user" to connect to "data_node data_node_3 | localhost | 15432 | data_node_3 | t | t | t (1 row) +-- Verify lack of tables +SELECT * FROM timescaledb_information.data_node; + node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size +-------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- + data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 0 | | + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 0 | | + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 0 | | +(3 rows) + -- Create distributed hypertables. Add a trigger and primary key -- constraint to test how those work CREATE TABLE disttable(time timestamptz, device int CHECK (device > 0), color int, temp float, PRIMARY KEY (time,device)); @@ -388,9 +397,9 @@ Sun Jul 01 08:01:00 2018 PDT| 29| 1.5 SELECT * FROM timescaledb_information.data_node; node_name | owner | options | node_up | num_dist_tables | num_dist_chunks | total_dist_size -------------+----------------------+------------------------------------------------+---------+-----------------+-----------------+----------------- - data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 1 | 2 | 112 kB - data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 1 | 2 | 112 kB - data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 1 | 2 | 112 kB + data_node_3 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_3} | t | 2 | 2 | 112 kB + data_node_1 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_1} | t | 2 | 2 | 112 kB + data_node_2 | default_cluster_user | {host=localhost,port=15432,dbname=data_node_2} | t | 2 | 2 | 112 kB (3 rows) SELECT * FROM hypertable_data_node_relation_size('disttable'); @@ -1207,7 +1216,7 @@ ORDER BY table_schema, table_name; table_schema | table_name | table_owner | num_dimensions | num_chunks | table_size | index_size | toast_size | total_size | distributed --------------+-----------------+----------------------+----------------+------------+------------+------------+------------+------------+------------- public | disttable | default_cluster_user | 2 | 9 | 72 kB | 720 kB | | 792 kB | t - public | underreplicated | default_cluster_user | 1 | 1 | | | | | t + public | underreplicated | default_cluster_user | 1 | 1 | 24 kB | 48 kB | | 72 kB | t (2 rows) -- Test distributed hypertable creation with many parameters diff --git a/tsl/test/sql/hypertable_distributed.sql.in b/tsl/test/sql/hypertable_distributed.sql.in index 2bf7f13cd..c94e816d9 100644 --- a/tsl/test/sql/hypertable_distributed.sql.in +++ b/tsl/test/sql/hypertable_distributed.sql.in @@ -40,6 +40,9 @@ SELECT * FROM add_data_node('data_node_3', bootstrap_user => :'ROLE_CLUSTER_SUPERUSER', bootstrap_password => :'ROLE_CLUSTER_SUPERUSER_PASS'); +-- Verify lack of tables +SELECT * FROM timescaledb_information.data_node; + -- Create distributed hypertables. Add a trigger and primary key -- constraint to test how those work CREATE TABLE disttable(time timestamptz, device int CHECK (device > 0), color int, temp float, PRIMARY KEY (time,device));