Merge pull request #70914 from yariks5s/fix_logical_error_substrings

Fix logical error for substrings
This commit is contained in:
Yarik Briukhovetskyi 2024-10-25 15:20:29 +00:00 committed by GitHub
commit bc98110628
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -62,7 +62,7 @@ struct CountSubstringsImpl
while (pos < end && end != (pos = searcher.search(pos, end - pos)))
{
/// Determine which index it refers to.
while (begin + haystack_offsets[i] <= pos)
while (i < input_rows_count - 1 && begin + haystack_offsets[i] <= pos)
++i;
auto start = start_pos != nullptr ? start_pos->getUInt(i) : 0;
@ -80,9 +80,10 @@ struct CountSubstringsImpl
continue;
}
pos = begin + haystack_offsets[i];
++i;
chassert(i < input_rows_count);
++i;
if (i >= input_rows_count)
break; // Handle the end of the haystacks
}
}

View File

@ -0,0 +1 @@
1150aaa1116

View File

@ -0,0 +1,9 @@
SELECT
concat(concat(11),
5,
countSubstringsCaseInsensitive(
concat(countSubstringsCaseInsensitive(
concat(11, toString(number), materialize('aaa111'), 6, materialize(6)), char(number)),
'aaa111'),
char(countSubstringsCaseInsensitive(concat(' test'), char(toLowCardinality(6))))),
'aaa111', 6) FROM numbers(1);