Check out of range values in FieldVisitorConverToNumber

This commit is contained in:
Alexey Milovidov 2021-04-10 23:38:14 +03:00
parent f33498c73b
commit 1f2226b9db
3 changed files with 9 additions and 0 deletions

View File

@ -188,9 +188,16 @@ public:
}
if constexpr (std::is_same_v<Decimal256, T>)
{
return Int256(x);
}
else
{
if (x > std::numeric_limits<T>::max() || x < std::numeric_limits<T>::lowest())
throw Exception("Cannot convert out of range floating point value to integer type", ErrorCodes::CANNOT_CONVERT_TYPE);
return T(x);
}
}
T operator() (const UInt128 &) const

View File

@ -0,0 +1,2 @@
SELECT uniqUpTo(1e100)(number) FROM numbers(5); -- { serverError 70 }
SELECT uniqUpTo(-1e100)(number) FROM numbers(5); -- { serverError 70 }