This commit is contained in:
Alexey Milovidov 2021-10-13 03:14:44 +03:00
parent 9939e7c1eb
commit 0ad20e6613
2 changed files with 10 additions and 8 deletions

View File

@ -276,11 +276,13 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf)
{
case '+':
{
/// 123+ or +123+, just stop after 123 or +123.
if (has_number)
return ReturnType(true);
/// No digits read yet, but we already read sign, like ++, -+.
if (has_sign)
{
if (has_number)
return ReturnType(true);
if constexpr (throw_exception)
throw ParsingException(
"Cannot parse number with multiple sign (+/-) characters",
@ -294,11 +296,11 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf)
}
case '-':
{
if (has_number)
return ReturnType(true);
if (has_sign)
{
if (has_number)
return ReturnType(true);
if constexpr (throw_exception)
throw ParsingException(
"Cannot parse number with multiple sign (+/-) characters",

View File

@ -3,8 +3,8 @@ select toInt64('+-1'); -- { serverError 72; }
select toInt64('++1'); -- { serverError 72; }
select toInt64('++'); -- { serverError 72; }
select toInt64('+'); -- { serverError 72; }
select toInt64('1+1'); -- { serverError 72; }
select toInt64('1-1'); -- { serverError 72; }
select toInt64('1+1'); -- { serverError 6; }
select toInt64('1-1'); -- { serverError 6; }
select toInt64(''); -- { serverError 32; }
select toInt64('1');
select toInt64('-1');