summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-06-23 11:03:21 +0200
committerunknown <sergefp@mysql.com>2005-06-23 11:03:21 +0200
commit4775eaaaaa276caf7d7d741d7b9d73f1bdea9c00 (patch)
treede88e22c30a32b009405e1e263c2db66ffd5ded9
parent31d07866873631f79177fb1277bacfec62062c80 (diff)
parent396ef56858776bd93405f8f0c3df52922dde1d48 (diff)
downloadmariadb-git-4775eaaaaa276caf7d7d741d7b9d73f1bdea9c00.tar.gz
Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/psergey/mysql-4.1-bug10151
-rw-r--r--mysql-test/r/case.result15
-rw-r--r--mysql-test/t/case.test11
-rw-r--r--sql/item_cmpfunc.cc4
3 files changed, 29 insertions, 1 deletions
diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result
index 541560afd36..fb0bc19a67e 100644
--- a/mysql-test/r/case.result
+++ b/mysql-test/r/case.result
@@ -154,3 +154,18 @@ t1 CREATE TABLE `t1` (
`COALESCE('a' COLLATE latin1_bin,'b')` char(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
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 87e456baba7..ac60d7298ce 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -107,3 +107,14 @@ explain extended SELECT
COALESCE('a' COLLATE latin1_bin,'b');
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;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 3098e5dc77e..f24638d1a93 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1174,6 +1174,8 @@ Item *Item_func_case::find_item(String *str)
String *first_expr_str,*tmp;
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);
@@ -1186,7 +1188,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: