This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch dev-1.1.2 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/dev-1.1.2 by this push: new 9414c9ba80 [fix](str_to_date) str_to_date support format without leading zero (#11817) 9414c9ba80 is described below commit 9414c9ba804d19f2dce8c46e620d5c7fe0e1c980 Author: camby <104178...@qq.com> AuthorDate: Tue Aug 16 18:23:16 2022 +0800 [fix](str_to_date) str_to_date support format without leading zero (#11817) Co-authored-by: cambyzju <zhuxiaol...@baidu.com> --- be/src/runtime/datetime_value.cpp | 4 ++++ be/src/vec/runtime/vdatetime_value.cpp | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/be/src/runtime/datetime_value.cpp b/be/src/runtime/datetime_value.cpp index b7202916d5..14a4ae35f1 100644 --- a/be/src/runtime/datetime_value.cpp +++ b/be/src/runtime/datetime_value.cpp @@ -996,6 +996,10 @@ static bool str_to_int64(const char* ptr, const char** endptr, int64_t* ret) { if (ptr >= end) { return false; } + // a valid input should at least contains one digit + if (!isdigit(*ptr)) { + return false; + } // Skip '0' while (ptr < end && *ptr == '0') { ptr++; diff --git a/be/src/vec/runtime/vdatetime_value.cpp b/be/src/vec/runtime/vdatetime_value.cpp index 4b5b00d3f1..3efc4f25d6 100644 --- a/be/src/vec/runtime/vdatetime_value.cpp +++ b/be/src/vec/runtime/vdatetime_value.cpp @@ -979,6 +979,10 @@ static bool str_to_int64(const char* ptr, const char** endptr, int64_t* ret) { if (ptr >= end) { return false; } + // a valid input should at least contains one digit + if (!isdigit(*ptr)) { + return false; + } // Skip '0' while (ptr < end && *ptr == '0') { ptr++; @@ -988,10 +992,7 @@ static bool str_to_int64(const char* ptr, const char** endptr, int64_t* ret) { n_end = end; } uint64_t value_1 = 0; - while (ptr < n_end) { - if (!isdigit(*ptr)) { - return false; - } + while (ptr < n_end && isdigit(*ptr)) { value_1 *= 10; value_1 += *ptr++ - '0'; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org