mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Fix UBSan report in rounding to years intervals
This commit is contained in:
parent
eaeb4a3bf0
commit
badd5165da
@ -807,7 +807,14 @@ public:
|
||||
return toFirstDayNumOfYear(v);
|
||||
|
||||
const LUTIndex i = toLUTIndex(v);
|
||||
return toDayNum(years_lut[lut[i].year / years * years - DATE_LUT_MIN_YEAR]);
|
||||
|
||||
UInt16 year = lut[i].year / years * years;
|
||||
|
||||
/// For example, rounding down 1925 to 100 years will be 1900, but it's less than min supported year.
|
||||
if (unlikely(year < DATE_LUT_MIN_YEAR))
|
||||
year = DATE_LUT_MIN_YEAR;
|
||||
|
||||
return toDayNum(years_lut[year - DATE_LUT_MIN_YEAR]);
|
||||
}
|
||||
|
||||
inline ExtendedDayNum toStartOfQuarterInterval(ExtendedDayNum d, UInt64 quarters) const
|
||||
|
1
tests/queries/0_stateless/01761_round_year_bounds.sql
Normal file
1
tests/queries/0_stateless/01761_round_year_bounds.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT toStartOfInterval(toDateTime(-9223372036854775808), toIntervalYear(100), 'Europe/Moscow') FORMAT Null;
|
Loading…
Reference in New Issue
Block a user