Skip to content

Commit

Permalink
Deprecate continuous aggregates with old format
Browse files Browse the repository at this point in the history
This patch will report a warning when upgrading to new timescaledb
extension. Also restrict users from creating cagss with old format
on timescaledb with PG15.
  • Loading branch information
sb230132 committed Nov 9, 2022
1 parent 9744b4f commit f5ad22f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sql/updates/post-update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,19 @@ FROM _timescaledb_catalog.hypertable h
INNER JOIN _timescaledb_catalog.dimension d ON (d.hypertable_id = h.id)
WHERE d.interval_length IS NULL;
DROP FUNCTION _timescaledb_internal.update_dimension_partition;

-- Report warning when partial aggregates are used
DO $$
DECLARE
cagg_cnt int := 0;
BEGIN
IF current_setting('server_version_num')::int > 140000 THEN
SELECT
COUNT(*) INTO cagg_cnt
FROM _timescaledb_catalog.continuous_agg cagg
WHERE cagg.finalized = false;
END IF;
IF cagg_cnt > 0 THEN
RAISE WARNING 'Continuous Aggregates with old format will not be supported with PG15. You should upgrade to the new format';
END IF;
END $$;
13 changes: 13 additions & 0 deletions tsl/src/continuous_aggs/create.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,19 @@ cagg_query_supported(Query *query, StringInfo hint, StringInfo detail, const boo
return false;
}

#if PG15_GE
if (!finalized)
{
/* continuous aggregates with old format will not be allowed */
appendStringInfoString(detail,
"Continuous aggregates with partials will not be supported.");
appendStringInfoString(hint,
"Define Continuous aggregates with finalized parameter set to "
"true.");
return false;
}
#endif

return true; /* Query was OK and is supported */
}

Expand Down

0 comments on commit f5ad22f

Please sign in to comment.