From cfa4548ba5277166fe768994b0c3fde0709088a7 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 21 Apr 2014 10:13:38 +0400 Subject: MDEV-6134 SUBSTRING_INDEX returns wrong result for 8bit character sets when delimiter is not found --- sql/item_strfunc.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/item_strfunc.cc') diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d00eb8002f2..6edf0173b18 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1404,6 +1404,8 @@ String *Item_func_substr_index::val_str(String *str) break; } } + if (count) + return res; // Didn't find, return org string } } /* -- cgit v1.2.1 From 213f10363e1134fdb39842f55876db1136496ff3 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 21 Apr 2014 13:19:32 +0400 Subject: MDEV-6045 MySQL Bug#11829861 - SUBSTRING_INDEX() RESULTS "OMIT" CHARACTER WHEN USED INSIDE LOWER() --- sql/item_strfunc.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sql/item_strfunc.cc') diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 6edf0173b18..4044ee3cd19 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1095,7 +1095,7 @@ String *Item_str_conv::val_str(String *str) if (multiply == 1) { uint len; - res= copy_if_not_alloced(str,res,res->length()); + res= copy_if_not_alloced(&tmp_value, res, res->length()); len= converter(collation.collation, (char*) res->ptr(), res->length(), (char*) res->ptr(), res->length()); DBUG_ASSERT(len <= res->length()); @@ -1296,8 +1296,10 @@ void Item_func_substr_index::fix_length_and_dec() String *Item_func_substr_index::val_str(String *str) { DBUG_ASSERT(fixed == 1); + char buff[MAX_FIELD_WIDTH]; + String tmp(buff,sizeof(buff),system_charset_info); String *res= args[0]->val_str(str); - String *delimiter= args[1]->val_str(&tmp_value); + String *delimiter= args[1]->val_str(&tmp); int32 count= (int32) args[2]->val_int(); uint offset; -- cgit v1.2.1