This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 8c498844b040d378c0ac643c4d06af35c9cca8d1 Author: yuxuan-luo <119841515+yuxuan-...@users.noreply.github.com> AuthorDate: Tue Aug 29 10:34:12 2023 +0800 [fix](regexp_extract_all) fix be OOM when quering with regexp_extrac… (#23284) --- be/src/vec/functions/function_regexp.cpp | 5 +++++ .../sql_functions/string_functions/test_string_function_regexp.out | 6 ++++++ .../string_functions/test_string_function_regexp.groovy | 2 ++ 3 files changed, 13 insertions(+) diff --git a/be/src/vec/functions/function_regexp.cpp b/be/src/vec/functions/function_regexp.cpp index 50f845acc3..31ad61cc18 100644 --- a/be/src/vec/functions/function_regexp.cpp +++ b/be/src/vec/functions/function_regexp.cpp @@ -350,6 +350,11 @@ struct RegexpExtractAllImpl { StringOP::push_empty_string(index_now, result_data, result_offset); break; } + if (matches[0].empty()) { + StringOP::push_empty_string(index_now, result_data, result_offset); + pos += 1; + continue; + } res_matches.push_back(matches[1]); auto offset = std::string(str_pos, str_size).find(std::string(matches[0].as_string())); pos += offset + matches[0].size(); diff --git a/regression-test/data/query_p0/sql_functions/string_functions/test_string_function_regexp.out b/regression-test/data/query_p0/sql_functions/string_functions/test_string_function_regexp.out index 415b8f2822..1684a03a15 100644 --- a/regression-test/data/query_p0/sql_functions/string_functions/test_string_function_regexp.out +++ b/regression-test/data/query_p0/sql_functions/string_functions/test_string_function_regexp.out @@ -61,6 +61,12 @@ d -- !sql -- +-- !sql -- + + +-- !sql -- +['ab','c','c','c'] + -- !sql -- a-b-c diff --git a/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function_regexp.groovy b/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function_regexp.groovy index cb80939adf..e3e04a5456 100644 --- a/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function_regexp.groovy +++ b/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function_regexp.groovy @@ -56,6 +56,8 @@ suite("test_string_function_regexp") { qt_sql "SELECT regexp_extract_all('http://a.m.baidu.com/i41915i73660.htm', 'i([0-9]+)');" qt_sql "SELECT regexp_extract_all('abc=111, def=222, ghi=333', '(\"[^\"]+\"|\\\\w+)=(\"[^\"]+\"|\\\\w+)');" qt_sql "select regexp_extract_all('xxfs','f');" + qt_sql "select regexp_extract_all('asdfg', '(z|x|c|)');" + qt_sql "select regexp_extract_all('abcdfesscca', '(ab|c|)');" qt_sql "SELECT regexp_replace('a b c', \" \", \"-\");" qt_sql "SELECT regexp_replace('a b c','(b)','<\\\\1>');" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org