From 7dbe9d3318ecc6e18a9469de9b8ae61f55c47f84 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Sun, 3 Jun 2007 14:46:09 +0400 Subject: [PATCH 1/2] user_var.result, user_var.test: Extended test case for the bug#28494. --- mysql-test/r/user_var.result | 25 +++++++++++++++++++++++-- mysql-test/t/user_var.test | 10 ++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index b90bb1f062b..15a9fe2ecda 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -317,8 +317,11 @@ SHOW COUNT(*) WARNINGS; SHOW COUNT(*) ERRORS; @@session.error_count 1 -create table t1(f1 int); -insert into t1 values(1),(1),(2),(3),(4),(1),(3),(1); +create table t1(f1 int, f2 varchar(2), f3 float, f4 decimal(2,1)); +insert into t1 values +(1, "a", 1.5, 1.6), (1, "a", 1.5, 1.6), (2, "b", 2.5, 2.6), +(3, "c", 3.5, 3.6), (4, "d", 4.5, 4.6), (1, "a", 1.5, 1.6), +(3, "c", 3.5, 3.6), (1, "a", 1.5, 1.6); select @a:=f1, count(f1) from t1 group by 1 desc; @a:=f1 count(f1) 4 1 @@ -331,4 +334,22 @@ select @a:=f1, count(f1) from t1 group by 1 asc; 2 1 3 2 4 1 +select @a:=f2, count(f2) from t1 group by 1 desc; +@a:=f2 count(f2) +a 4 +b 1 +c 2 +d 1 +select @a:=f3, count(f3) from t1 group by 1 desc; +@a:=f3 count(f3) +1.5 4 +2.5 1 +3.5 2 +4.5 1 +select @a:=f4, count(f4) from t1 group by 1 desc; +@a:=f4 count(f4) +4.6 1 +3.6 2 +2.6 1 +1.6 4 drop table t1; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 3df949ae669..3a3e8f88f83 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -226,8 +226,14 @@ SHOW COUNT(*) ERRORS; # # Bug#28494: Grouping by Item_func_set_user_var produces incorrect result. # -create table t1(f1 int); -insert into t1 values(1),(1),(2),(3),(4),(1),(3),(1); +create table t1(f1 int, f2 varchar(2), f3 float, f4 decimal(2,1)); +insert into t1 values + (1, "a", 1.5, 1.6), (1, "a", 1.5, 1.6), (2, "b", 2.5, 2.6), + (3, "c", 3.5, 3.6), (4, "d", 4.5, 4.6), (1, "a", 1.5, 1.6), + (3, "c", 3.5, 3.6), (1, "a", 1.5, 1.6); select @a:=f1, count(f1) from t1 group by 1 desc; select @a:=f1, count(f1) from t1 group by 1 asc; +select @a:=f2, count(f2) from t1 group by 1 desc; +select @a:=f3, count(f3) from t1 group by 1 desc; +select @a:=f4, count(f4) from t1 group by 1 desc; drop table t1; From 88147d5cfee3c4c0e94d3decbfa6bb17701b83d9 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Sun, 3 Jun 2007 15:56:48 +0400 Subject: [PATCH 2/2] user_var.result: Corrected test case result for the bug#28494. item_func.h, item_func.cc: Corrected function names after fix for the bug#28494. --- mysql-test/r/user_var.result | 12 ++++++------ sql/item_func.cc | 4 ++-- sql/item_func.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 15a9fe2ecda..80b5dccc198 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -336,16 +336,16 @@ select @a:=f1, count(f1) from t1 group by 1 asc; 4 1 select @a:=f2, count(f2) from t1 group by 1 desc; @a:=f2 count(f2) -a 4 -b 1 -c 2 d 1 +c 2 +b 1 +a 4 select @a:=f3, count(f3) from t1 group by 1 desc; @a:=f3 count(f3) -1.5 4 -2.5 1 -3.5 2 4.5 1 +3.5 2 +2.5 1 +1.5 4 select @a:=f4, count(f4) from t1 group by 1 desc; @a:=f4 count(f4) 4.6 1 diff --git a/sql/item_func.cc b/sql/item_func.cc index ca8b0af865d..580d19fbd4e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4208,7 +4208,7 @@ my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val) } -double Item_func_set_user_var::val_real_result() +double Item_func_set_user_var::val_result() { DBUG_ASSERT(fixed == 1); check(TRUE); @@ -4224,7 +4224,7 @@ longlong Item_func_set_user_var::val_int_result() return entry->val_int(&null_value); } -String *Item_func_set_user_var::val_str_result(String *str) +String *Item_func_set_user_var::str_result(String *str) { DBUG_ASSERT(fixed == 1); check(TRUE); diff --git a/sql/item_func.h b/sql/item_func.h index c8ea79b9747..9a0201cb28b 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1208,9 +1208,9 @@ public: longlong val_int(); String *val_str(String *str); my_decimal *val_decimal(my_decimal *); - double val_real_result(); + double val_result(); longlong val_int_result(); - String *val_str_result(String *str); + String *str_result(String *str); my_decimal *val_decimal_result(my_decimal *); bool update_hash(void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);