diff --git a/dbms/src/Core/SettingsCommon.cpp b/dbms/src/Core/SettingsCommon.cpp index 0d6130cc874..06622499434 100644 --- a/dbms/src/Core/SettingsCommon.cpp +++ b/dbms/src/Core/SettingsCommon.cpp @@ -65,7 +65,7 @@ template void SettingNumber::set(const String & x) { std::cerr << "\n\nEnter in set_function_for_string\n\n"; - set(parse(x)); + set(completeParse(x)); } template <> diff --git a/dbms/src/IO/ReadHelpers.h b/dbms/src/IO/ReadHelpers.h index 6f4b53ef968..1e36489e89a 100644 --- a/dbms/src/IO/ReadHelpers.h +++ b/dbms/src/IO/ReadHelpers.h @@ -299,7 +299,8 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf) res += *buf.position() - '0'; break; default: - throw Exception("Invalid characters used", ErrorCodes::CANNOT_PARSE_NUMBER); + x = negative ? -res : res; + return ReturnType(true); } ++buf.position(); } @@ -308,6 +309,15 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf) return ReturnType(true); } +template +void completeReadIntTextImpl(T & x, ReadBuffer & buf) +{ + std::cerr << "\n\nEnter in exactReadIntTextImpl function\n\n"; + readIntTextImpl(x, buf); + if (!buf.eof()) + throw Exception("Invalid characters used", ErrorCodes::CANNOT_PARSE_NUMBER); +} + template void readIntText(T & x, ReadBuffer & buf) { @@ -570,6 +580,9 @@ inline void readUUIDText(UUID & uuid, ReadBuffer & buf) template inline T parse(const char * data, size_t size); +template +inline T exactParse(const char * data, size_t size); + template inline T parseFromString(const String & str) { @@ -676,7 +689,7 @@ readText(T & x, ReadBuffer & buf) { readIntText(x, buf); std::cerr << "\n\nEnter template inline std::enable_if_t, void> -readText(T & x, ReadBuffer & buf) { readFloatText(x, buf); std::cerr << "\n\nEnter in readText for float\n\n";} +readText(T & x, ReadBuffer & buf) { readFloatText(x, buf);} inline void readText(bool & x, ReadBuffer & buf) { readBoolText(x, buf); } inline void readText(String & x, ReadBuffer & buf) { readEscapedString(x, buf); } @@ -879,6 +892,37 @@ inline T parse(const char * data, size_t size) return res; } +template +std::enable_if_t, T> +inline completeParse(const char * data, size_t size) +{ + std::cerr << "\n\nenter in exact parse function\n\n"; + T res; + ReadBufferFromMemory buf(data, size); + completeReadIntTextImpl(res, buf); + return res; +} + +template +std::enable_if_t, T> +inline completeParse(const char * data, size_t size) +{ + return parse(data, size); +} + +template +inline T completeParse(const String & s) +{ + std::cerr << "\n\nenter in exact parse function_for_string\n\n"; + return completeParse(s.data(), s.size()); +} + +template +inline T completeParse(const char * data) +{ + return completeParse(data, strlen(data)); +} + template inline T parse(const char * data) {