diff --git a/.unreleased/PR_6056 b/.unreleased/PR_6056 new file mode 100644 index 00000000000..f59b518736e --- /dev/null +++ b/.unreleased/PR_6056 @@ -0,0 +1 @@ +Implements: #6056 Restrict creation of partial cagg diff --git a/src/guc.c b/src/guc.c index d312b60d25d..137b7d414a9 100644 --- a/src/guc.c +++ b/src/guc.c @@ -86,6 +86,7 @@ bool ts_guc_enable_async_append = true; TSDLLEXPORT bool ts_guc_enable_compression_indexscan = true; TSDLLEXPORT bool ts_guc_enable_bulk_decompression = true; TSDLLEXPORT bool ts_guc_enable_skip_scan = true; +TSDLLEXPORT bool ts_guc_block_old_format_cagg = true; /* default value of ts_guc_max_open_chunks_per_insert and ts_guc_max_cached_chunks_per_hypertable * will be set as their respective boot-value when the GUC mechanism starts up */ int ts_guc_max_open_chunks_per_insert; @@ -476,6 +477,17 @@ _guc_init(void) NULL, NULL); + DefineCustomBoolVariable("timescaledb.block_old_format_cagg", + "Block creation of old format continuous aggregate", + "Disable creation of continuous aggregate with partials", + &ts_guc_block_old_format_cagg, + true, + PGC_USERSET, + 0, + NULL, + NULL, + NULL); + DefineCustomIntVariable("timescaledb.max_insert_batch_size", "The max number of tuples to batch before sending to a data node", "When acting as a access node, TimescaleDB splits batches of " diff --git a/src/guc.h b/src/guc.h index b4e369ebc79..d88e06ef192 100644 --- a/src/guc.h +++ b/src/guc.h @@ -35,6 +35,7 @@ extern TSDLLEXPORT bool ts_guc_enable_per_data_node_queries; extern TSDLLEXPORT bool ts_guc_enable_parameterized_data_node_scan; extern TSDLLEXPORT bool ts_guc_enable_async_append; extern TSDLLEXPORT bool ts_guc_enable_skip_scan; +extern TSDLLEXPORT bool ts_guc_block_old_format_cagg; extern bool ts_guc_restoring; extern int ts_guc_max_open_chunks_per_insert; extern int ts_guc_max_cached_chunks_per_hypertable; diff --git a/tsl/src/continuous_aggs/common.c b/tsl/src/continuous_aggs/common.c index cb59d35fcc0..73e8f714ebe 100644 --- a/tsl/src/continuous_aggs/common.c +++ b/tsl/src/continuous_aggs/common.c @@ -5,6 +5,7 @@ */ #include "common.h" +#include "guc.h" static Const *check_time_bucket_argument(Node *arg, char *position); static void caggtimebucketinfo_init(CAggTimebucketInfo *src, int32 hypertable_id, @@ -419,14 +420,10 @@ cagg_agg_validate(Node *node, void *context) static bool cagg_query_supported(const Query *query, StringInfo hint, StringInfo detail, const bool finalized) { -/* - * For now deprecate partial aggregates on release builds only. - * Once migration tests are made compatible with PG15 enable deprecation - * on debug builds as well. - */ -#ifndef DEBUG -#if PG15_GE - if (!finalized) + /* + * Deprecate partial aggregates to support only finalized aggregates. + */ + if (!finalized && ts_guc_block_old_format_cagg) { /* continuous aggregates with old format will not be allowed */ appendStringInfoString(detail, @@ -436,8 +433,6 @@ cagg_query_supported(const Query *query, StringInfo hint, StringInfo detail, con "to true."); return false; } -#endif -#endif if (!query->jointree->fromlist) { appendStringInfoString(hint, "FROM clause missing in the query"); diff --git a/tsl/test/expected/cagg_errors_deprecated.out b/tsl/test/expected/cagg_errors_deprecated.out index a8814bbab70..5113ff92e77 100644 --- a/tsl/test/expected/cagg_errors_deprecated.out +++ b/tsl/test/expected/cagg_errors_deprecated.out @@ -19,6 +19,8 @@ select table_name from create_hypertable( 'conditions', 'timec'); conditions (1 row) +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_m1 WITH (timescaledb.continuous, timescaledb.finalized = false, timescaledb.myfill = 1) as select location , min(temperature) diff --git a/tsl/test/expected/cagg_joins.out b/tsl/test/expected/cagg_joins.out index d53a67756db..8394d3b213c 100644 --- a/tsl/test/expected/cagg_joins.out +++ b/tsl/test/expected/cagg_joins.out @@ -938,6 +938,8 @@ ERROR: invalid continuous aggregate view DETAIL: Unsupported expression in join clause. HINT: Only equality conditions are supported in continuous aggregates. --With old format cagg definition +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW cagg_cagg_old WITH (timescaledb.continuous, timescaledb.materialized_only = TRUE, timescaledb.finalized = FALSE) AS SELECT time_bucket(INTERVAL '1 day', day) AS bucket, diff --git a/tsl/test/expected/cagg_migrate.out b/tsl/test/expected/cagg_migrate.out index 5ad01fafcb6..1f788f1b8e2 100644 --- a/tsl/test/expected/cagg_migrate.out +++ b/tsl/test/expected/cagg_migrate.out @@ -102,6 +102,8 @@ CALL cagg_migrate('conditions_summary_daily_new'); psql:include/cagg_migrate_common.sql:91: ERROR: continuous aggregate "public.conditions_summary_daily_new" does not require any migration \set ON_ERROR_STOP 1 -- older continuous aggregate to be migrated +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -118,7 +120,7 @@ FROM conditions GROUP BY bucket; -psql:include/cagg_migrate_common.sql:110: NOTICE: refreshing continuous aggregate "conditions_summary_daily" +psql:include/cagg_migrate_common.sql:112: NOTICE: refreshing continuous aggregate "conditions_summary_daily" SELECT ca.raw_hypertable_id AS "RAW_HYPERTABLE_ID", h.schema_name AS "MAT_SCHEMA_NAME", @@ -136,7 +138,7 @@ WHERE \set ON_ERROR_STOP 0 -- should fail because the new cagg with suffix '_new' already exists CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:129: ERROR: continuous aggregate "public.conditions_summary_daily_new" already exists +psql:include/cagg_migrate_common.sql:131: ERROR: continuous aggregate "public.conditions_summary_daily_new" already exists \set ON_ERROR_STOP 1 -- remove the new cagg to execute the migration DROP MATERIALIZED VIEW conditions_summary_daily_new; @@ -197,8 +199,8 @@ SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalo -- should resume the execution CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:151: WARNING: resuming the migration of the continuous aggregate "public.conditions_summary_daily" -psql:include/cagg_migrate_common.sql:151: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('1008' AS integer), NULL);" +psql:include/cagg_migrate_common.sql:153: WARNING: resuming the migration of the continuous aggregate "public.conditions_summary_daily" +psql:include/cagg_migrate_common.sql:153: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('1008' AS integer), NULL);" SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalog.continuous_agg_migrate_plan_step ORDER BY step_id; mat_hypertable_id | step_id | status | type | config -------------------+---------+----------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -225,13 +227,13 @@ SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalo \set ON_ERROR_STOP 0 -- should error because plan already exists CALL _timescaledb_functions.cagg_migrate_create_plan(:'CAGG_DATA', 'conditions_summary_daily_new'); -psql:include/cagg_migrate_common.sql:156: ERROR: plan already exists for materialized hypertable 3 +psql:include/cagg_migrate_common.sql:158: ERROR: plan already exists for materialized hypertable 3 CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:157: ERROR: plan already exists for continuous aggregate public.conditions_summary_daily +psql:include/cagg_migrate_common.sql:159: ERROR: plan already exists for continuous aggregate public.conditions_summary_daily \set ON_ERROR_STOP 1 -- policies for test ALTER MATERIALIZED VIEW conditions_summary_daily SET (timescaledb.compress=true); -psql:include/cagg_migrate_common.sql:161: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:163: NOTICE: defaulting compress_orderby to bucket \if :IS_TIME_DIMENSION SELECT add_retention_policy('conditions_summary_daily', '30 days'::interval); SELECT add_continuous_aggregate_policy('conditions_summary_daily', '30 days'::interval, '1 day'::interval, '1 hour'::interval); @@ -270,12 +272,12 @@ AND job_id >= 1000; -- execute the migration DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:180: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:182: NOTICE: drop cascades to 10 other objects TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:181: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:183: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:182: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:182: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('1008' AS integer), NULL);" +psql:include/cagg_migrate_common.sql:184: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:184: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('1008' AS integer), NULL);" SELECT ca.raw_hypertable_id AS "NEW_RAW_HYPERTABLE_ID", h.schema_name AS "NEW_MAT_SCHEMA_NAME", @@ -406,9 +408,9 @@ JOIN _timescaledb_catalog.continuous_agg ON mat_hypertable_id = hypertable_id ORDER BY bgw_job.id; -- test migration overriding the new cagg and keeping the old DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:230: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:232: NOTICE: drop cascades to 10 other objects TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:231: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:233: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" -- check policies before the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; schema | name | id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | fixed_schedule | initial_start | hypertable_id | config | check_schema | check_name | timezone @@ -419,8 +421,8 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d (3 rows) CALL cagg_migrate('conditions_summary_daily', override => TRUE); -psql:include/cagg_migrate_common.sql:234: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:234: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('1008' AS integer), NULL);" +psql:include/cagg_migrate_common.sql:236: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:236: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('1008' AS integer), NULL);" -- cagg with the new format because it was overriden \d+ conditions_summary_daily View "public.conditions_summary_daily" @@ -481,7 +483,7 @@ UNION ALL \set ON_ERROR_STOP 0 -- should fail because the cagg was overriden SELECT * FROM conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:241: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 +psql:include/cagg_migrate_common.sql:243: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 \set ON_ERROR_STOP 1 -- check policies after the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -509,9 +511,9 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d -- test migration overriding the new cagg and removing the old TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:251: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:253: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:252: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:254: NOTICE: drop cascades to 10 other objects ALTER MATERIALIZED VIEW conditions_summary_daily_old RENAME TO conditions_summary_daily; -- check policies before the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -523,12 +525,12 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d (3 rows) CALL cagg_migrate('conditions_summary_daily', override => TRUE, drop_old => TRUE); -psql:include/cagg_migrate_common.sql:256: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:256: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('1008' AS integer), NULL);" -psql:include/cagg_migrate_common.sql:256: NOTICE: drop cascades to 10 other objects -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1002 not found, skipping -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1001 not found, skipping -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1000 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:258: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('1008' AS integer), NULL);" +psql:include/cagg_migrate_common.sql:258: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1002 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1001 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1000 not found, skipping -- cagg with the new format because it was overriden \d+ conditions_summary_daily View "public.conditions_summary_daily" @@ -560,10 +562,10 @@ UNION ALL \set ON_ERROR_STOP 0 -- should fail because the cagg was overriden SELECT * FROM conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:261: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 +psql:include/cagg_migrate_common.sql:263: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 -- should fail because the old cagg was removed SELECT * FROM conditions_summary_daily_old; -psql:include/cagg_migrate_common.sql:263: ERROR: relation "conditions_summary_daily_old" does not exist at character 15 +psql:include/cagg_migrate_common.sql:265: ERROR: relation "conditions_summary_daily_old" does not exist at character 15 \set ON_ERROR_STOP 1 -- check policies after the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -588,11 +590,13 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d -- permissions test TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:273: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:275: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:274: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:276: NOTICE: drop cascades to 10 other objects GRANT ALL ON TABLE conditions TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -609,11 +613,11 @@ FROM conditions GROUP BY bucket; -psql:include/cagg_migrate_common.sql:293: NOTICE: refreshing continuous aggregate "conditions_summary_daily" +psql:include/cagg_migrate_common.sql:297: NOTICE: refreshing continuous aggregate "conditions_summary_daily" \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan' catalog table CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:297: ERROR: permission denied for table continuous_agg_migrate_plan +psql:include/cagg_migrate_common.sql:301: ERROR: permission denied for table continuous_agg_migrate_plan \set ON_ERROR_STOP 1 RESET ROLE; GRANT SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan TO :ROLE_DEFAULT_PERM_USER; @@ -621,7 +625,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan_step' catalog table CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:307: ERROR: permission denied for table continuous_agg_migrate_plan_step +psql:include/cagg_migrate_common.sql:311: ERROR: permission denied for table continuous_agg_migrate_plan_step \set ON_ERROR_STOP 1 RESET ROLE; GRANT SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan_step TO :ROLE_DEFAULT_PERM_USER; @@ -629,14 +633,14 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan_step_step_id_seq' catalog sequence CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:317: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq +psql:include/cagg_migrate_common.sql:321: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq \set ON_ERROR_STOP 1 RESET ROLE; GRANT USAGE ON SEQUENCE _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; -- all necessary permissions granted CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:326: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('1008' AS integer), NULL);" +psql:include/cagg_migrate_common.sql:330: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('1008' AS integer), NULL);" -- check migrated data. should return 0 (zero) rows SELECT * FROM conditions_summary_daily EXCEPT @@ -676,14 +680,14 @@ RESET ROLE; -- execute transaction control statements. Transaction control statements are only -- allowed if CALL is executed in its own transaction.` TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:343: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:347: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:344: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:348: NOTICE: drop cascades to 10 other objects \set ON_ERROR_STOP 0 BEGIN; -- should fail with `invalid transaction termination` CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:349: ERROR: invalid transaction termination +psql:include/cagg_migrate_common.sql:353: ERROR: invalid transaction termination ROLLBACK; \set ON_ERROR_STOP 1 CREATE OR REPLACE FUNCTION execute_migration() RETURNS void AS @@ -699,16 +703,16 @@ LANGUAGE plpgsql; BEGIN; -- should fail with `invalid transaction termination` SELECT execute_migration(); -psql:include/cagg_migrate_common.sql:366: ERROR: invalid transaction termination +psql:include/cagg_migrate_common.sql:370: ERROR: invalid transaction termination ROLLBACK; \set ON_ERROR_STOP 1 -- cleanup REVOKE SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan FROM :ROLE_DEFAULT_PERM_USER; REVOKE USAGE ON SEQUENCE _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq FROM :ROLE_DEFAULT_PERM_USER; TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:373: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:377: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:374: NOTICE: drop cascades to 10 other objects +psql:include/cagg_migrate_common.sql:378: NOTICE: drop cascades to 10 other objects DROP TABLE conditions; -- ######################################################## -- ## TIMESTAMP data type tests @@ -806,6 +810,8 @@ CALL cagg_migrate('conditions_summary_daily_new'); psql:include/cagg_migrate_common.sql:91: ERROR: continuous aggregate "public.conditions_summary_daily_new" does not require any migration \set ON_ERROR_STOP 1 -- older continuous aggregate to be migrated +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -822,7 +828,7 @@ FROM conditions GROUP BY bucket; -psql:include/cagg_migrate_common.sql:110: NOTICE: refreshing continuous aggregate "conditions_summary_daily" +psql:include/cagg_migrate_common.sql:112: NOTICE: refreshing continuous aggregate "conditions_summary_daily" SELECT ca.raw_hypertable_id AS "RAW_HYPERTABLE_ID", h.schema_name AS "MAT_SCHEMA_NAME", @@ -840,7 +846,7 @@ WHERE \set ON_ERROR_STOP 0 -- should fail because the new cagg with suffix '_new' already exists CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:129: ERROR: continuous aggregate "public.conditions_summary_daily_new" already exists +psql:include/cagg_migrate_common.sql:131: ERROR: continuous aggregate "public.conditions_summary_daily_new" already exists \set ON_ERROR_STOP 1 -- remove the new cagg to execute the migration DROP MATERIALIZED VIEW conditions_summary_daily_new; @@ -897,8 +903,8 @@ SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalo -- should resume the execution CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:151: WARNING: resuming the migration of the continuous aggregate "public.conditions_summary_daily" -psql:include/cagg_migrate_common.sql:151: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" +psql:include/cagg_migrate_common.sql:153: WARNING: resuming the migration of the continuous aggregate "public.conditions_summary_daily" +psql:include/cagg_migrate_common.sql:153: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalog.continuous_agg_migrate_plan_step ORDER BY step_id; mat_hypertable_id | step_id | status | type | config -------------------+---------+----------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -921,13 +927,13 @@ SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalo \set ON_ERROR_STOP 0 -- should error because plan already exists CALL _timescaledb_functions.cagg_migrate_create_plan(:'CAGG_DATA', 'conditions_summary_daily_new'); -psql:include/cagg_migrate_common.sql:156: ERROR: plan already exists for materialized hypertable 16 +psql:include/cagg_migrate_common.sql:158: ERROR: plan already exists for materialized hypertable 16 CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:157: ERROR: plan already exists for continuous aggregate public.conditions_summary_daily +psql:include/cagg_migrate_common.sql:159: ERROR: plan already exists for continuous aggregate public.conditions_summary_daily \set ON_ERROR_STOP 1 -- policies for test ALTER MATERIALIZED VIEW conditions_summary_daily SET (timescaledb.compress=true); -psql:include/cagg_migrate_common.sql:161: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:163: NOTICE: defaulting compress_orderby to bucket \if :IS_TIME_DIMENSION SELECT add_retention_policy('conditions_summary_daily', '30 days'::interval); add_retention_policy @@ -966,12 +972,12 @@ AND job_id >= 1000; -- execute the migration DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:180: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:182: NOTICE: drop cascades to 6 other objects TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:181: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:183: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:182: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:182: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" +psql:include/cagg_migrate_common.sql:184: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:184: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" SELECT ca.raw_hypertable_id AS "NEW_RAW_HYPERTABLE_ID", h.schema_name AS "NEW_MAT_SCHEMA_NAME", @@ -1090,9 +1096,9 @@ JOIN _timescaledb_catalog.continuous_agg ON mat_hypertable_id = hypertable_id ORDER BY bgw_job.id; -- test migration overriding the new cagg and keeping the old DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:230: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:232: NOTICE: drop cascades to 6 other objects TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:231: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:233: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" -- check policies before the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; schema | name | id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | fixed_schedule | initial_start | hypertable_id | config | check_schema | check_name | timezone @@ -1103,8 +1109,8 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d (3 rows) CALL cagg_migrate('conditions_summary_daily', override => TRUE); -psql:include/cagg_migrate_common.sql:234: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:234: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" +psql:include/cagg_migrate_common.sql:236: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:236: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" -- cagg with the new format because it was overriden \d+ conditions_summary_daily View "public.conditions_summary_daily" @@ -1165,7 +1171,7 @@ UNION ALL \set ON_ERROR_STOP 0 -- should fail because the cagg was overriden SELECT * FROM conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:241: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 +psql:include/cagg_migrate_common.sql:243: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 \set ON_ERROR_STOP 1 -- check policies after the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -1193,9 +1199,9 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d -- test migration overriding the new cagg and removing the old TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:251: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:253: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:252: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:254: NOTICE: drop cascades to 6 other objects ALTER MATERIALIZED VIEW conditions_summary_daily_old RENAME TO conditions_summary_daily; -- check policies before the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -1207,12 +1213,12 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d (3 rows) CALL cagg_migrate('conditions_summary_daily', override => TRUE, drop_old => TRUE); -psql:include/cagg_migrate_common.sql:256: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:256: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" -psql:include/cagg_migrate_common.sql:256: NOTICE: drop cascades to 6 other objects -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1014 not found, skipping -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1013 not found, skipping -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1012 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:258: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" +psql:include/cagg_migrate_common.sql:258: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1014 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1013 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1012 not found, skipping -- cagg with the new format because it was overriden \d+ conditions_summary_daily View "public.conditions_summary_daily" @@ -1244,10 +1250,10 @@ UNION ALL \set ON_ERROR_STOP 0 -- should fail because the cagg was overriden SELECT * FROM conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:261: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 +psql:include/cagg_migrate_common.sql:263: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 -- should fail because the old cagg was removed SELECT * FROM conditions_summary_daily_old; -psql:include/cagg_migrate_common.sql:263: ERROR: relation "conditions_summary_daily_old" does not exist at character 15 +psql:include/cagg_migrate_common.sql:265: ERROR: relation "conditions_summary_daily_old" does not exist at character 15 \set ON_ERROR_STOP 1 -- check policies after the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -1272,11 +1278,13 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d -- permissions test TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:273: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:275: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:274: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:276: NOTICE: drop cascades to 6 other objects GRANT ALL ON TABLE conditions TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -1293,11 +1301,11 @@ FROM conditions GROUP BY bucket; -psql:include/cagg_migrate_common.sql:293: NOTICE: refreshing continuous aggregate "conditions_summary_daily" +psql:include/cagg_migrate_common.sql:297: NOTICE: refreshing continuous aggregate "conditions_summary_daily" \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan' catalog table CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:297: ERROR: permission denied for table continuous_agg_migrate_plan +psql:include/cagg_migrate_common.sql:301: ERROR: permission denied for table continuous_agg_migrate_plan \set ON_ERROR_STOP 1 RESET ROLE; GRANT SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan TO :ROLE_DEFAULT_PERM_USER; @@ -1305,7 +1313,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan_step' catalog table CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:307: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq +psql:include/cagg_migrate_common.sql:311: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq \set ON_ERROR_STOP 1 RESET ROLE; GRANT SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan_step TO :ROLE_DEFAULT_PERM_USER; @@ -1313,14 +1321,14 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan_step_step_id_seq' catalog sequence CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:317: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq +psql:include/cagg_migrate_common.sql:321: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq \set ON_ERROR_STOP 1 RESET ROLE; GRANT USAGE ON SEQUENCE _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; -- all necessary permissions granted CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:326: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" +psql:include/cagg_migrate_common.sql:330: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp without time zone), NULL);" -- check migrated data. should return 0 (zero) rows SELECT * FROM conditions_summary_daily EXCEPT @@ -1356,14 +1364,14 @@ RESET ROLE; -- execute transaction control statements. Transaction control statements are only -- allowed if CALL is executed in its own transaction.` TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:343: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:347: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:344: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:348: NOTICE: drop cascades to 6 other objects \set ON_ERROR_STOP 0 BEGIN; -- should fail with `invalid transaction termination` CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:349: ERROR: invalid transaction termination +psql:include/cagg_migrate_common.sql:353: ERROR: invalid transaction termination ROLLBACK; \set ON_ERROR_STOP 1 CREATE OR REPLACE FUNCTION execute_migration() RETURNS void AS @@ -1379,16 +1387,16 @@ LANGUAGE plpgsql; BEGIN; -- should fail with `invalid transaction termination` SELECT execute_migration(); -psql:include/cagg_migrate_common.sql:366: ERROR: invalid transaction termination +psql:include/cagg_migrate_common.sql:370: ERROR: invalid transaction termination ROLLBACK; \set ON_ERROR_STOP 1 -- cleanup REVOKE SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan FROM :ROLE_DEFAULT_PERM_USER; REVOKE USAGE ON SEQUENCE _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq FROM :ROLE_DEFAULT_PERM_USER; TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:373: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:377: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:374: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:378: NOTICE: drop cascades to 6 other objects DROP TABLE conditions; -- ######################################################## -- ## TIMESTAMPTZ data type tests @@ -1485,6 +1493,8 @@ CALL cagg_migrate('conditions_summary_daily_new'); psql:include/cagg_migrate_common.sql:91: ERROR: continuous aggregate "public.conditions_summary_daily_new" does not require any migration \set ON_ERROR_STOP 1 -- older continuous aggregate to be migrated +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -1501,7 +1511,7 @@ FROM conditions GROUP BY bucket; -psql:include/cagg_migrate_common.sql:110: NOTICE: refreshing continuous aggregate "conditions_summary_daily" +psql:include/cagg_migrate_common.sql:112: NOTICE: refreshing continuous aggregate "conditions_summary_daily" SELECT ca.raw_hypertable_id AS "RAW_HYPERTABLE_ID", h.schema_name AS "MAT_SCHEMA_NAME", @@ -1519,7 +1529,7 @@ WHERE \set ON_ERROR_STOP 0 -- should fail because the new cagg with suffix '_new' already exists CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:129: ERROR: continuous aggregate "public.conditions_summary_daily_new" already exists +psql:include/cagg_migrate_common.sql:131: ERROR: continuous aggregate "public.conditions_summary_daily_new" already exists \set ON_ERROR_STOP 1 -- remove the new cagg to execute the migration DROP MATERIALIZED VIEW conditions_summary_daily_new; @@ -1576,8 +1586,8 @@ SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalo -- should resume the execution CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:151: WARNING: resuming the migration of the continuous aggregate "public.conditions_summary_daily" -psql:include/cagg_migrate_common.sql:151: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" +psql:include/cagg_migrate_common.sql:153: WARNING: resuming the migration of the continuous aggregate "public.conditions_summary_daily" +psql:include/cagg_migrate_common.sql:153: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalog.continuous_agg_migrate_plan_step ORDER BY step_id; mat_hypertable_id | step_id | status | type | config -------------------+---------+----------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -1600,13 +1610,13 @@ SELECT mat_hypertable_id, step_id, status, type, config FROM _timescaledb_catalo \set ON_ERROR_STOP 0 -- should error because plan already exists CALL _timescaledb_functions.cagg_migrate_create_plan(:'CAGG_DATA', 'conditions_summary_daily_new'); -psql:include/cagg_migrate_common.sql:156: ERROR: plan already exists for materialized hypertable 29 +psql:include/cagg_migrate_common.sql:158: ERROR: plan already exists for materialized hypertable 29 CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:157: ERROR: plan already exists for continuous aggregate public.conditions_summary_daily +psql:include/cagg_migrate_common.sql:159: ERROR: plan already exists for continuous aggregate public.conditions_summary_daily \set ON_ERROR_STOP 1 -- policies for test ALTER MATERIALIZED VIEW conditions_summary_daily SET (timescaledb.compress=true); -psql:include/cagg_migrate_common.sql:161: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:163: NOTICE: defaulting compress_orderby to bucket \if :IS_TIME_DIMENSION SELECT add_retention_policy('conditions_summary_daily', '30 days'::interval); add_retention_policy @@ -1645,12 +1655,12 @@ AND job_id >= 1000; -- execute the migration DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:180: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:182: NOTICE: drop cascades to 6 other objects TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:181: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:183: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:182: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:182: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" +psql:include/cagg_migrate_common.sql:184: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:184: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" SELECT ca.raw_hypertable_id AS "NEW_RAW_HYPERTABLE_ID", h.schema_name AS "NEW_MAT_SCHEMA_NAME", @@ -1769,9 +1779,9 @@ JOIN _timescaledb_catalog.continuous_agg ON mat_hypertable_id = hypertable_id ORDER BY bgw_job.id; -- test migration overriding the new cagg and keeping the old DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:230: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:232: NOTICE: drop cascades to 6 other objects TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:231: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:233: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" -- check policies before the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; schema | name | id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | fixed_schedule | initial_start | hypertable_id | config | check_schema | check_name | timezone @@ -1782,8 +1792,8 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d (3 rows) CALL cagg_migrate('conditions_summary_daily', override => TRUE); -psql:include/cagg_migrate_common.sql:234: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:234: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" +psql:include/cagg_migrate_common.sql:236: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:236: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" -- cagg with the new format because it was overriden \d+ conditions_summary_daily View "public.conditions_summary_daily" @@ -1844,7 +1854,7 @@ UNION ALL \set ON_ERROR_STOP 0 -- should fail because the cagg was overriden SELECT * FROM conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:241: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 +psql:include/cagg_migrate_common.sql:243: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 \set ON_ERROR_STOP 1 -- check policies after the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -1872,9 +1882,9 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d -- test migration overriding the new cagg and removing the old TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:251: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:253: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:252: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:254: NOTICE: drop cascades to 6 other objects ALTER MATERIALIZED VIEW conditions_summary_daily_old RENAME TO conditions_summary_daily; -- check policies before the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -1886,12 +1896,12 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d (3 rows) CALL cagg_migrate('conditions_summary_daily', override => TRUE, drop_old => TRUE); -psql:include/cagg_migrate_common.sql:256: NOTICE: defaulting compress_orderby to bucket -psql:include/cagg_migrate_common.sql:256: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" -psql:include/cagg_migrate_common.sql:256: NOTICE: drop cascades to 6 other objects -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1026 not found, skipping -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1025 not found, skipping -psql:include/cagg_migrate_common.sql:256: NOTICE: job 1024 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: defaulting compress_orderby to bucket +psql:include/cagg_migrate_common.sql:258: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" +psql:include/cagg_migrate_common.sql:258: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1026 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1025 not found, skipping +psql:include/cagg_migrate_common.sql:258: NOTICE: job 1024 not found, skipping -- cagg with the new format because it was overriden \d+ conditions_summary_daily View "public.conditions_summary_daily" @@ -1923,10 +1933,10 @@ UNION ALL \set ON_ERROR_STOP 0 -- should fail because the cagg was overriden SELECT * FROM conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:261: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 +psql:include/cagg_migrate_common.sql:263: ERROR: relation "conditions_summary_daily_new" does not exist at character 15 -- should fail because the old cagg was removed SELECT * FROM conditions_summary_daily_old; -psql:include/cagg_migrate_common.sql:263: ERROR: relation "conditions_summary_daily_old" does not exist at character 15 +psql:include/cagg_migrate_common.sql:265: ERROR: relation "conditions_summary_daily_old" does not exist at character 15 \set ON_ERROR_STOP 1 -- check policies after the migration SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_daily'; @@ -1951,11 +1961,13 @@ SELECT * FROM cagg_jobs WHERE schema = 'public' AND name = 'conditions_summary_d -- permissions test TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:273: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:275: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:274: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:276: NOTICE: drop cascades to 6 other objects GRANT ALL ON TABLE conditions TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -1972,11 +1984,11 @@ FROM conditions GROUP BY bucket; -psql:include/cagg_migrate_common.sql:293: NOTICE: refreshing continuous aggregate "conditions_summary_daily" +psql:include/cagg_migrate_common.sql:297: NOTICE: refreshing continuous aggregate "conditions_summary_daily" \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan' catalog table CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:297: ERROR: permission denied for table continuous_agg_migrate_plan +psql:include/cagg_migrate_common.sql:301: ERROR: permission denied for table continuous_agg_migrate_plan \set ON_ERROR_STOP 1 RESET ROLE; GRANT SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan TO :ROLE_DEFAULT_PERM_USER; @@ -1984,7 +1996,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan_step' catalog table CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:307: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq +psql:include/cagg_migrate_common.sql:311: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq \set ON_ERROR_STOP 1 RESET ROLE; GRANT SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan_step TO :ROLE_DEFAULT_PERM_USER; @@ -1992,14 +2004,14 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; \set ON_ERROR_STOP 0 -- should fail because the lack of permissions on 'continuous_agg_migrate_plan_step_step_id_seq' catalog sequence CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:317: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq +psql:include/cagg_migrate_common.sql:321: ERROR: permission denied for sequence continuous_agg_migrate_plan_step_step_id_seq \set ON_ERROR_STOP 1 RESET ROLE; GRANT USAGE ON SEQUENCE _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; -- all necessary permissions granted CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:326: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" +psql:include/cagg_migrate_common.sql:330: WARNING: refresh the continuous aggregate after the migration executing this statement: "CALL public.refresh_continuous_aggregate('public.conditions_summary_daily_new', CAST('Sun Jan 01 00:00:00 2023' AS timestamp with time zone), NULL);" -- check migrated data. should return 0 (zero) rows SELECT * FROM conditions_summary_daily EXCEPT @@ -2035,14 +2047,14 @@ RESET ROLE; -- execute transaction control statements. Transaction control statements are only -- allowed if CALL is executed in its own transaction.` TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:343: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:347: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily_new; -psql:include/cagg_migrate_common.sql:344: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:348: NOTICE: drop cascades to 6 other objects \set ON_ERROR_STOP 0 BEGIN; -- should fail with `invalid transaction termination` CALL cagg_migrate('conditions_summary_daily'); -psql:include/cagg_migrate_common.sql:349: ERROR: invalid transaction termination +psql:include/cagg_migrate_common.sql:353: ERROR: invalid transaction termination ROLLBACK; \set ON_ERROR_STOP 1 CREATE OR REPLACE FUNCTION execute_migration() RETURNS void AS @@ -2058,14 +2070,14 @@ LANGUAGE plpgsql; BEGIN; -- should fail with `invalid transaction termination` SELECT execute_migration(); -psql:include/cagg_migrate_common.sql:366: ERROR: invalid transaction termination +psql:include/cagg_migrate_common.sql:370: ERROR: invalid transaction termination ROLLBACK; \set ON_ERROR_STOP 1 -- cleanup REVOKE SELECT, INSERT, UPDATE ON TABLE _timescaledb_catalog.continuous_agg_migrate_plan FROM :ROLE_DEFAULT_PERM_USER; REVOKE USAGE ON SEQUENCE _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq FROM :ROLE_DEFAULT_PERM_USER; TRUNCATE _timescaledb_catalog.continuous_agg_migrate_plan RESTART IDENTITY CASCADE; -psql:include/cagg_migrate_common.sql:373: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" +psql:include/cagg_migrate_common.sql:377: NOTICE: truncate cascades to table "continuous_agg_migrate_plan_step" DROP MATERIALIZED VIEW conditions_summary_daily; -psql:include/cagg_migrate_common.sql:374: NOTICE: drop cascades to 6 other objects +psql:include/cagg_migrate_common.sql:378: NOTICE: drop cascades to 6 other objects DROP TABLE conditions; diff --git a/tsl/test/expected/cagg_repair.out b/tsl/test/expected/cagg_repair.out index ca67e9974cf..6ef53565131 100644 --- a/tsl/test/expected/cagg_repair.out +++ b/tsl/test/expected/cagg_repair.out @@ -312,6 +312,8 @@ UNION ALL GROUP BY (time_bucket('@ 7 days'::interval, conditions."time")); -- Tests with old cagg format +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_old_format WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT diff --git a/tsl/test/expected/continuous_aggs-13.out b/tsl/test/expected/continuous_aggs-13.out index 1e80bdcc960..3528fab8d23 100644 --- a/tsl/test/expected/continuous_aggs-13.out +++ b/tsl/test/expected/continuous_aggs-13.out @@ -2213,6 +2213,18 @@ AS SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) FROM conditions GROUP BY time_bucket('1day', timec) WITH NO DATA; +-- Aggregates with partials are not supported by default +\set ON_ERROR_STOP 0 +CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) +WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) +AS +SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) +FROM conditions +GROUP BY time_bucket('1day', timec) WITH NO DATA; +ERROR: invalid continuous aggregate query +\set ON_ERROR_STOP 1 +-- Aggregates with partials are supported under a custom boolean flag +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) AS diff --git a/tsl/test/expected/continuous_aggs-14.out b/tsl/test/expected/continuous_aggs-14.out index b785788f37e..66392dd7633 100644 --- a/tsl/test/expected/continuous_aggs-14.out +++ b/tsl/test/expected/continuous_aggs-14.out @@ -2212,6 +2212,18 @@ AS SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) FROM conditions GROUP BY time_bucket('1day', timec) WITH NO DATA; +-- Aggregates with partials are not supported by default +\set ON_ERROR_STOP 0 +CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) +WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) +AS +SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) +FROM conditions +GROUP BY time_bucket('1day', timec) WITH NO DATA; +ERROR: invalid continuous aggregate query +\set ON_ERROR_STOP 1 +-- Aggregates with partials are supported under a custom boolean flag +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) AS diff --git a/tsl/test/expected/continuous_aggs-15.out b/tsl/test/expected/continuous_aggs-15.out index 691522c73d4..d408b554a1c 100644 --- a/tsl/test/expected/continuous_aggs-15.out +++ b/tsl/test/expected/continuous_aggs-15.out @@ -2214,6 +2214,18 @@ AS SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) FROM conditions GROUP BY time_bucket('1day', timec) WITH NO DATA; +-- Aggregates with partials are not supported by default +\set ON_ERROR_STOP 0 +CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) +WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) +AS +SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) +FROM conditions +GROUP BY time_bucket('1day', timec) WITH NO DATA; +ERROR: invalid continuous aggregate query +\set ON_ERROR_STOP 1 +-- Aggregates with partials are supported under a custom boolean flag +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) AS diff --git a/tsl/test/expected/continuous_aggs_deprecated-13.out b/tsl/test/expected/continuous_aggs_deprecated-13.out index 0fa341542fe..b27313ab4bf 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-13.out +++ b/tsl/test/expected/continuous_aggs_deprecated-13.out @@ -44,6 +44,8 @@ SELECT set_integer_now_func('foo', 'integer_now_foo'); (1 row) +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_m1(a, countb) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as @@ -741,6 +743,8 @@ select table_name from create_hypertable( 'conditions', 'timec'); (1 row) --no data in hyper table on purpose so that CASCADE is not required because of chunks +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_drop_test(timec, minl, sumt , sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as diff --git a/tsl/test/expected/continuous_aggs_deprecated-14.out b/tsl/test/expected/continuous_aggs_deprecated-14.out index 20097a81700..d0075d0ed78 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-14.out +++ b/tsl/test/expected/continuous_aggs_deprecated-14.out @@ -44,6 +44,8 @@ SELECT set_integer_now_func('foo', 'integer_now_foo'); (1 row) +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_m1(a, countb) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as @@ -741,6 +743,8 @@ select table_name from create_hypertable( 'conditions', 'timec'); (1 row) --no data in hyper table on purpose so that CASCADE is not required because of chunks +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_drop_test(timec, minl, sumt , sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as diff --git a/tsl/test/expected/continuous_aggs_deprecated-15.out b/tsl/test/expected/continuous_aggs_deprecated-15.out index 20097a81700..d0075d0ed78 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-15.out +++ b/tsl/test/expected/continuous_aggs_deprecated-15.out @@ -44,6 +44,8 @@ SELECT set_integer_now_func('foo', 'integer_now_foo'); (1 row) +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_m1(a, countb) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as @@ -741,6 +743,8 @@ select table_name from create_hypertable( 'conditions', 'timec'); (1 row) --no data in hyper table on purpose so that CASCADE is not required because of chunks +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_drop_test(timec, minl, sumt , sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as diff --git a/tsl/test/expected/telemetry_stats-13.out b/tsl/test/expected/telemetry_stats-13.out index 5d00b22911b..44e95ebfabf 100644 --- a/tsl/test/expected/telemetry_stats-13.out +++ b/tsl/test/expected/telemetry_stats-13.out @@ -70,6 +70,8 @@ FROM hyper GROUP BY hour, device; NOTICE: continuous aggregate "contagg" is already up-to-date +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW contagg_old WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT diff --git a/tsl/test/expected/telemetry_stats-14.out b/tsl/test/expected/telemetry_stats-14.out index 5d00b22911b..44e95ebfabf 100644 --- a/tsl/test/expected/telemetry_stats-14.out +++ b/tsl/test/expected/telemetry_stats-14.out @@ -70,6 +70,8 @@ FROM hyper GROUP BY hour, device; NOTICE: continuous aggregate "contagg" is already up-to-date +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW contagg_old WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT diff --git a/tsl/test/expected/telemetry_stats-15.out b/tsl/test/expected/telemetry_stats-15.out index f82fa068c54..9668a652ee0 100644 --- a/tsl/test/expected/telemetry_stats-15.out +++ b/tsl/test/expected/telemetry_stats-15.out @@ -70,6 +70,8 @@ FROM hyper GROUP BY hour, device; NOTICE: continuous aggregate "contagg" is already up-to-date +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW contagg_old WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -920,6 +922,8 @@ FROM disthyper GROUP BY hour, device; NOTICE: refreshing continuous aggregate "distcontagg" +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW distcontagg_old WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT diff --git a/tsl/test/sql/cagg_errors_deprecated.sql b/tsl/test/sql/cagg_errors_deprecated.sql index 455b42926ca..f9099ecc9c7 100644 --- a/tsl/test/sql/cagg_errors_deprecated.sql +++ b/tsl/test/sql/cagg_errors_deprecated.sql @@ -18,6 +18,9 @@ CREATE TABLE conditions ( ); select table_name from create_hypertable( 'conditions', 'timec'); +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; + CREATE MATERIALIZED VIEW mat_m1 WITH (timescaledb.continuous, timescaledb.finalized = false, timescaledb.myfill = 1) as select location , min(temperature) diff --git a/tsl/test/sql/cagg_joins.sql b/tsl/test/sql/cagg_joins.sql index 5eb21e4ebe3..c40a8f74c36 100644 --- a/tsl/test/sql/cagg_joins.sql +++ b/tsl/test/sql/cagg_joins.sql @@ -381,6 +381,9 @@ AND conditions.city = devices.location AND GROUP BY name, bucket; --With old format cagg definition +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; + CREATE MATERIALIZED VIEW cagg_cagg_old WITH (timescaledb.continuous, timescaledb.materialized_only = TRUE, timescaledb.finalized = FALSE) AS SELECT time_bucket(INTERVAL '1 day', day) AS bucket, diff --git a/tsl/test/sql/cagg_repair.sql b/tsl/test/sql/cagg_repair.sql index 795e0129180..3886e0114c9 100644 --- a/tsl/test/sql/cagg_repair.sql +++ b/tsl/test/sql/cagg_repair.sql @@ -110,6 +110,8 @@ CALL _timescaledb_internal.cagg_try_repair('conditions_summary_nojoin', TRUE); \d+ conditions_summary_nojoin -- Tests with old cagg format +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_old_format WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT diff --git a/tsl/test/sql/continuous_aggs.sql.in b/tsl/test/sql/continuous_aggs.sql.in index 0c09d8c7497..c323af748f3 100644 --- a/tsl/test/sql/continuous_aggs.sql.in +++ b/tsl/test/sql/continuous_aggs.sql.in @@ -1490,6 +1490,19 @@ SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity FROM conditions GROUP BY time_bucket('1day', timec) WITH NO DATA; +-- Aggregates with partials are not supported by default +\set ON_ERROR_STOP 0 +CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) +WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) +AS +SELECT time_bucket('1day', timec), min(location), sum(temperature), sum(humidity) +FROM conditions +GROUP BY time_bucket('1day', timec) WITH NO DATA; +\set ON_ERROR_STOP 1 + +-- Aggregates with partials are supported under a custom boolean flag +SET timescaledb.block_old_format_cagg TO OFF; + CREATE MATERIALIZED VIEW conditions_summary_old(timec, minl, sumt, sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) AS diff --git a/tsl/test/sql/continuous_aggs_deprecated.sql.in b/tsl/test/sql/continuous_aggs_deprecated.sql.in index 022a786e808..cf175653249 100644 --- a/tsl/test/sql/continuous_aggs_deprecated.sql.in +++ b/tsl/test/sql/continuous_aggs_deprecated.sql.in @@ -41,6 +41,9 @@ CREATE OR REPLACE FUNCTION integer_now_foo() returns int LANGUAGE SQL STABLE as SELECT set_integer_now_func('foo', 'integer_now_foo'); +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; + CREATE MATERIALIZED VIEW mat_m1(a, countb) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as @@ -574,6 +577,8 @@ select table_name from create_hypertable( 'conditions', 'timec'); --no data in hyper table on purpose so that CASCADE is not required because of chunks +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW mat_drop_test(timec, minl, sumt , sumh) WITH (timescaledb.continuous, timescaledb.materialized_only=true, timescaledb.finalized=false) as diff --git a/tsl/test/sql/include/cagg_migrate_common.sql b/tsl/test/sql/include/cagg_migrate_common.sql index 74599657f34..17e5a8f23e5 100644 --- a/tsl/test/sql/include/cagg_migrate_common.sql +++ b/tsl/test/sql/include/cagg_migrate_common.sql @@ -92,6 +92,8 @@ CALL cagg_migrate('conditions_summary_daily_new'); \set ON_ERROR_STOP 1 -- older continuous aggregate to be migrated +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -275,6 +277,8 @@ DROP MATERIALIZED VIEW conditions_summary_daily; GRANT ALL ON TABLE conditions TO :ROLE_DEFAULT_PERM_USER; SET ROLE :ROLE_DEFAULT_PERM_USER; +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW conditions_summary_daily WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT diff --git a/tsl/test/sql/include/cont_agg_equal_deprecated.sql b/tsl/test/sql/include/cont_agg_equal_deprecated.sql index bf84d22bf59..93b220bf697 100644 --- a/tsl/test/sql/include/cont_agg_equal_deprecated.sql +++ b/tsl/test/sql/include/cont_agg_equal_deprecated.sql @@ -7,6 +7,9 @@ DROP MATERIALIZED VIEW IF EXISTS mat_test; +-- Aggregates with partials are supported under a custom boolean flag +SET timescaledb.block_old_format_cagg TO OFF; + CREATE MATERIALIZED VIEW mat_test WITH (timescaledb.continuous, timescaledb.finalized=false) as :QUERY diff --git a/tsl/test/sql/telemetry_stats.sql.in b/tsl/test/sql/telemetry_stats.sql.in index b01b79368cd..3f3963e948a 100644 --- a/tsl/test/sql/telemetry_stats.sql.in +++ b/tsl/test/sql/telemetry_stats.sql.in @@ -56,6 +56,8 @@ FROM hyper GROUP BY hour, device; +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW contagg_old WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT @@ -227,6 +229,8 @@ FROM disthyper GROUP BY hour, device; +-- Continuous aggregates with partials are supported under a custom boolean flag. +SET timescaledb.block_old_format_cagg TO OFF; CREATE MATERIALIZED VIEW distcontagg_old WITH (timescaledb.continuous, timescaledb.finalized=false) AS SELECT