mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 18:13:18 +08:00
Verify compression settings before adding policy
When a compression policy is added for a continuous aggregate, verify that compression has been enabled, before adding a policy.
This commit is contained in:
parent
44be03b5c6
commit
7f5c5fd10d
@ -413,7 +413,6 @@ validate_compress_chunks_hypertable(Cache *hcache, Oid user_htoid, bool *is_cagg
|
||||
{
|
||||
if (!TS_HYPERTABLE_HAS_COMPRESSION_ENABLED(ht))
|
||||
{
|
||||
ts_cache_release(hcache);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("compression not enabled on hypertable \"%s\"",
|
||||
@ -423,7 +422,6 @@ validate_compress_chunks_hypertable(Cache *hcache, Oid user_htoid, bool *is_cagg
|
||||
status = ts_continuous_agg_hypertable_status(ht->fd.id);
|
||||
if ((status == HypertableIsMaterialization || status == HypertableIsMaterializationAndRaw))
|
||||
{
|
||||
ts_cache_release(hcache);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot add compression policy to materialized hypertable \"%s\" ",
|
||||
@ -460,7 +458,6 @@ validate_compress_chunks_hypertable(Cache *hcache, Oid user_htoid, bool *is_cagg
|
||||
found = policy_refresh_cagg_exists(mat_id);
|
||||
if (!found)
|
||||
{
|
||||
ts_cache_release(hcache);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("continuous aggregate policy does not exist for \"%s\"",
|
||||
@ -469,6 +466,14 @@ validate_compress_chunks_hypertable(Cache *hcache, Oid user_htoid, bool *is_cagg
|
||||
"policy",
|
||||
get_rel_name(user_htoid))));
|
||||
}
|
||||
if (!TS_HYPERTABLE_HAS_COMPRESSION_ENABLED(ht))
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("compression not enabled on continuous aggregate \"%s\"",
|
||||
get_rel_name(user_htoid)),
|
||||
errhint("Enable compression before adding a compression policy.")));
|
||||
}
|
||||
}
|
||||
Assert(ht != NULL);
|
||||
return ht;
|
||||
|
@ -656,7 +656,9 @@ select add_continuous_aggregate_policy('i2980_cagg2', interval '10 day', interva
|
||||
1002
|
||||
(1 row)
|
||||
|
||||
--this one fails as i2980_cagg refresh policy is (NULL, NULL)
|
||||
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);
|
||||
ERROR: compression not enabled on continuous aggregate "i2980_cagg"
|
||||
ALTER MATERIALIZED VIEW i2980_cagg SET ( timescaledb.compress );
|
||||
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);
|
||||
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for i2980_cagg
|
||||
SELECT add_continuous_aggregate_policy('i2980_cagg2', '10 day'::interval, '6 day'::interval);
|
||||
|
@ -568,13 +568,16 @@ SELECT time_bucket('1 day', time) as dayb, device_id,
|
||||
FROM metrics
|
||||
GROUP BY 1, 2
|
||||
WITH NO DATA;
|
||||
ALTER MATERIALIZED VIEW metrics_cagg SET (timescaledb.compress);
|
||||
--can set compression policy only after setting up refresh policy --
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT add_compression_policy('metrics_cagg', '1 day'::interval);
|
||||
ERROR: setup a refresh policy for "metrics_cagg" before setting up a compression policy
|
||||
\set ON_ERROR_STOP 1
|
||||
--can set compression policy only after enabling compression --
|
||||
SELECT add_continuous_aggregate_policy('metrics_cagg', '7 day'::interval, '1 day'::interval, '1 h'::interval) as "REFRESH_JOB" \gset
|
||||
SELECT add_compression_policy('metrics_cagg', '8 day'::interval) AS "COMP_JOB" ;
|
||||
ERROR: compression not enabled on continuous aggregate "metrics_cagg"
|
||||
\set ON_ERROR_STOP 1
|
||||
ALTER MATERIALIZED VIEW metrics_cagg SET (timescaledb.compress);
|
||||
SELECT add_compression_policy('metrics_cagg', '8 day'::interval) AS "COMP_JOB" ;
|
||||
COMP_JOB
|
||||
----------
|
||||
|
@ -567,7 +567,8 @@ ALTER MATERIALIZED VIEW i2980_cagg2 SET ( timescaledb.compress, timescaledb.comp
|
||||
|
||||
--Errors with compression policy on caggs--
|
||||
select add_continuous_aggregate_policy('i2980_cagg2', interval '10 day', interval '2 day' ,'4h') AS job_id ;
|
||||
--this one fails as i2980_cagg refresh policy is (NULL, NULL)
|
||||
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);
|
||||
ALTER MATERIALIZED VIEW i2980_cagg SET ( timescaledb.compress );
|
||||
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);
|
||||
|
||||
SELECT add_continuous_aggregate_policy('i2980_cagg2', '10 day'::interval, '6 day'::interval);
|
||||
|
@ -336,14 +336,17 @@ FROM metrics
|
||||
GROUP BY 1, 2
|
||||
WITH NO DATA;
|
||||
|
||||
ALTER MATERIALIZED VIEW metrics_cagg SET (timescaledb.compress);
|
||||
|
||||
--can set compression policy only after setting up refresh policy --
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT add_compression_policy('metrics_cagg', '1 day'::interval);
|
||||
|
||||
--can set compression policy only after enabling compression --
|
||||
SELECT add_continuous_aggregate_policy('metrics_cagg', '7 day'::interval, '1 day'::interval, '1 h'::interval) as "REFRESH_JOB" \gset
|
||||
SELECT add_compression_policy('metrics_cagg', '8 day'::interval) AS "COMP_JOB" ;
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
SELECT add_continuous_aggregate_policy('metrics_cagg', '7 day'::interval, '1 day'::interval, '1 h'::interval) as "REFRESH_JOB" \gset
|
||||
ALTER MATERIALIZED VIEW metrics_cagg SET (timescaledb.compress);
|
||||
|
||||
SELECT add_compression_policy('metrics_cagg', '8 day'::interval) AS "COMP_JOB" ;
|
||||
SELECT remove_compression_policy('metrics_cagg');
|
||||
SELECT add_compression_policy('metrics_cagg', '8 day'::interval) AS "COMP_JOB" \gset
|
||||
|
Loading…
x
Reference in New Issue
Block a user