mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #52467 from hanfei1991/hanfei/refine-52451
do not throw exception in OptimizedRegularExpressionImpl::analyze
This commit is contained in:
commit
a104ce6b3b
@ -1,5 +1,6 @@
|
||||
#include <limits>
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/logger_useful.h>
|
||||
#include <Common/PODArray.h>
|
||||
#include <Common/checkStackSize.h>
|
||||
#include <Common/OptimizedRegularExpression.h>
|
||||
@ -423,6 +424,7 @@ void OptimizedRegularExpressionImpl<thread_safe>::analyze(
|
||||
bool & is_trivial,
|
||||
bool & required_substring_is_prefix,
|
||||
std::vector<std::string> & alternatives)
|
||||
try
|
||||
{
|
||||
Literals alternative_literals;
|
||||
Literal required_literal;
|
||||
@ -432,12 +434,20 @@ void OptimizedRegularExpressionImpl<thread_safe>::analyze(
|
||||
for (auto & lit : alternative_literals)
|
||||
alternatives.push_back(std::move(lit.literal));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
required_substring = "";
|
||||
is_trivial = false;
|
||||
required_substring_is_prefix = false;
|
||||
alternatives.clear();
|
||||
LOG_ERROR(&Poco::Logger::get("OptimizeRegularExpression"), "Analyze RegularExpression failed, got error: {}", DB::getCurrentExceptionMessage(false));
|
||||
}
|
||||
|
||||
template <bool thread_safe>
|
||||
OptimizedRegularExpressionImpl<thread_safe>::OptimizedRegularExpressionImpl(const std::string & regexp_, int options)
|
||||
{
|
||||
std::vector<std::string> alternativesDummy; /// this vector extracts patterns a,b,c from pattern (a|b|c). for now it's not used.
|
||||
analyze(regexp_, required_substring, is_trivial, required_substring_is_prefix, alternativesDummy);
|
||||
std::vector<std::string> alternatives_dummy; /// this vector extracts patterns a,b,c from pattern (a|b|c). for now it's not used.
|
||||
analyze(regexp_, required_substring, is_trivial, required_substring_is_prefix, alternatives_dummy);
|
||||
|
||||
|
||||
/// Just three following options are supported
|
||||
|
@ -1 +1 @@
|
||||
SELECT match('', repeat('(', 100000)); -- { serverError 306 }
|
||||
SELECT match('', repeat('(', 100000)); -- { serverError 427 }
|
||||
|
Loading…
Reference in New Issue
Block a user