mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
change as request
This commit is contained in:
parent
de5474c9f9
commit
2f7ea79d94
@ -118,16 +118,13 @@ struct MatchImpl
|
||||
if (haystack_offsets.empty())
|
||||
return;
|
||||
|
||||
/// Fast path for [I]LIKE, because the result is always true or false
|
||||
/// col [i]like '%%'
|
||||
/// col not [i]like '%%'
|
||||
/// col like '%'
|
||||
/// col not [i]like '%'
|
||||
/// match(like, '^$')
|
||||
if ((is_like && (needle == "%%" or needle == "%")) || (!is_like && needle == ".*"))
|
||||
/// Shortcut for the silly but practical case that the pattern matches everything/nothing independently of the haystack:
|
||||
/// - col [not] [i]like '%' / '%%'
|
||||
/// - match(col, '.*')
|
||||
if ((is_like && (needle == "%" or needle == "%%")) || (!is_like && (needle == ".*" || needle == ".*?")))
|
||||
{
|
||||
for (auto & re : res)
|
||||
re = !negate;
|
||||
for (auto & x : res)
|
||||
x = !negate;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -280,6 +277,16 @@ struct MatchImpl
|
||||
if (haystack.empty())
|
||||
return;
|
||||
|
||||
/// Shortcut for the silly but practical case that the pattern matches everything/nothing independently of the haystack:
|
||||
/// - col [not] [i]like '%' / '%%'
|
||||
/// - match(col, '.*')
|
||||
if ((is_like && (needle == "%" or needle == "%%")) || (!is_like && (needle == ".*" || needle == ".*?")))
|
||||
{
|
||||
for (auto & x : res)
|
||||
x = !negate;
|
||||
return;
|
||||
}
|
||||
|
||||
/// Special case that the [I]LIKE expression reduces to finding a substring in a string
|
||||
String strstr_pattern;
|
||||
if (is_like && impl::likePatternIsSubstring(needle, strstr_pattern))
|
||||
|
Loading…
Reference in New Issue
Block a user