summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-06-01 01:17:14 +0400
committerunknown <evgen@moonbone.local>2007-06-01 01:17:14 +0400
commitb4a35cd76e8d25a90c3d59fa9fcd5eb829e71b59 (patch)
treed16e6bd3d365e623581d9c8f4cb210d2ea934836 /sql/item_func.h
parentb79b49099310fdc068d7ddadcb7a168b9aaa674c (diff)
downloadmariadb-git-b4a35cd76e8d25a90c3d59fa9fcd5eb829e71b59.tar.gz
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/t/user_var.test: Added a test case for the bug#28494: Grouping by Item_func_set_user_var produces incorrect result. mysql-test/r/user_var.result: Added a test case for the bug#28494: Grouping by Item_func_set_user_var produces incorrect result. sql/item_func.cc: 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: 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.
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 1cffe9a934e..18cd87d2de4 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -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); }
};