mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-14 09:37:00 +08:00
Fix crash in 1-step integer policy creation
Previously when a retention policy existed on the underlying hypertable, we would get a segmentation fault when trying to add a Cagg refresh policy, due to passing a bool instead of pointer to bool argument to function `ts_jsonb_get_int64_field` in a particular code path. Fixed by passing the expected pointer type. Fixes #5907
This commit is contained in:
parent
b2773aa344
commit
28612ebc3c
1
.unreleased/bugfix_5907
Normal file
1
.unreleased/bugfix_5907
Normal file
@ -0,0 +1 @@
|
||||
Fixes: #5912 Fix crash in 1-step integer policy creation
|
@ -128,9 +128,10 @@ validate_and_create_policies(policies_info all_policies, bool if_exists)
|
||||
{
|
||||
if (IS_INTEGER_TYPE(all_policies.partition_type))
|
||||
{
|
||||
bool found_drop_after = false;
|
||||
drop_after_HT = ts_jsonb_get_int64_field(orig_ht_reten_job->fd.config,
|
||||
POL_RETENTION_CONF_KEY_DROP_AFTER,
|
||||
false);
|
||||
&found_drop_after);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1275,3 +1275,35 @@ SELECT * FROM deals_best_weekly;
|
||||
Sun Apr 24 17:00:00 2022 PDT | 117.764705882353 | 6
|
||||
(1 row)
|
||||
|
||||
-- github issue 5907: segfault when creating 1-step policies on cagg
|
||||
-- whose underlying hypertable has a retention policy setup
|
||||
CREATE TABLE t(a integer NOT NULL, b integer);
|
||||
SELECT create_hypertable('t', 'a', chunk_time_interval=> 10);
|
||||
create_hypertable
|
||||
-------------------
|
||||
(25,public,t,t)
|
||||
(1 row)
|
||||
|
||||
CREATE OR REPLACE FUNCTION unix_now() returns int LANGUAGE SQL IMMUTABLE as $$ SELECT extract(epoch from now())::INT $$;
|
||||
SELECT set_integer_now_func('t', 'unix_now');
|
||||
set_integer_now_func
|
||||
----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT add_retention_policy('t', 20);
|
||||
add_retention_policy
|
||||
----------------------
|
||||
1056
|
||||
(1 row)
|
||||
|
||||
CREATE MATERIALIZED VIEW cagg(a, sumb) WITH (timescaledb.continuous)
|
||||
AS SELECT time_bucket(1, a), sum(b)
|
||||
FROM t GROUP BY time_bucket(1, a);
|
||||
NOTICE: continuous aggregate "cagg" is already up-to-date
|
||||
SELECT timescaledb_experimental.add_policies('cagg');
|
||||
add_policies
|
||||
--------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
|
@ -630,3 +630,19 @@ SELECT * FROM deals_best_daily ORDER BY bucket LIMIT 2;
|
||||
-- expect to get an up-to-date notice
|
||||
CALL refresh_continuous_aggregate('deals_best_weekly', '2022-04-24', '2022-05-05');
|
||||
SELECT * FROM deals_best_weekly;
|
||||
|
||||
-- github issue 5907: segfault when creating 1-step policies on cagg
|
||||
-- whose underlying hypertable has a retention policy setup
|
||||
CREATE TABLE t(a integer NOT NULL, b integer);
|
||||
SELECT create_hypertable('t', 'a', chunk_time_interval=> 10);
|
||||
|
||||
CREATE OR REPLACE FUNCTION unix_now() returns int LANGUAGE SQL IMMUTABLE as $$ SELECT extract(epoch from now())::INT $$;
|
||||
SELECT set_integer_now_func('t', 'unix_now');
|
||||
|
||||
SELECT add_retention_policy('t', 20);
|
||||
|
||||
CREATE MATERIALIZED VIEW cagg(a, sumb) WITH (timescaledb.continuous)
|
||||
AS SELECT time_bucket(1, a), sum(b)
|
||||
FROM t GROUP BY time_bucket(1, a);
|
||||
|
||||
SELECT timescaledb_experimental.add_policies('cagg');
|
||||
|
Loading…
x
Reference in New Issue
Block a user