fix toUInt256 stack overflow

This commit is contained in:
fenglv 2020-11-21 12:59:40 +00:00
parent c7e88087cd
commit 268b15f221
3 changed files with 19 additions and 0 deletions

View File

@ -153,6 +153,9 @@ struct ConvertImpl
{
if constexpr (std::is_same_v<FromFieldType, UInt128> || std::is_same_v<ToFieldType, UInt128>)
throw Exception("Unexpected UInt128 to big int conversion", ErrorCodes::NOT_IMPLEMENTED);
/// If From Data is Nan or Inf, throw exception
else if (!isFinite(vec_from[i]))
throw Exception("Unexpected inf or nan to big int conversion", ErrorCodes::NOT_IMPLEMENTED);
else
vec_to[i] = bigint_cast<ToFieldType>(vec_from[i]);
}

View File

@ -0,0 +1,6 @@
-9223372036854775808
170141183460469231731687303715884105727
-9223372036854775808
170141183460469231731687303715884105727
0
0

View File

@ -0,0 +1,10 @@
SELECT toInt64(inf);
SELECT toInt128(inf);
SELECT toInt256(inf); -- { serverError 48 }
SELECT toInt64(nan);
SELECT toInt128(nan);
SELECT toInt256(nan); -- { serverError 48 }
SELECT toUInt64(inf);
SELECT toUInt256(inf); -- { serverError 48 }
SELECT toUInt64(nan);
SELECT toUInt256(nan); -- { serverError 48 }