change as request

This commit is contained in:
taiyang-li 2023-01-16 10:42:58 +08:00
parent de5474c9f9
commit 2f7ea79d94

View File

@ -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))