diff options
author | Sinisa@sinisa.nasamreza.org <> | 2002-12-16 22:16:57 +0200 |
---|---|---|
committer | Sinisa@sinisa.nasamreza.org <> | 2002-12-16 22:16:57 +0200 |
commit | 8ebc9834426820a6646b7b62c90d88bc99cef965 (patch) | |
tree | 58b92740fb2bde5c4357043d1e2970298ceb9710 | |
parent | c2f3ff6630662a6cbb74e6dd33aafe223186a95f (diff) | |
download | mariadb-git-8ebc9834426820a6646b7b62c90d88bc99cef965.tar.gz |
fix for a bug in CASE ...WHEN ...
-rw-r--r-- | mysql-test/r/case.result | 4 | ||||
-rw-r--r-- | mysql-test/t/case.test | 5 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 2 | ||||
-rw-r--r-- | sql/sql_db.cc | 2 |
4 files changed, 11 insertions, 2 deletions
diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 073164aa035..9ba33daaa4d 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -40,3 +40,7 @@ fcase count(*) nothing 2 one 1 two 1 +color +orange +yellow +green diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 79511f5f546..f2b8d42e07c 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -30,3 +30,8 @@ insert into t1 values(1),(2),(3),(4); select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase; select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase; drop table t1; +drop table if exists t; +create table t1 (row int not null, col int not null, val varchar(255) not null); +insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small'); +select max(case col when 1 then val else null end) as color from t1 group by row; +drop table if exists t; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 07704e3385f..0d10b17ad87 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -687,6 +687,8 @@ String *Item_func_case::val_str(String *str) } if (!(res=item->val_str(str))) null_value=1; + else + null_value=item->null_value; return res; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index e61a2aa60c5..338d3161bd4 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -371,8 +371,6 @@ bool mysql_change_db(THD *thd,const char *name) } send_ok(&thd->net); x_free(thd->db); - if (lower_case_table_names) - casedn_str(dbname); thd->db=dbname; thd->db_access=db_access; DBUG_RETURN(0); |