Skip to content

Commit 0beed12

Browse files
committed
Add Update test
1 parent d72224d commit 0beed12

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

test/sql/updates/post.compression.sql

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ SELECT * FROM compress ORDER BY time DESC, small_cardinality, large_cardinality,
2525
\x on
2626
WITH hypertables AS (
2727
SELECT ht.id hypertable_id,
28-
ht.schema_name,
29-
ht.table_name,
30-
ht.compressed_hypertable_id
28+
ht.schema_name,
29+
ht.table_name,
30+
ht.compressed_hypertable_id
3131
FROM pg_class cl JOIN pg_namespace ns ON ns.oid = relnamespace
32-
JOIN _timescaledb_catalog.hypertable ht ON relname = ht.table_name AND nspname = ht.schema_name
32+
JOIN _timescaledb_catalog.hypertable ht ON relname = ht.table_name AND nspname = ht.schema_name
3333
),
3434
table_summary AS (
35-
SELECT format('%I.%I', ht1.schema_name, ht1.table_name) AS hypertable_name,
36-
format('%I.%I', ht2.schema_name, ht2.table_name) AS compressed_hypertable_name,
37-
format('%I.%I', ch2.schema_name, ch2.table_name) AS compressed_chunk_name
38-
FROM hypertables ht1
39-
JOIN hypertables ht2 ON ht1.compressed_hypertable_id = ht2.hypertable_id
35+
SELECT format('%I.%I', ht1.schema_name, ht1.table_name) AS hypertable_name,
36+
format('%I.%I', ht2.schema_name, ht2.table_name) AS compressed_hypertable_name,
37+
format('%I.%I', ch2.schema_name, ch2.table_name) AS compressed_chunk_name
38+
FROM hypertables ht1
39+
JOIN hypertables ht2 ON ht1.compressed_hypertable_id = ht2.hypertable_id
4040
JOIN _timescaledb_catalog.chunk ch2 ON ch2.hypertable_id = ht2.hypertable_id
4141
)
4242
SELECT hypertable_name,
@@ -49,3 +49,19 @@ SELECT hypertable_name,
4949
ORDER BY hypertable_name, compressed_hypertable_name, compressed_chunk_name;
5050
\x off
5151

52+
DO $$
53+
DECLARE
54+
ts_minor int := (SELECT (string_to_array(extversion,'.'))[2]::int FROM pg_extension WHERE extname = 'timescaledb');
55+
BEGIN
56+
57+
-- Enable chunk skipping. For versions smaller than minor 18 we do
58+
-- this in the post step since the feature and settings aren't all
59+
-- available in proior versions.
60+
IF ts_minor < 18 THEN
61+
SET timescaledb.enable_chunk_skipping = true;
62+
PERFORM enable_chunk_skipping('compress', 'some_int');
63+
END IF;
64+
END
65+
$$;
66+
67+
SELECT * FROM _timescaledb_catalog.chunk_column_stats ORDER BY id;

test/sql/updates/setup.compression.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ INSERT INTO compress
2929
SELECT g, 'POR', g::text, 'lint', 94.0, 45, (3,4)::custom_type_for_compression, true
3030
FROM generate_series('2018-11-01 00:00'::timestamp, '2018-12-15 00:00'::timestamp, '1 day') g;
3131

32-
-- Add column stats for chunk skipping
33-
SELECT enable_chunk_skipping('compress', 'some_int');
34-
3532
DO $$
3633
DECLARE
3734
ts_minor int := (SELECT (string_to_array(extversion,'.'))[2]::int FROM pg_extension WHERE extname = 'timescaledb');
@@ -49,6 +46,14 @@ BEGIN
4946
IF ts_minor >= 10 THEN
5047
ALTER TABLE compress DROP COLUMN dropped;
5148
END IF;
49+
50+
-- Enable chunk skipping. Doing this after compression to have a
51+
-- "special" chunk_id entry of 0, since this is changed to NULL
52+
-- during upgrade.
53+
IF ts_minor >= 18 THEN
54+
SET timescaledb.enable_chunk_skipping = true;
55+
PERFORM enable_chunk_skipping('compress', 'some_int');
56+
END IF;
5257
END
5358
$$;
5459

0 commit comments

Comments
 (0)