diff --git a/.unreleased/fix_6940 b/.unreleased/fix_6940 new file mode 100644 index 00000000000..70f4bafe739 --- /dev/null +++ b/.unreleased/fix_6940 @@ -0,0 +1 @@ +Fixes: #6940 Fix `pg_upgrade` failure by removing `regprocedure` from catalog table diff --git a/sql/pre_install/tables.sql b/sql/pre_install/tables.sql index 06f6e7fb46d..08a315bcd95 100644 --- a/sql/pre_install/tables.sql +++ b/sql/pre_install/tables.sql @@ -351,7 +351,7 @@ SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_agg' CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( mat_hypertable_id integer NOT NULL, -- The bucket function - bucket_func regprocedure NOT NULL, + bucket_func text NOT NULL, -- `bucket_width` argument of the function, e.g. "1 month" bucket_width text NOT NULL, -- optional `origin` argument of the function provided by the user @@ -364,7 +364,8 @@ CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( bucket_fixed_width bool NOT NULL, -- table constraints CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), - CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE + CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE, + CONSTRAINT continuous_aggs_bucket_function_func_check CHECK (pg_catalog.to_regprocedure(bucket_func) IS DISTINCT FROM 0) ); SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql index e69de29bb2d..8ea90a558a4 100644 --- a/sql/updates/latest-dev.sql +++ b/sql/updates/latest-dev.sql @@ -0,0 +1,49 @@ +CREATE TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function AS + SELECT + mat_hypertable_id, + bucket_func::text AS bucket_func, + bucket_width, + bucket_origin, + bucket_offset, + bucket_timezone, + bucket_fixed_width + FROM + _timescaledb_catalog.continuous_aggs_bucket_function + ORDER BY + mat_hypertable_id; + +ALTER EXTENSION timescaledb + DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; + +DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; + +CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( + mat_hypertable_id integer NOT NULL, + -- The bucket function + bucket_func text NOT NULL, + -- `bucket_width` argument of the function, e.g. "1 month" + bucket_width text NOT NULL, + -- optional `origin` argument of the function provided by the user + bucket_origin text, + -- optional `offset` argument of the function provided by the user + bucket_offset text, + -- optional `timezone` argument of the function provided by the user + bucket_timezone text, + -- fixed or variable sized bucket + bucket_fixed_width bool NOT NULL, + -- table constraints + CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), + CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE, + CONSTRAINT continuous_aggs_bucket_function_func_check CHECK (pg_catalog.to_regprocedure(bucket_func) IS DISTINCT FROM 0) +); + +INSERT INTO _timescaledb_catalog.continuous_aggs_bucket_function + SELECT * FROM _timescaledb_catalog._tmp_continuous_aggs_bucket_function; + +DROP TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function; + +SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); + +GRANT SELECT ON TABLE _timescaledb_catalog.continuous_aggs_bucket_function TO PUBLIC; + +ANALYZE _timescaledb_catalog.continuous_aggs_bucket_function; diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql index e69de29bb2d..344a796df29 100644 --- a/sql/updates/reverse-dev.sql +++ b/sql/updates/reverse-dev.sql @@ -0,0 +1,48 @@ +CREATE TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function AS + SELECT + mat_hypertable_id, + pg_catalog.to_regprocedure(bucket_func) AS bucket_func, + bucket_width, + bucket_origin, + bucket_offset, + bucket_timezone, + bucket_fixed_width + FROM + _timescaledb_catalog.continuous_aggs_bucket_function + ORDER BY + mat_hypertable_id; + +ALTER EXTENSION timescaledb + DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; + +DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; + +CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( + mat_hypertable_id integer NOT NULL, + -- The bucket function + bucket_func regprocedure NOT NULL, + -- `bucket_width` argument of the function, e.g. "1 month" + bucket_width text NOT NULL, + -- optional `origin` argument of the function provided by the user + bucket_origin text, + -- optional `offset` argument of the function provided by the user + bucket_offset text, + -- optional `timezone` argument of the function provided by the user + bucket_timezone text, + -- fixed or variable sized bucket + bucket_fixed_width bool NOT NULL, + -- table constraints + CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), + CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE +); + +INSERT INTO _timescaledb_catalog.continuous_aggs_bucket_function + SELECT * FROM _timescaledb_catalog._tmp_continuous_aggs_bucket_function; + +DROP TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function; + +SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); + +GRANT SELECT ON TABLE _timescaledb_catalog.continuous_aggs_bucket_function TO PUBLIC; + +ANALYZE _timescaledb_catalog.continuous_aggs_bucket_function; diff --git a/src/ts_catalog/continuous_agg.c b/src/ts_catalog/continuous_agg.c index d21d55c964c..cfd2f098506 100644 --- a/src/ts_catalog/continuous_agg.c +++ b/src/ts_catalog/continuous_agg.c @@ -504,10 +504,10 @@ continuous_agg_fill_bucket_function(int32 mat_hypertable_id, ContinuousAggsBucke /* Bucket function */ Assert(!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)]); - bf->bucket_function = DatumGetObjectId( + const char *bucket_function_str = TextDatumGetCString( values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)]); - - Assert(OidIsValid(bf->bucket_function)); + bf->bucket_function = DatumGetObjectId( + DirectFunctionCall1(regprocedurein, CStringGetDatum(bucket_function_str))); bf->bucket_time_based = ts_continuous_agg_bucket_on_interval(bf->bucket_function); diff --git a/tsl/src/continuous_aggs/create.c b/tsl/src/continuous_aggs/create.c index 879d0df7fca..4e58f35831d 100644 --- a/tsl/src/continuous_aggs/create.c +++ b/tsl/src/continuous_aggs/create.c @@ -208,7 +208,7 @@ create_bucket_function_catalog_entry(int32 matht_id, Oid bucket_function, const /* Bucket function */ values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)] = - ObjectIdGetDatum(bucket_function); + CStringGetTextDatum(format_procedure_qualified(bucket_function)); /* Bucket width */ values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_width)] = diff --git a/tsl/src/continuous_aggs/utils.c b/tsl/src/continuous_aggs/utils.c index 1bcb92dabc4..cb809c04746 100644 --- a/tsl/src/continuous_aggs/utils.c +++ b/tsl/src/continuous_aggs/utils.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "extension.h" @@ -308,7 +309,7 @@ cagg_time_bucket_update(TupleInfo *ti, void *data) /* Update the bucket function */ values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)] = - ObjectIdGetDatum(cagg->bucket_function->bucket_function); + CStringGetTextDatum(format_procedure_qualified(cagg->bucket_function->bucket_function)); doReplace[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)] = true; /* Set new origin if not already present. Time_bucket and time_bucket_ng use different diff --git a/tsl/test/expected/cagg_migrate_function-14.out b/tsl/test/expected/cagg_migrate_function-14.out index 350df7528b9..723ee411f97 100644 --- a/tsl/test/expected/cagg_migrate_function-14.out +++ b/tsl/test/expected/cagg_migrate_function-14.out @@ -78,9 +78,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+--------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 4 | timescaledb_experimental.time_bucket_ng(interval,date) | @ 7 days | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 4 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date) | @ 7 days | | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -114,9 +114,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 4 | time_bucket(interval,date,date) | @ 7 days | Sat Jan 01 00:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 4 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -168,9 +168,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,date,date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -204,9 +204,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | time_bucket(interval,date,date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -300,9 +300,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 6 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Sat Jan 01 00:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 6 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -390,9 +390,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 7 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Tue Dec 31 20:00:00 2019 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 7 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Tue Dec 31 20:00:00 2019 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -455,9 +455,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 8 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 5 mins | | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 8 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 5 mins | | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -491,9 +491,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 8 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 8 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -545,9 +545,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+----------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 9 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,text) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 9 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,pg_catalog.text) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -581,9 +581,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 9 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 9 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -636,9 +636,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 10 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 5 mins | | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 10 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 5 mins | | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -680,9 +680,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 10 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 10 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_migrate_function-15.out b/tsl/test/expected/cagg_migrate_function-15.out index 350df7528b9..723ee411f97 100644 --- a/tsl/test/expected/cagg_migrate_function-15.out +++ b/tsl/test/expected/cagg_migrate_function-15.out @@ -78,9 +78,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+--------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 4 | timescaledb_experimental.time_bucket_ng(interval,date) | @ 7 days | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 4 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date) | @ 7 days | | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -114,9 +114,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 4 | time_bucket(interval,date,date) | @ 7 days | Sat Jan 01 00:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 4 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -168,9 +168,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,date,date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -204,9 +204,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | time_bucket(interval,date,date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -300,9 +300,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 6 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Sat Jan 01 00:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 6 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -390,9 +390,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 7 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Tue Dec 31 20:00:00 2019 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 7 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Tue Dec 31 20:00:00 2019 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -455,9 +455,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 8 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 5 mins | | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 8 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 5 mins | | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -491,9 +491,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 8 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 8 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -545,9 +545,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+----------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 9 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,text) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 9 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,pg_catalog.text) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -581,9 +581,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 9 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 9 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -636,9 +636,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 10 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 5 mins | | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 10 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 5 mins | | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -680,9 +680,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 10 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 10 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_migrate_function-16.out b/tsl/test/expected/cagg_migrate_function-16.out index f72b6f37204..0fa824b7aef 100644 --- a/tsl/test/expected/cagg_migrate_function-16.out +++ b/tsl/test/expected/cagg_migrate_function-16.out @@ -78,9 +78,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+--------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 4 | timescaledb_experimental.time_bucket_ng(interval,date) | @ 7 days | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 4 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date) | @ 7 days | | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -114,9 +114,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 4 | time_bucket(interval,date,date) | @ 7 days | Sat Jan 01 00:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 4 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -168,9 +168,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,date,date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -204,9 +204,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | time_bucket(interval,date,date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -300,9 +300,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 6 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Sat Jan 01 00:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 6 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -390,9 +390,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 7 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Tue Dec 31 20:00:00 2019 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 7 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 5 mins | Tue Dec 31 20:00:00 2019 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -455,9 +455,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 8 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 5 mins | | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 8 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 5 mins | | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -491,9 +491,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 8 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 8 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -545,9 +545,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+----------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 9 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,text) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 9 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,pg_catalog.text) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -581,9 +581,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 9 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 9 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Wed Apr 01 00:00:00 2020 PDT | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -636,9 +636,9 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 10 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 5 mins | | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 10 | timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 5 mins | | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -680,9 +680,9 @@ SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 10 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 10 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 5 mins | Fri Dec 31 15:00:00 1999 PST | | Europe/Berlin | f (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_query.out b/tsl/test/expected/cagg_query.out index 2c24a68869f..82e2bdbd765 100644 --- a/tsl/test/expected/cagg_query.out +++ b/tsl/test/expected/cagg_query.out @@ -818,9 +818,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 10 | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 10 | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; @@ -832,9 +832,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 11 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 11 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; @@ -846,9 +846,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset2 GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 12 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 12 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; @@ -862,9 +862,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts GROUP BY 1 ORDER BY 1; ERROR: cannot create continuous aggregate with variable-width bucket using offset or origin. SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 3 | time_bucket(interval,timestamp with time zone) | @ 1 day | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 3 | public.time_bucket(interval,timestamp with time zone) | @ 1 day | | | | t (1 row) \set ON_ERROR_STOP 1 @@ -875,9 +875,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 13 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 13 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; @@ -890,9 +890,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin2 GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 14 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 14 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; @@ -906,9 +906,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts GROUP BY 1 ORDER BY 1; ERROR: cannot create continuous aggregate with variable-width bucket using offset or origin. SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 3 | time_bucket(interval,timestamp with time zone) | @ 1 day | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 3 | public.time_bucket(interval,timestamp with time zone) | @ 1 day | | | | t (1 row) -- Without named parameter @@ -919,9 +919,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 GROUP BY 1 ORDER BY 1; ERROR: cannot create continuous aggregate with variable-width bucket using offset or origin. SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 3 | time_bucket(interval,timestamp with time zone) | @ 1 day | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 3 | public.time_bucket(interval,timestamp with time zone) | @ 1 day | | | | t (1 row) \set ON_ERROR_STOP 1 @@ -933,9 +933,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 15 | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 15 | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -945,9 +945,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 16 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 16 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; @@ -961,9 +961,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 17 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 17 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) \set ON_ERROR_STOP 1 @@ -974,9 +974,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 18 | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 18 | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; @@ -989,9 +989,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- - 19 | time_bucket(interval,date) | @ 4 days | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 19 | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; @@ -1003,9 +1003,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 20 | time_bucket(interval,date,date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 20 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; @@ -1017,9 +1017,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 21 | time_bucket(interval,date,date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + 21 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; @@ -1031,9 +1031,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_offset GROUP BY 1 ORDER BY 1; NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 22 | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 22 | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; @@ -1046,9 +1046,9 @@ CREATE MATERIALIZED VIEW cagg_smallint GROUP BY 1; NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 23 | time_bucket(smallint,smallint) | 2 | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 23 | public.time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; @@ -1060,9 +1060,9 @@ CREATE MATERIALIZED VIEW cagg_smallint_offset GROUP BY 1; NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 24 | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 24 | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; @@ -1074,9 +1074,9 @@ CREATE MATERIALIZED VIEW cagg_int GROUP BY 1; NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 25 | time_bucket(integer,integer) | 2 | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 25 | public.time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; @@ -1088,9 +1088,9 @@ CREATE MATERIALIZED VIEW cagg_int_offset GROUP BY 1; NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 26 | time_bucket(integer,integer,integer) | 2 | | 1 | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 26 | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; @@ -1101,9 +1101,9 @@ CREATE MATERIALIZED VIEW cagg_bigint FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- - 27 | time_bucket(bigint,bigint) | 2 | | | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 27 | public.time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1113,9 +1113,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 28 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 28 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1126,11 +1126,22 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 29 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 29 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) +-- mess with the bucket_func signature to make sure it will raise an exception +\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER +\set ON_ERROR_STOP 0 +BEGIN; +UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; +-- should error because function does not exist +CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); +ERROR: function "func_does_not_exist()" does not exist +ROLLBACK; +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 diff --git a/tsl/test/expected/exp_cagg_monthly.out b/tsl/test/expected/exp_cagg_monthly.out index d2d85aac584..3176d4fb1e1 100644 --- a/tsl/test/expected/exp_cagg_monthly.out +++ b/tsl/test/expected/exp_cagg_monthly.out @@ -72,9 +72,9 @@ WHERE user_view_name = 'conditions_summary' SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :cagg_id; - mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width --------------------+--------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - 2 | timescaledb_experimental.time_bucket_ng(interval,date) | @ 1 mon | | | | f + mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +-------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + 2 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date) | @ 1 mon | | | | f (1 row) \pset null "" diff --git a/tsl/test/expected/exp_cagg_origin.out b/tsl/test/expected/exp_cagg_origin.out index 56ecd6b15ed..36d4b06d54e 100644 --- a/tsl/test/expected/exp_cagg_origin.out +++ b/tsl/test/expected/exp_cagg_origin.out @@ -801,9 +801,9 @@ SELECT mat_hypertable_id AS cagg_id SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :cagg_id; - bucket_func | bucket_width | bucket_origin | bucket_timezone | bucket_fixed_width -----------------------------------------------------------------------------------------------------------+--------------+------------------------------+-----------------+-------------------- - timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,text) | @ 12 hours | Mon Jun 01 02:00:00 2020 PDT | Europe/Moscow | f + bucket_func | bucket_width | bucket_origin | bucket_timezone | bucket_fixed_width +---------------------------------------------------------------------------------------------------------------------+--------------+------------------------------+-----------------+-------------------- + timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,timestamp with time zone,pg_catalog.text) | @ 12 hours | Mon Jun 01 02:00:00 2020 PDT | Europe/Moscow | f (1 row) SELECT city, to_char(bucket at time zone 'MSK', 'YYYY-MM-DD HH24:MI:SS') AS b, min, max diff --git a/tsl/test/expected/exp_cagg_timezone.out b/tsl/test/expected/exp_cagg_timezone.out index b303e67bd47..77dc30dfe35 100644 --- a/tsl/test/expected/exp_cagg_timezone.out +++ b/tsl/test/expected/exp_cagg_timezone.out @@ -120,9 +120,9 @@ WHERE user_view_name = 'conditions_summary_tz' SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :cagg_id_tz; - bucket_func | bucket_width | bucket_origin | bucket_timezone | bucket_fixed_width ----------------------------------------------------------------------------------+--------------+---------------+-----------------+-------------------- - timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 1 mon | | MSK | f + bucket_func | bucket_width | bucket_origin | bucket_timezone | bucket_fixed_width +--------------------------------------------------------------------------------------------+--------------+---------------+-----------------+-------------------- + timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 1 mon | | MSK | f (1 row) -- Make sure that buckets with specified timezone are always treated as @@ -146,9 +146,9 @@ WHERE user_view_name = 'conditions_summary_1w' SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :cagg_id_1w; - bucket_func | bucket_width | bucket_origin | bucket_timezone | bucket_fixed_width ----------------------------------------------------------------------------------+--------------+---------------+-----------------+-------------------- - timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,text) | @ 7 days | | MSK | f + bucket_func | bucket_width | bucket_origin | bucket_timezone | bucket_fixed_width +--------------------------------------------------------------------------------------------+--------------+---------------+-----------------+-------------------- + timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone,pg_catalog.text) | @ 7 days | | MSK | f (1 row) -- Check the invalidation threshold is -infinity diff --git a/tsl/test/sql/cagg_query.sql b/tsl/test/sql/cagg_query.sql index 23787f1b4c8..ad4d6a34c33 100644 --- a/tsl/test/sql/cagg_query.sql +++ b/tsl/test/sql/cagg_query.sql @@ -554,6 +554,18 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1 DESC LIMIT 1; + +-- mess with the bucket_func signature to make sure it will raise an exception +\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER +\set ON_ERROR_STOP 0 +BEGIN; +UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; +-- should error because function does not exist +CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); +ROLLBACK; +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER + DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions diff --git a/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz b/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz index 3d8058d73b8..4a67fae9f5d 100644 Binary files a/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz and b/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz differ diff --git a/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz b/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz index de12d6cf183..bb3cf45b41c 100644 Binary files a/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz and b/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz differ diff --git a/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz b/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz index 729abe1ce7a..32744f15b4f 100644 Binary files a/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz and b/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz differ