timescaledb/test/expected/relocate_extension.out
Stephen Polcyn 1dc1850793 Drop_chunks returns list of dropped chunks
Previously, drop_chunks returned an empty table, giving the user
no indication of what (if anything) had happened.
Now, drop_chunks returns a list of the chunks identifiers in the
same style as show_chunks, with the chunk's schema and table name.

Notably, when show_chunks is called directly before drop_chunks, the
output should be the same.
2019-07-19 12:13:24 -04:00

182 lines
7.9 KiB
Plaintext

-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
-- Set this variable to avoid using a hard-coded path each time query
-- results are compared
\set QUERY_RESULT_TEST_EQUAL_RELPATH 'include/query_result_test_equal.sql'
\c postgres :ROLE_SUPERUSER
DROP DATABASE :TEST_DBNAME;
CREATE DATABASE :TEST_DBNAME;
\c :TEST_DBNAME
CREATE SCHEMA "testSchema0";
SET client_min_messages=error;
CREATE EXTENSION IF NOT EXISTS timescaledb SCHEMA "testSchema0";
RESET client_min_messages;
SET timescaledb.disable_optimizations = :DISABLE_OPTIMIZATIONS;
CREATE TABLE test_ts(time timestamp, temp float8, device text);
CREATE TABLE test_tz(time timestamptz, temp float8, device text);
CREATE TABLE test_dt(time date, temp float8, device text);
SELECT "testSchema0".create_hypertable('test_ts', 'time', 'device', 2);
NOTICE: adding not-null constraint to column "time"
create_hypertable
----------------------
(1,public,test_ts,t)
(1 row)
SELECT "testSchema0".create_hypertable('test_tz', 'time', 'device', 2);
NOTICE: adding not-null constraint to column "time"
create_hypertable
----------------------
(2,public,test_tz,t)
(1 row)
SELECT "testSchema0".create_hypertable('test_dt', 'time', 'device', 2);
NOTICE: adding not-null constraint to column "time"
create_hypertable
----------------------
(3,public,test_dt,t)
(1 row)
SELECT * FROM _timescaledb_catalog.hypertable;
id | schema_name | table_name | associated_schema_name | associated_table_prefix | num_dimensions | chunk_sizing_func_schema | chunk_sizing_func_name | chunk_target_size
----+-------------+------------+------------------------+-------------------------+----------------+--------------------------+--------------------------+-------------------
1 | public | test_ts | _timescaledb_internal | _hyper_1 | 2 | _timescaledb_internal | calculate_chunk_interval | 0
2 | public | test_tz | _timescaledb_internal | _hyper_2 | 2 | _timescaledb_internal | calculate_chunk_interval | 0
3 | public | test_dt | _timescaledb_internal | _hyper_3 | 2 | _timescaledb_internal | calculate_chunk_interval | 0
(3 rows)
INSERT INTO test_ts VALUES('Mon Mar 20 09:17:00.936242 2017', 23.4, 'dev1');
INSERT INTO test_ts VALUES('Mon Mar 20 09:27:00.936242 2017', 22, 'dev2');
INSERT INTO test_ts VALUES('Mon Mar 20 09:28:00.936242 2017', 21.2, 'dev1');
INSERT INTO test_ts VALUES('Mon Mar 20 09:37:00.936242 2017', 30, 'dev3');
SELECT * FROM test_ts ORDER BY time;
time | temp | device
---------------------------------+------+--------
Mon Mar 20 09:17:00.936242 2017 | 23.4 | dev1
Mon Mar 20 09:27:00.936242 2017 | 22 | dev2
Mon Mar 20 09:28:00.936242 2017 | 21.2 | dev1
Mon Mar 20 09:37:00.936242 2017 | 30 | dev3
(4 rows)
INSERT INTO test_tz VALUES('Mon Mar 20 09:17:00.936242 2017', 23.4, 'dev1');
INSERT INTO test_tz VALUES('Mon Mar 20 09:27:00.936242 2017', 22, 'dev2');
INSERT INTO test_tz VALUES('Mon Mar 20 09:28:00.936242 2017', 21.2, 'dev1');
INSERT INTO test_tz VALUES('Mon Mar 20 09:37:00.936242 2017', 30, 'dev3');
SELECT * FROM test_tz ORDER BY time;
time | temp | device
-------------------------------------+------+--------
Mon Mar 20 09:17:00.936242 2017 PDT | 23.4 | dev1
Mon Mar 20 09:27:00.936242 2017 PDT | 22 | dev2
Mon Mar 20 09:28:00.936242 2017 PDT | 21.2 | dev1
Mon Mar 20 09:37:00.936242 2017 PDT | 30 | dev3
(4 rows)
INSERT INTO test_dt VALUES('Mon Mar 20 09:17:00.936242 2017', 23.4, 'dev1');
INSERT INTO test_dt VALUES('Mon Mar 21 09:27:00.936242 2017', 22, 'dev2');
INSERT INTO test_dt VALUES('Mon Mar 22 09:28:00.936242 2017', 21.2, 'dev1');
INSERT INTO test_dt VALUES('Mon Mar 23 09:37:00.936242 2017', 30, 'dev3');
SELECT * FROM test_dt ORDER BY time;
time | temp | device
------------+------+--------
03-20-2017 | 23.4 | dev1
03-21-2017 | 22 | dev2
03-22-2017 | 21.2 | dev1
03-23-2017 | 30 | dev3
(4 rows)
-- testing time_bucket START
SELECT AVG(temp) AS avg_tmp, "testSchema0".time_bucket('5 minutes', time, INTERVAL '1 minutes') AS ten_min FROM test_ts GROUP BY ten_min ORDER BY avg_tmp;
avg_tmp | ten_min
---------+--------------------------
21.6 | Mon Mar 20 09:26:00 2017
23.4 | Mon Mar 20 09:16:00 2017
30 | Mon Mar 20 09:36:00 2017
(3 rows)
SELECT AVG(temp) AS avg_tmp, "testSchema0".time_bucket('5 minutes', time, INTERVAL '1 minutes') AS ten_min FROM test_tz GROUP BY ten_min ORDER BY avg_tmp;
avg_tmp | ten_min
---------+------------------------------
21.6 | Mon Mar 20 09:26:00 2017 PDT
23.4 | Mon Mar 20 09:16:00 2017 PDT
30 | Mon Mar 20 09:36:00 2017 PDT
(3 rows)
SELECT AVG(temp) AS avg_tmp, "testSchema0".time_bucket('1 day', time, INTERVAL '-0.5 day') AS ten_min FROM test_dt GROUP BY ten_min ORDER BY avg_tmp;
avg_tmp | ten_min
---------+------------
21.2 | 03-21-2017
22 | 03-20-2017
23.4 | 03-19-2017
30 | 03-22-2017
(4 rows)
-- testing time_bucket END
-- testing drop_chunks START
-- show_chunks and drop_chunks output should be the same
\set QUERY1 'SELECT "testSchema0".show_chunks(older_than => \'2017-03-01\'::timestamp, hypertable => \'test_ts\')::REGCLASS::TEXT'
\set QUERY2 'SELECT "testSchema0".drop_chunks(\'2017-03-01\'::timestamp, \'test_ts\')::TEXT'
\set ECHO errors
Different Rows | Total Rows from Query 1 | Total Rows from Query 2
----------------+-------------------------+-------------------------
0 | 0 | 0
(1 row)
SELECT * FROM test_ts ORDER BY time;
time | temp | device
---------------------------------+------+--------
Mon Mar 20 09:17:00.936242 2017 | 23.4 | dev1
Mon Mar 20 09:27:00.936242 2017 | 22 | dev2
Mon Mar 20 09:28:00.936242 2017 | 21.2 | dev1
Mon Mar 20 09:37:00.936242 2017 | 30 | dev3
(4 rows)
\set QUERY1 'SELECT "testSchema0".show_chunks(older_than => interval \'1 minutes\', hypertable => \'test_tz\')::REGCLASS::TEXT'
\set QUERY2 'SELECT "testSchema0".drop_chunks(interval \'1 minutes\', \'test_tz\')::TEXT'
\set ECHO errors
Different Rows | Total Rows from Query 1 | Total Rows from Query 2
----------------+-------------------------+-------------------------
0 | 2 | 2
(1 row)
SELECT * FROM test_tz ORDER BY time;
time | temp | device
------+------+--------
(0 rows)
\set QUERY1 'SELECT "testSchema0".show_chunks(older_than => interval \'1 minutes\', hypertable => \'test_dt\')::REGCLASS::TEXT'
\set QUERY2 'SELECT "testSchema0".drop_chunks(interval \'1 minutes\', \'test_dt\')::TEXT'
\set ECHO errors
Different Rows | Total Rows from Query 1 | Total Rows from Query 2
----------------+-------------------------+-------------------------
0 | 3 | 3
(1 row)
SELECT * FROM test_dt ORDER BY time;
time | temp | device
------+------+--------
(0 rows)
-- testing drop_chunks END
-- testing hypertable_relation_size_pretty START
SELECT * FROM "testSchema0".hypertable_relation_size_pretty('test_ts');
table_size | index_size | toast_size | total_size
------------+------------+------------+------------
16 kB | 64 kB | 16 kB | 96 kB
(1 row)
-- testing hypertable_relation_size_pretty END
-- testing indexes_relation_size_pretty START
SELECT * FROM "testSchema0".indexes_relation_size_pretty('test_ts') ORDER BY index_name;
index_name | total_size
--------------------------------+------------
public.test_ts_device_time_idx | 32 kB
public.test_ts_time_idx | 32 kB
(2 rows)
-- testing indexes_relation_size_pretty END
CREATE SCHEMA "testSchema";
\set ON_ERROR_STOP 0
ALTER EXTENSION timescaledb SET SCHEMA "testSchema";
ERROR: extension "timescaledb" does not support SET SCHEMA
\set ON_ERROR_STOP 1