1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-1390 Fix SUBSTRING_INDEX for negative count

If negative count number is more than the number of characters in the
string then it should always return the string.

For example if a table contains SUBSTRING_INDEX('zzz', 'z', -5) should
return 'zzz'. Before this patch it would return NULL.
This commit is contained in:
Andrew Hutchings
2018-05-10 18:32:22 +01:00
parent e66cceb1a3
commit baf42e7b4a

View File

@ -71,6 +71,9 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
if ( count > (int64_t) end )
return str;
if (( count < 0 ) && ((count * -1) > end))
return str;
string value = str;
if ( count > 0 ) {