Search before asking
Version
master (after PR #62262)
What happened
count_substrings('ccc', 'cc') returns 2 instead of expected 1 (non-overlapping count).
The regression test test_string_all.groovy expects 1, but BE returns 2, causing cloud_p0 CI failures.
Root Cause
In PR #62262, function_string.h was split into function_string_search.cpp. The find_pos() function checks pos < str_size but does not verify pos + pattern_ref.size <= str_size, so it matches a pattern that extends beyond the string boundary via memcmp_small_allow_overflow15.
// function_string_search.cpp, find_pos()
while (pos < str_size && // ← should be: pos + pattern_ref.size <= str_size
memcmp_small_allow_overflow15(...)) {
pos++;
}
For count_substrings('ccc', 'cc'):
- pos=0: matches
cc at [0,1] → count=1, advance to pos=2
- pos=2:
pos < str_size (2 < 3) is true, memcmp reads bytes [2,3] which overflows → false match → count=2
Expected behavior
count_substrings('ccc', 'cc') should return 1 (non-overlapping).
How to reproduce
SELECT count_substrings('ccc', 'cc');
-- Returns: 2
-- Expected: 1
Anything else
This causes qt_count_substrings_53 in test_string_all.groovy to fail in CI.
Introduced by refactoring PR #62262.
Search before asking
Version
master (after PR #62262)
What happened
count_substrings('ccc', 'cc')returns 2 instead of expected 1 (non-overlapping count).The regression test
test_string_all.groovyexpects 1, but BE returns 2, causingcloud_p0CI failures.Root Cause
In PR #62262,
function_string.hwas split intofunction_string_search.cpp. Thefind_pos()function checkspos < str_sizebut does not verifypos + pattern_ref.size <= str_size, so it matches a pattern that extends beyond the string boundary viamemcmp_small_allow_overflow15.For
count_substrings('ccc', 'cc'):ccat [0,1] → count=1, advance to pos=2pos < str_size(2 < 3) is true, memcmp reads bytes [2,3] which overflows → false match → count=2Expected behavior
count_substrings('ccc', 'cc')should return 1 (non-overlapping).How to reproduce
Anything else
This causes
qt_count_substrings_53intest_string_all.groovyto fail in CI.Introduced by refactoring PR #62262.