Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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@stripped, 2007-06-01 01:17:14+04:00, evgen@stripped +4 -0
Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
The end_update() function uses the Item::save_org_in_field() function to
save original values of items into the group buffer. But for the
Item_func_set_user_var this method was mapped to the save_in_field method.
The latter function wrongly decides to use the result_field. This leads to
saving incorrect value in the grouping buffer and wrong result of the whole
query.
The can_use_result_field argument of the bool type is added to the
Item_func_set_user_var::save_in_field() function. If it is set to FALSE
then the item's result field won't be used. Otherwise it will be detected
whether the result field will be used (old behaviour).
Two wrapping functions for the function above are added to the
Item_func_set_user_var class:
the save_in_field(Field *field, bool no_conversions) - it calls the above
function with the can_use_result_field set to TRUE.
the save_org_in_field(Field *field) - same, but the can_use_result_field
is set to FALSE.
mysql-test/r/user_var.result@stripped, 2007-06-01 01:17:03+04:00, evgen@stripped +7 -0
Added a test case for the bug#28494: Grouping by Item_func_set_user_var
produces incorrect result.
mysql-test/t/user_var.test@stripped, 2007-06-01 01:17:01+04:00, evgen@stripped +8 -0
Added a test case for the bug#28494: Grouping by Item_func_set_user_var
produces incorrect result.
sql/item_func.cc@stripped, 2007-06-01 01:17:03+04:00, evgen@stripped +4 -2
Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
The can_use_result_field argument of the bool type is added to the
Item_func_set_user_var::save_in_field() function. If it is set to FALSE
then the item's result field won't be used. Otherwise it will be detected
whether the result field will be used (old behaviour).
sql/item_func.h@stripped, 2007-06-01 01:17:03+04:00, evgen@stripped +7 -1
Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
The can_use_result_field argument of the bool type is added to the
Item_func_set_user_var::save_in_field() function.
Two wrapping functions for the function above are added to the
Item_func_set_user_var class:
the save_in_field(Field *field, bool no_conversions) - it calls the above
function with the can_use_result_field set to TRUE.
the save_org_in_field(Field *field) - same, but the can_use_result_field
is set to FALSE.
# 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: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/28494-bug-5.0-opt-mysql
--- 1.343/sql/item_func.cc 2007-05-30 16:43:53 +04:00
+++ 1.344/sql/item_func.cc 2007-06-01 01:17:03 +04:00
@@ -4290,9 +4290,11 @@ void Item_func_set_user_var::make_field(
TRUE Error
*/
-int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions)
+int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
+ bool can_use_result_field)
{
- bool use_result_field= (result_field && result_field != field);
+ bool use_result_field= (!can_use_result_field ? 0 :
+ (result_field && result_field != field));
int error;
/* Update the value of the user variable */
--- 1.169/sql/item_func.h 2007-05-18 00:17:45 +04:00
+++ 1.170/sql/item_func.h 2007-06-01 01:17:03 +04:00
@@ -1220,7 +1220,13 @@ public:
void print(String *str);
void print_as_stmt(String *str);
const char *func_name() const { return "set_user_var"; }
- int save_in_field(Field *field, bool no_conversions);
+ int save_in_field(Field *field, bool no_conversions,
+ bool can_use_result_field);
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_in_field(field, no_conversions, 1);
+ }
+ void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
};
--- 1.44/mysql-test/r/user_var.result 2007-01-09 23:23:57 +03:00
+++ 1.45/mysql-test/r/user_var.result 2007-06-01 01:17:03 +04:00
@@ -317,3 +317,10 @@ SHOW COUNT(*) WARNINGS;
SHOW COUNT(*) ERRORS;
@@session.error_count
1
+create table t1(f1 int);
+insert into t1 values(1),(1),(2);
+select @a:=f1, count(f1) from t1 group by 1;
+@a:=f1 count(f1)
+1 2
+2 1
+drop table t1;
--- 1.39/mysql-test/t/user_var.test 2007-01-09 23:24:10 +03:00
+++ 1.40/mysql-test/t/user_var.test 2007-06-01 01:17:01 +04:00
@@ -222,3 +222,11 @@ drop table t1,t2;
insert into city 'blah';
SHOW COUNT(*) WARNINGS;
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);
+select @a:=f1, count(f1) from t1 group by 1;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2511) BUG#28494 | eugene | 31 May |