timescaledb/tsl/test/sql/include/compression_test_hypertable_segment_meta.sql
Matvey Arye be199bec70 Add type cache
Add a type cache to get the OID corresponding to a particular
defined SQL type.
2019-10-29 19:02:58 -04:00

34 lines
1.5 KiB
SQL

-- This file and its contents are licensed under the Timescale License.
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
SELECT 'NULL::'||:'TYPE' as "NULLTYPE" \gset
--compress the data
SELECT count(compress_chunk(chunk.schema_name|| '.' || chunk.table_name)) as count_compressed
FROM _timescaledb_catalog.chunk chunk
INNER JOIN _timescaledb_catalog.hypertable hypertable ON (chunk.hypertable_id = hypertable.id)
WHERE hypertable.table_name like :'HYPERTABLE_NAME' and chunk.compressed_chunk_id IS NULL;
SELECT
comp_hypertable.schema_name AS "COMP_SCHEMA_NAME",
comp_hypertable.table_name AS "COMP_TABLE_NAME"
FROM _timescaledb_catalog.hypertable uc_hypertable
INNER JOIN _timescaledb_catalog.hypertable comp_hypertable ON (comp_hypertable.id = uc_hypertable.compressed_hypertable_id)
WHERE uc_hypertable.table_name like :'HYPERTABLE_NAME' \gset
SELECT
bool_and(_timescaledb_internal.segment_meta_min_max_get_min(:SEGMENT_META_COL, :NULLTYPE) = true_min) as min_correct,
bool_and(_timescaledb_internal.segment_meta_min_max_get_max(:SEGMENT_META_COL, :NULLTYPE) = true_max) as max_correct,
bool_and(_timescaledb_internal.segment_meta_min_max_has_null(:SEGMENT_META_COL) = true_has_null) as has_null_correct
FROM
:"COMP_SCHEMA_NAME".:"COMP_TABLE_NAME", LATERAL (
SELECT min(decomp) true_min, max(decomp) true_max, ((count(*)-count(decomp)) > 0) true_has_null
FROM _timescaledb_internal.decompress_forward(:"ORDER_BY_COL_NAME", :NULLTYPE) decomp
)
as m;
\set ECHO all