Loading mysql-test/r/func_str.result +11 −0 Original line number Diff line number Diff line Loading @@ -1940,6 +1940,17 @@ abcxx select lpad('abc', cast(5 as unsigned integer), 'x'); lpad('abc', cast(5 as unsigned integer), 'x') xxabc create table t1(f1 longtext); insert into t1 values ("123"),("456"); select substring(f1,1,1) from t1 group by 1; substring(f1,1,1) 1 4 create table t2(f1 varchar(3)); insert into t1 values ("123"),("456"); select substring(f1,4,1), substring(f1,-4,1) from t2; substring(f1,4,1) substring(f1,-4,1) drop table t1,t2; DROP TABLE IF EXISTS t1; CREATE TABLE `t1` ( `id` varchar(20) NOT NULL, Loading mysql-test/t/func_str.test +11 −0 Original line number Diff line number Diff line Loading @@ -1008,6 +1008,17 @@ select repeat('a', cast(2 as unsigned int)); select rpad('abc', cast(5 as unsigned integer), 'x'); select lpad('abc', cast(5 as unsigned integer), 'x'); # # Bug#15757: Wrong SUBSTRING() result when a tmp table was employed. # create table t1(f1 longtext); insert into t1 values ("123"),("456"); select substring(f1,1,1) from t1 group by 1; create table t2(f1 varchar(3)); insert into t1 values ("123"),("456"); select substring(f1,4,1), substring(f1,-4,1) from t2; drop table t1,t2; # # Bug #25197 :repeat function returns null when using table field directly as count # Loading sql/item_strfunc.cc +3 −4 Original line number Diff line number Diff line Loading @@ -1184,11 +1184,10 @@ void Item_func_substr::fix_length_and_dec() if (args[1]->const_item()) { int32 start= (int32) args[1]->val_int(); start= (int32)((start < 0) ? max_length + start : start - 1); if (start < 0 || start >= (int32) max_length) max_length=0; /* purecov: inspected */ if (start < 0) max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start); else max_length-= (uint) start; max_length-= min((uint)(start - 1), max_length); } if (arg_count == 3 && args[2]->const_item()) { Loading Loading
mysql-test/r/func_str.result +11 −0 Original line number Diff line number Diff line Loading @@ -1940,6 +1940,17 @@ abcxx select lpad('abc', cast(5 as unsigned integer), 'x'); lpad('abc', cast(5 as unsigned integer), 'x') xxabc create table t1(f1 longtext); insert into t1 values ("123"),("456"); select substring(f1,1,1) from t1 group by 1; substring(f1,1,1) 1 4 create table t2(f1 varchar(3)); insert into t1 values ("123"),("456"); select substring(f1,4,1), substring(f1,-4,1) from t2; substring(f1,4,1) substring(f1,-4,1) drop table t1,t2; DROP TABLE IF EXISTS t1; CREATE TABLE `t1` ( `id` varchar(20) NOT NULL, Loading
mysql-test/t/func_str.test +11 −0 Original line number Diff line number Diff line Loading @@ -1008,6 +1008,17 @@ select repeat('a', cast(2 as unsigned int)); select rpad('abc', cast(5 as unsigned integer), 'x'); select lpad('abc', cast(5 as unsigned integer), 'x'); # # Bug#15757: Wrong SUBSTRING() result when a tmp table was employed. # create table t1(f1 longtext); insert into t1 values ("123"),("456"); select substring(f1,1,1) from t1 group by 1; create table t2(f1 varchar(3)); insert into t1 values ("123"),("456"); select substring(f1,4,1), substring(f1,-4,1) from t2; drop table t1,t2; # # Bug #25197 :repeat function returns null when using table field directly as count # Loading
sql/item_strfunc.cc +3 −4 Original line number Diff line number Diff line Loading @@ -1184,11 +1184,10 @@ void Item_func_substr::fix_length_and_dec() if (args[1]->const_item()) { int32 start= (int32) args[1]->val_int(); start= (int32)((start < 0) ? max_length + start : start - 1); if (start < 0 || start >= (int32) max_length) max_length=0; /* purecov: inspected */ if (start < 0) max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start); else max_length-= (uint) start; max_length-= min((uint)(start - 1), max_length); } if (arg_count == 3 && args[2]->const_item()) { Loading