Merge pull request #8764 from 4ertus2/bugs

Fix toDecimalOrNull() with exception inside
This commit is contained in:
Artem Zuikov 2020-01-22 14:18:34 +03:00 committed by GitHub
commit 289f16978f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -101,7 +101,13 @@ inline bool readDigits(ReadBuffer & buf, T & x, unsigned int & digits, int & exp
{
++buf.position();
Int32 addition_exp = 0;
readIntText(addition_exp, buf);
if (!tryReadIntText(addition_exp, buf))
{
if constexpr (_throw_on_error)
throw Exception("Cannot parse exponent while reading decimal", ErrorCodes::CANNOT_PARSE_NUMBER);
else
return false;
}
exponent += addition_exp;
stop = true;
continue;

View File

@ -0,0 +1,3 @@
\N 1
\N 1
\N 1

View File

@ -0,0 +1,7 @@
SELECT toDecimal32('e', 1); -- { serverError 72 }
SELECT toDecimal64('e', 2); -- { serverError 72 }
SELECT toDecimal128('e', 3); -- { serverError 72 }
SELECT toDecimal32OrNull('e', 1) x, isNull(x);
SELECT toDecimal64OrNull('e', 2) x, isNull(x);
SELECT toDecimal128OrNull('e', 3) x, isNull(x);