From: Date: June 6 2006 7:36pm Subject: bk commit into 4.1 tree (bar:1.2487) BUG#11728 List-Archive: http://lists.mysql.com/commits/7331 X-Bug: 11728 Message-Id: <200606061736.k56HatpO004007@bar.intranet.mysql.r18.ru> Below is the list of changes that have just been committed into a local 4.1 repository of bar. When bar does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2487 06/06/06 22:36:49 bar@stripped +3 -0 Bug#11728 string function LEFT, strange undocumented behaviour, strict mode Problem: LEFT and RIGHT returnd empty string if the second argument was NULL. Fix: return NULL if any argument is NULL sql/item_strfunc.cc 1.242 06/06/06 22:36:44 bar@stripped +2 -2 Return NULL if either of arguments is NULL mysql-test/t/func_str.test 1.82 06/06/06 22:36:44 bar@stripped +5 -0 Adding test case mysql-test/r/func_str.result 1.100 06/06/06 22:36:44 bar@stripped +3 -0 Adding test case # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: bar # Host: bar.intranet.mysql.r18.ru # Root: /usr/home/bar/mysql-4.1.b11228 --- 1.241/sql/item_strfunc.cc 2006-05-08 06:39:19 +05:00 +++ 1.242/sql/item_strfunc.cc 2006-06-06 22:36:44 +05:00 @@ -978,7 +978,7 @@ String *Item_func_left::val_str(String * long length =(long) args[1]->val_int(); uint char_pos; - if ((null_value=args[0]->null_value)) + if ((null_value=(args[0]->null_value || args[1]->null_value))) return 0; if (length <= 0) return &my_empty_string; @@ -1018,7 +1018,7 @@ String *Item_func_right::val_str(String String *res =args[0]->val_str(str); long length =(long) args[1]->val_int(); - if ((null_value=args[0]->null_value)) + if ((null_value=(args[0]->null_value || args[1]->null_value))) return 0; /* purecov: inspected */ if (length <= 0) return &my_empty_string; /* purecov: inspected */ --- 1.99/mysql-test/r/func_str.result 2006-05-08 06:38:08 +05:00 +++ 1.100/mysql-test/r/func_str.result 2006-06-06 22:36:44 +05:00 @@ -33,6 +33,9 @@ position(binary 'll' in 'hello') positio select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ; left('hello',2) right('hello',2) substring('hello',2,2) mid('hello',1,5) he lo el hello +select left('hello',null), right('hello',null); +left('hello',null) right('hello',null) +NULL NULL select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ; concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) happy --- 1.81/mysql-test/t/func_str.test 2006-05-08 06:37:13 +05:00 +++ 1.82/mysql-test/t/func_str.test 2006-06-06 22:36:44 +05:00 @@ -19,6 +19,11 @@ select locate('he','hello'),locate('he', select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE'); select position(binary 'll' in 'hello'),position('a' in binary 'hello'); select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ; +# +# Bug#11728 string function LEFT, +# strange undocumented behaviour, strict mode +# +select left('hello',null), right('hello',null); select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ; select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1); select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1);