Loading mysql-test/r/func_str.result +6 −0 Original line number Diff line number Diff line Loading @@ -282,3 +282,9 @@ NULL NULL 1 1 n two 'two' 0 0 'two' four 'four' 0 0 'four' drop table t1; select trim(trailing 'foo' from 'foo'); trim(trailing 'foo' from 'foo') select trim(leading 'foo' from 'foo'); trim(leading 'foo' from 'foo') mysql-test/t/func_str.test +7 −0 Original line number Diff line number Diff line Loading @@ -172,3 +172,10 @@ create table t1(a char(4)); insert into t1 values ('one'),(NULL),('two'),('four'); select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1; drop table t1; # # Bug #5498: TRIM fails with LEADING or TRAILING if remstr = str # select trim(trailing 'foo' from 'foo'); select trim(leading 'foo' from 'foo'); sql/item_strfunc.cc +3 −3 Original line number Diff line number Diff line Loading @@ -1135,7 +1135,7 @@ String *Item_func_ltrim::val_str(String *str) { const char *r_ptr=remove_str->ptr(); end-=remove_length; while (ptr < end && !memcmp(ptr,r_ptr,remove_length)) while (ptr <= end && !memcmp(ptr, r_ptr, remove_length)) ptr+=remove_length; end+=remove_length; } Loading Loading @@ -1206,7 +1206,7 @@ String *Item_func_rtrim::val_str(String *str) else #endif /* USE_MB */ { while (ptr + remove_length < end && while (ptr + remove_length <= end && !memcmp(end-remove_length, r_ptr, remove_length)) end-=remove_length; } Loading Loading
mysql-test/r/func_str.result +6 −0 Original line number Diff line number Diff line Loading @@ -282,3 +282,9 @@ NULL NULL 1 1 n two 'two' 0 0 'two' four 'four' 0 0 'four' drop table t1; select trim(trailing 'foo' from 'foo'); trim(trailing 'foo' from 'foo') select trim(leading 'foo' from 'foo'); trim(leading 'foo' from 'foo')
mysql-test/t/func_str.test +7 −0 Original line number Diff line number Diff line Loading @@ -172,3 +172,10 @@ create table t1(a char(4)); insert into t1 values ('one'),(NULL),('two'),('four'); select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1; drop table t1; # # Bug #5498: TRIM fails with LEADING or TRAILING if remstr = str # select trim(trailing 'foo' from 'foo'); select trim(leading 'foo' from 'foo');
sql/item_strfunc.cc +3 −3 Original line number Diff line number Diff line Loading @@ -1135,7 +1135,7 @@ String *Item_func_ltrim::val_str(String *str) { const char *r_ptr=remove_str->ptr(); end-=remove_length; while (ptr < end && !memcmp(ptr,r_ptr,remove_length)) while (ptr <= end && !memcmp(ptr, r_ptr, remove_length)) ptr+=remove_length; end+=remove_length; } Loading Loading @@ -1206,7 +1206,7 @@ String *Item_func_rtrim::val_str(String *str) else #endif /* USE_MB */ { while (ptr + remove_length < end && while (ptr + remove_length <= end && !memcmp(end-remove_length, r_ptr, remove_length)) end-=remove_length; } Loading