mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-24 15:05:03 +08:00
Grants and revokes where not propagated to compressed hypertables, if the hypertable had a compressed hypertable, meaning that `pg_dump` and `pg_restore` would not be able to dump nor restore the compressed part of a hypertable unless they were owners and/or was a superuser. This commit fixes this by propagating grants and revokes on a hypertable to the associated compressed hypertable, if one exists, which will then include the compressed hypertable and the associated chunks in the grant and revoke execution. It also adds code to fix the permissions of compressed hypertables and all associated chunks in an update and adds an update test to check that the permissions match. Fixes #3209
42 lines
1.7 KiB
SQL
42 lines
1.7 KiB
SQL
-- 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.
|
|
|
|
CREATE TYPE custom_type_for_compression AS (high int, low int);
|
|
|
|
CREATE TABLE compress (
|
|
time TIMESTAMPTZ NOT NULL,
|
|
small_cardinality TEXT NULL,
|
|
large_cardinality TEXT NULL,
|
|
some_double DOUBLE PRECISION NULL,
|
|
some_int integer NULL,
|
|
some_custom custom_type_for_compression NULL,
|
|
some_bool boolean NULL
|
|
);
|
|
|
|
SELECT table_name FROM create_hypertable( 'compress', 'time');
|
|
|
|
INSERT INTO compress
|
|
SELECT g, 'POR', g::text, 75.0, 40, (1,2)::custom_type_for_compression, true
|
|
FROM generate_series('2018-12-01 00:00'::timestamp, '2018-12-31 00:00'::timestamp, '1 day') g;
|
|
|
|
INSERT INTO compress
|
|
SELECT g, 'POR', NULL, NULL, NULL, NULL, NULL
|
|
FROM generate_series('2018-11-01 00:00'::timestamp, '2018-12-31 00:00'::timestamp, '1 day') g;
|
|
|
|
INSERT INTO compress
|
|
SELECT g, 'POR', g::text, 94.0, 45, (3,4)::custom_type_for_compression, true
|
|
FROM generate_series('2018-11-01 00:00'::timestamp, '2018-12-15 00:00'::timestamp, '1 day') g;
|
|
|
|
ALTER TABLE compress SET (timescaledb.compress, timescaledb.compress_segmentby='small_cardinality');
|
|
|
|
SELECT 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 = 'compress' and chunk.compressed_chunk_id IS NULL
|
|
ORDER BY chunk.id;
|
|
|
|
\if :WITH_ROLES
|
|
GRANT SELECT ON compress TO tsdbadmin;
|
|
\endif
|