List:Commits« Previous MessageNext Message »
From:eugene Date:June 2 2007 6:23pm
Subject:bk commit into 5.0 tree (evgen:1.2506) BUG#28494
View as plain text  
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-02 22:23:05+04:00, evgen@stripped +4 -0
  Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
  
  This is an additional fix.
  Item::val_xxx methods are supposed to use original data source and
  Item::val_xxx_result methods to use the item's result field. But for the
  Item_func_set_user_var class val_xxx_result maethods were mapped to val_xxx
  methods. This leads, in particular, to producing bad sort keys and thus
  wrong order of the result set of queries with group by/order by clauses.
  
  The additional use_result_field parameter is added to the
  Item_func_set_user_var::val_xxx methods. Depending on its value the class
  will or won't use the result_field.
  Two sets of wrapper functions are added to the Item_func_set_user_var class.
  val_xxx methods are call appropriate function from above set with the
  use_result_field set to FALSE.
  val_xxx_result methods - same as above but use_result_field is set to TRUE.

  mysql-test/r/user_var.result@stripped, 2007-06-02 22:21:22+04:00, evgen@stripped +5 -1
    Corrected test case for hte bug#28494.

  mysql-test/t/user_var.test@stripped, 2007-06-02 22:21:03+04:00, evgen@stripped +2 -1
    Corrected test case for hte bug#28494.

  sql/item_func.cc@stripped, 2007-06-02 22:22:32+04:00, evgen@stripped +9 -8
    Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
    The additional use_result_field parameter is added to the
    Item_func_set_user_var::val_xxx methods. Depending on its value the class
    will or won't use the result_field.

  sql/item_func.h@stripped, 2007-06-02 22:22:05+04:00, evgen@stripped +18 -4
    Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
    The additional use_result_field parameter is added to the
    Item_func_set_user_var::val_xxx methods.
    Two sets of wrapper functions are added to the Item_func_set_user_var class.
    val_xxx methods are call appropriate function from above set with the
    use_result_field set to FALSE.
    val_xxx_result methods - same as above but use_result_field is set to TRUE.

# 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/test-5.0-opt-mysql

--- 1.344/sql/item_func.cc	2007-06-01 01:17:03 +04:00
+++ 1.345/sql/item_func.cc	2007-06-02 22:22:32 +04:00
@@ -4174,35 +4174,36 @@ Item_func_set_user_var::update()
 }
 
 
-double Item_func_set_user_var::val_real()
+double Item_func_set_user_var::val_real(bool use_result_field)
 {
   DBUG_ASSERT(fixed == 1);
-  check(0);
+  check(use_result_field);
   update();					// Store expression
   return entry->val_real(&null_value);
 }
 
-longlong Item_func_set_user_var::val_int()
+longlong Item_func_set_user_var::val_int(bool use_result_field)
 {
   DBUG_ASSERT(fixed == 1);
-  check(0);
+  check(use_result_field);
   update();					// Store expression
   return entry->val_int(&null_value);
 }
 
-String *Item_func_set_user_var::val_str(String *str)
+String *Item_func_set_user_var::val_str(String *str, bool use_result_field)
 {
   DBUG_ASSERT(fixed == 1);
-  check(0);
+  check(use_result_field);
   update();					// Store expression
   return entry->val_str(&null_value, str, decimals);
 }
 
 
-my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
+my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val,
+                                                bool use_result_field)
 {
   DBUG_ASSERT(fixed == 1);
-  check(0);
+  check(use_result_field);
   update();					// Store expression
   return entry->val_decimal(&null_value, val);
 }

--- 1.170/sql/item_func.h	2007-06-01 01:17:03 +04:00
+++ 1.171/sql/item_func.h	2007-06-02 22:22:05 +04:00
@@ -1204,10 +1204,24 @@ public:
     :Item_func(b), cached_result_type(INT_RESULT), name(a)
   {}
   enum Functype functype() const { return SUSERVAR_FUNC; }
-  double val_real();
-  longlong val_int();
-  String *val_str(String *str);
-  my_decimal *val_decimal(my_decimal *);
+
+  double val_real(bool use_result_field);
+  longlong val_int(bool use_result_field);
+  String *val_str(String *str, bool use_result_field);
+  my_decimal *val_decimal(my_decimal *, bool use_result_field);
+
+  double val_real() { return val_real(FALSE); };
+  longlong val_int() { return val_int(FALSE); };
+  String *val_str(String *str) { return val_str(str, FALSE); };
+  my_decimal *val_decimal(my_decimal *val) { return val_decimal(val, FALSE); };
+
+  double val_real_result() { return val_real(TRUE); };
+  longlong val_int_result() { return val_int(TRUE); };
+  String *val_str_result(String *str) { return val_str(str, TRUE); };
+  my_decimal *val_decimal_result(my_decimal *val)
+  {
+    return val_decimal(val, TRUE);
+  };
   bool update_hash(void *ptr, uint length, enum Item_result type,
   		   CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
   bool send(Protocol *protocol, String *str_arg);

--- 1.45/mysql-test/r/user_var.result	2007-06-01 01:17:03 +04:00
+++ 1.46/mysql-test/r/user_var.result	2007-06-02 22:21:22 +04:00
@@ -319,7 +319,11 @@ SHOW COUNT(*) ERRORS;
 1
 create table t1(f1 int);
 insert into t1 values(1),(1),(2);
-select @a:=f1, count(f1) from t1 group by 1;
+select @a:=f1, count(f1) from t1 group by 1 desc;
+@a:=f1	count(f1)
+2	1
+1	2
+select @a:=f1, count(f1) from t1 group by 1 asc;
 @a:=f1	count(f1)
 1	2
 2	1

--- 1.40/mysql-test/t/user_var.test	2007-06-01 01:17:01 +04:00
+++ 1.41/mysql-test/t/user_var.test	2007-06-02 22:21:03 +04:00
@@ -228,5 +228,6 @@ SHOW COUNT(*) ERRORS;
 #
 create table t1(f1 int);
 insert into t1 values(1),(1),(2);
-select @a:=f1, count(f1) from t1 group by 1;
+select @a:=f1, count(f1) from t1 group by 1 desc;
+select @a:=f1, count(f1) from t1 group by 1 asc;
 drop table t1;
Thread
bk commit into 5.0 tree (evgen:1.2506) BUG#28494eugene2 Jun