Loading mysql-test/r/case.result +15 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,21 @@ t1 CREATE TABLE `t1` ( `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT 'case+union+test' UNION SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; case+union+test case+union+test nobug SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END nobug SELECT 'case+union+test' UNION SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; case+union+test case+union+test nobug CREATE TABLE t1 (EMPNUM INT); INSERT INTO t1 VALUES (0), (2); CREATE TABLE t2 (EMPNUM DECIMAL (4, 2)); Loading mysql-test/t/case.test +11 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,17 @@ explain extended SELECT SHOW CREATE TABLE t1; DROP TABLE t1; # Test for BUG#10151 SELECT 'case+union+test' UNION SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; SELECT 'case+union+test' UNION SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; # # Tests for bug #9939: conversion of the arguments for COALESCE and IFNULL # Loading sql/item_cmpfunc.cc +3 −1 Original line number Diff line number Diff line Loading @@ -1420,6 +1420,8 @@ Item *Item_func_case::find_item(String *str) my_decimal *first_expr_dec, first_expr_dec_val; longlong first_expr_int; double first_expr_real; char buff[MAX_FIELD_WIDTH]; String buff_str(buff,sizeof(buff),default_charset()); /* These will be initialized later */ LINT_INIT(first_expr_str); Loading @@ -1433,7 +1435,7 @@ Item *Item_func_case::find_item(String *str) { case STRING_RESULT: // We can't use 'str' here as this may be overwritten if (!(first_expr_str= args[first_expr_num]->val_str(&str_value))) if (!(first_expr_str= args[first_expr_num]->val_str(&buff_str))) return else_expr_num != -1 ? args[else_expr_num] : 0; // Impossible break; case INT_RESULT: Loading Loading
mysql-test/r/case.result +15 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,21 @@ t1 CREATE TABLE `t1` ( `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT 'case+union+test' UNION SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; case+union+test case+union+test nobug SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END nobug SELECT 'case+union+test' UNION SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; case+union+test case+union+test nobug CREATE TABLE t1 (EMPNUM INT); INSERT INTO t1 VALUES (0), (2); CREATE TABLE t2 (EMPNUM DECIMAL (4, 2)); Loading
mysql-test/t/case.test +11 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,17 @@ explain extended SELECT SHOW CREATE TABLE t1; DROP TABLE t1; # Test for BUG#10151 SELECT 'case+union+test' UNION SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; SELECT 'case+union+test' UNION SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; # # Tests for bug #9939: conversion of the arguments for COALESCE and IFNULL # Loading
sql/item_cmpfunc.cc +3 −1 Original line number Diff line number Diff line Loading @@ -1420,6 +1420,8 @@ Item *Item_func_case::find_item(String *str) my_decimal *first_expr_dec, first_expr_dec_val; longlong first_expr_int; double first_expr_real; char buff[MAX_FIELD_WIDTH]; String buff_str(buff,sizeof(buff),default_charset()); /* These will be initialized later */ LINT_INIT(first_expr_str); Loading @@ -1433,7 +1435,7 @@ Item *Item_func_case::find_item(String *str) { case STRING_RESULT: // We can't use 'str' here as this may be overwritten if (!(first_expr_str= args[first_expr_num]->val_str(&str_value))) if (!(first_expr_str= args[first_expr_num]->val_str(&buff_str))) return else_expr_num != -1 ? args[else_expr_num] : 0; // Impossible break; case INT_RESULT: Loading