Skip to content

Commit

Permalink
Fix datetime parse error in chunk constraint creation
Browse files Browse the repository at this point in the history
With certain timezone settings chunk constraint creation could
fail as we convert the internal time to string when creating
the chunk constraint leading to parse errors when the produces
string could not be parsed back.
  • Loading branch information
svenklemm committed Nov 7, 2024
1 parent 98780f7 commit 7faf5f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .unreleased/pr_7426
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #7426 Fix datetime parsing error in chunk constraint creation
10 changes: 9 additions & 1 deletion src/chunk_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,17 @@ create_dimension_check_constraint(const Dimension *dim, const DimensionSlice *sl
enddat = ts_internal_to_time_value(slice->fd.range_end, dim->fd.column_type);
}

/* Convert internal format datums to string (output) datums */
/*
* Convert internal format datums to string (output) datums.
*
* We are forcing ISO datestyle here to prevent parsing errors with
* certain timezone/datestyle combinations.
*/
int current_datestyle = DateStyle;
DateStyle = USE_ISO_DATES;
startdat = OidFunctionCall1(outfuncid, startdat);
enddat = OidFunctionCall1(outfuncid, enddat);
DateStyle = current_datestyle;

/* Elide range constraint for +INF or -INF */
if (slice->fd.range_start != PG_INT64_MIN)
Expand Down

0 comments on commit 7faf5f7

Please sign in to comment.