Merge pull request #30244 from evillique/fix_like_function

Fix `LIKE` function
This commit is contained in:
Kseniia Sumarokova 2021-10-25 16:35:37 +03:00 committed by GitHub
commit 377b937aa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -200,7 +200,7 @@ struct MatchImpl
}
/// We check that the entry does not pass through the boundaries of strings.
if (pos + strstr_pattern.size() < begin + offsets[i])
if (pos + required_substring.size() < begin + offsets[i])
{
/// And if it does not, if necessary, we check the regexp.
@ -344,7 +344,7 @@ struct MatchImpl
const UInt8 * next_pos = begin;
/// If required substring is larger than string size - it cannot be found.
if (strstr_pattern.size() <= n)
if (required_substring.size() <= n)
{
Searcher searcher(required_substring.data(), required_substring.size(), end - pos);
@ -360,7 +360,7 @@ struct MatchImpl
}
next_pos += n;
if (pos + strstr_pattern.size() <= next_pos)
if (pos + required_substring.size() <= next_pos)
{
/// And if it does not, if necessary, we check the regexp.

View File

@ -0,0 +1,2 @@
1
1 1 1 1 1 1

View File

@ -0,0 +1,10 @@
SELECT 'r\\a1bbb' LIKE '%r\\\\a1%bbb%' AS res;
WITH lower('\RealVNC\WinVNC4 /v password') as CommandLine
SELECT
CommandLine LIKE '%\\\\realvnc\\\\winvnc4%password%' as t1,
CommandLine LIKE '%\\\\realvnc\\\\winvnc4 %password%' as t2,
CommandLine LIKE '%\\\\realvnc\\\\winvnc4%password' as t3,
CommandLine LIKE '%\\\\realvnc\\\\winvnc4 %password' as t4,
CommandLine LIKE '%realvnc%winvnc4%password%' as t5,
CommandLine LIKE '%\\\\winvnc4%password%' as t6;