Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed metric suffix silently ignored in settings value #7678

Merged
merged 17 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbms/src/Core/SettingsCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void SettingNumber<Type>::set(const Field & x)
template <typename Type>
void SettingNumber<Type>::set(const String & x)
{
set(parse<Type>(x));
set(completeParse<Type>(x));
}

template <>
Expand Down
36 changes: 36 additions & 0 deletions dbms/src/IO/ReadHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf)
return ReturnType(true);
}

template <typename T>
void completeReadIntTextImpl(T & x, ReadBuffer & buf)
{
readIntTextImpl<T, void>(x, buf);
assertEOF(buf);
}

template <typename T>
void readIntText(T & x, ReadBuffer & buf)
{
Expand Down Expand Up @@ -875,6 +882,35 @@ inline T parse(const char * data, size_t size)
return res;
}

template <typename T>
std::enable_if_t<is_integral_v<T>, T>
inline completeParse(const char * data, size_t size)
{
T res;
ReadBufferFromMemory buf(data, size);
completeReadIntTextImpl<T>(res, buf);
return res;
}

template <typename T>
std::enable_if_t<!is_integral_v<T>, T>
inline completeParse(const char * data, size_t size)
{
return parse<T>(data, size);
}

template <typename T>
inline T completeParse(const String & s)
{
return completeParse<T>(s.data(), s.size());
}

template <typename T>
inline T completeParse(const char * data)
{
return completeParse<T>(data, strlen(data));
}

template <typename T>
inline T parse(const char * data)
{
Expand Down