mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
fix: prevent overflow error in utc timestamp conversion
This commit is contained in:
parent
bdd18b35b2
commit
bb10f5c27e
@ -88,10 +88,20 @@ namespace
|
||||
{
|
||||
UInt32 date_time_val = date_time_col.getElement(i);
|
||||
auto time_zone_offset = time_zone.timezoneOffset(date_time_val);
|
||||
if constexpr (toUTC)
|
||||
if constexpr (toUTC) {
|
||||
result_data[i] = date_time_val - static_cast<UInt32>(time_zone_offset);
|
||||
else
|
||||
if (result_data[i] > date_time_val) {
|
||||
// Overflow occured
|
||||
result_data[i] = UINT32_MAX;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result_data[i] = date_time_val + static_cast<UInt32>(time_zone_offset);
|
||||
if (result_data[i] < date_time_val) {
|
||||
// Underflow occurred
|
||||
result_data[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result_column;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user