Skip to content

Commit

Permalink
Fix CAgg migration with custom settings
Browse files Browse the repository at this point in the history
The CAgg migration path contained two bugs. This PR fixes both. A typo
in the column type prevented 'timestamp with time zone' buckets from
being handled properly. In addition, a custom setting of the datestyle
could create errors during the parsing of the generated timestamp
values.

Fixes: timescale#5359
  • Loading branch information
jnidzwetzki committed Mar 5, 2024
1 parent 9f2d4e9 commit de16186
Show file tree
Hide file tree
Showing 4 changed files with 518 additions and 94 deletions.
5 changes: 3 additions & 2 deletions sql/cagg_migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ BEGIN
ELSE
_interval_value := _time_interval::TEXT;
_interval_type := 'interval';
_watermark := COALESCE(_timescaledb_functions.to_timestamp(_timescaledb_functions.cagg_watermark(_cagg_data.mat_hypertable_id)), '-infinity'::timestamptz)::TEXT;

IF _bucket_column_type = 'timestamp with timezone' THEN
-- We expect an ISO date later in parsing (i.e., min value has to be '4714-11-24 00:53:28+00:53:28 BC')
SET LOCAL datestyle = 'ISO, MDY';
IF _bucket_column_type = 'timestamp with time zone' THEN
_watermark := COALESCE(_timescaledb_functions.to_timestamp(_timescaledb_functions.cagg_watermark(_cagg_data.mat_hypertable_id)), '-infinity'::timestamptz)::TEXT;
ELSE
_watermark := COALESCE(_timescaledb_functions.to_timestamp_without_timezone(_timescaledb_functions.cagg_watermark(_cagg_data.mat_hypertable_id)), '-infinity'::timestamp)::TEXT;
Expand Down
Loading

0 comments on commit de16186

Please sign in to comment.