mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 03:25:15 +00:00
Merge pull request #45428 from hanfei1991/hanfei/fix-empty-expressions
fix regexp logical error in stress tests
This commit is contained in:
commit
3007507a8b
@ -243,13 +243,23 @@ void RegExpTreeDictionary::loadData()
|
||||
initRegexNodes(block);
|
||||
}
|
||||
initGraph();
|
||||
if (regexps.empty())
|
||||
throw Exception(ErrorCodes::INCORRECT_DICTIONARY_DEFINITION, "There are no available regular expression. Please check your config");
|
||||
#if USE_VECTORSCAN
|
||||
std::vector<std::string_view> regexps_views(regexps.begin(), regexps.end());
|
||||
hyperscan_regex = MultiRegexps::getOrSet<true, false>(regexps_views, std::nullopt);
|
||||
/// TODO: fallback when exceptions occur.
|
||||
hyperscan_regex->get();
|
||||
try
|
||||
{
|
||||
std::vector<std::string_view> regexps_views(regexps.begin(), regexps.end());
|
||||
hyperscan_regex = MultiRegexps::getOrSet<true, false>(regexps_views, std::nullopt);
|
||||
hyperscan_regex->get();
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
/// Some compile errors will be thrown as LOGICAL ERROR and cause crash, e.g. empty expression or expressions are too large.
|
||||
/// We catch the error here and rethrow again.
|
||||
/// TODO: fallback to other engine, like re2, when exceptions occur.
|
||||
throw Exception(ErrorCodes::INCORRECT_DICTIONARY_DEFINITION, "Error occurs when compiling regular expressions, reason: {}", e.message());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -76,6 +76,9 @@ INSERT INTO regexp_dictionary_source_table VALUES (2, 0, '33/tclwebkit', ['versi
|
||||
SYSTEM RELOAD dictionary regexp_dict1;
|
||||
select dictGet(regexp_dict1, ('name', 'version', 'comment'), '33/tclwebkit');
|
||||
|
||||
truncate table regexp_dictionary_source_table;
|
||||
SYSTEM RELOAD dictionary regexp_dict1; -- { serverError 489 }
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS regexp_dictionary_source_table;
|
||||
DROP TABLE IF EXISTS needle_table;
|
||||
|
Loading…
Reference in New Issue
Block a user