List:Commits« Previous MessageNext Message »
From:msvensson Date:June 8 2006 1:41pm
Subject:bk commit into 4.1 tree (msvensson:1.2473) BUG#7498
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of msvensson. When msvensson 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
  1.2473 06/06/08 15:41:17 msvensson@neptunus.(none) +7 -0
  Bug #7498 User variable SET saves SIGNED BIGINT as UNSIGNED BIGINT
   - Add unsigned flag to user_var_entry, used when 'type' is INT_RESULT
   - Propagate unsigned flag from the query executed by Item_single_row_subselect
   - Set unsigned_flag after coneverting from string(backport from 5.0)

  sql/sql_class.h
    1.286 06/06/08 15:41:15 msvensson@neptunus.(none) +1 -0
    Add unsigned_flag to user_var_entry. Used when 'type' is INT_RESULT

  sql/item_subselect.cc
    1.141 06/06/08 15:41:14 msvensson@neptunus.(none) +3 -1
    Propagate unsigned_flag to Item_singlerow_subselect from the query it executed.

  sql/item_func.h
    1.130 06/06/08 15:41:14 msvensson@neptunus.(none) +2 -4
    Removed unused variable save_buff
    Add parameter unsigned_arg to 'update_hash'

  sql/item_func.cc
    1.262 06/06/08 15:41:14 msvensson@neptunus.(none) +11 -3
    Add unsigned_flag to user_var_entry. Used when 'type' is INT_RESULT
    Pass unsigned_flag to 'update_hash' if type is INT_RESULT

  sql/item.cc
    1.233 06/06/08 15:41:14 msvensson@neptunus.(none) +3 -0
    Set unsigned flag, backport from 5.0

  mysql-test/t/user_var.test
    1.23 06/06/08 15:41:14 msvensson@neptunus.(none) +31 -0
    Add test case

  mysql-test/r/user_var.result
    1.29 06/06/08 15:41:14 msvensson@neptunus.(none) +36 -0
    Update test results

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/bug7498/my41-bug7498

--- 1.232/sql/item.cc	2006-04-28 11:23:28 +02:00
+++ 1.233/sql/item.cc	2006-06-08 15:41:14 +02:00
@@ -2194,6 +2194,8 @@
       return set_field_to_null_with_conversions(field, no_conversions);
     field->set_notnull();
     error=field->store(nr);
+    if (unsigned_flag)
+      field->flags |= UNSIGNED_FLAG;
   }
   return error;
 }
@@ -2981,6 +2983,7 @@
 {
   value= item->val_int_result();
   null_value= item->null_value;
+  unsigned_flag= item->unsigned_flag;
 }
 
 

--- 1.261/sql/item_func.cc	2006-05-07 10:43:22 +02:00
+++ 1.262/sql/item_func.cc	2006-06-08 15:41:14 +02:00
@@ -2312,6 +2312,7 @@
     entry->length=0;
     entry->update_query_id=0;
     entry->collation.set(NULL, DERIVATION_IMPLICIT);
+    entry->unsigned_flag= 0;
     /*
       If we are here, we were called from a SET or a query which sets a
       variable. Imagine it is this:
@@ -2389,7 +2390,8 @@
 bool Item_func_set_user_var::update_hash(void *ptr, uint length,
 					 Item_result type,
 					 CHARSET_INFO *cs,
-					 Derivation dv)
+                                         Derivation dv,
+                                         bool unsigned_arg)
 {
   if ((null_value=args[0]->null_value))
   {
@@ -2436,6 +2438,7 @@
     entry->length= length;
     entry->type=type;
     entry->collation.set(cs, dv);
+    entry->unsigned_flag= unsigned_arg;
   }
   return 0;
 
@@ -2506,7 +2509,10 @@
     str->set(*(double*) value, decimals, &my_charset_bin);
     break;
   case INT_RESULT:
-    str->set(*(longlong*) value, &my_charset_bin);
+    if (!unsigned_flag)
+      str->set(*(longlong*) value, &my_charset_bin);
+    else
+      str->set(*(ulonglong*) value, &my_charset_bin);
     break;
   case STRING_RESULT:
     if (str->copy(value, length, collation.collation))
@@ -2547,6 +2553,7 @@
   case INT_RESULT:
   {
     save_result.vint= args[0]->val_int();
+    unsigned_flag= args[0]->unsigned_flag;
     break;
   }
   case STRING_RESULT:
@@ -2597,7 +2604,8 @@
   case INT_RESULT:
   {
     res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
-		     INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT);
+		     INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
+                     unsigned_flag);
     break;
   }
   case STRING_RESULT:

--- 1.129/sql/item_func.h	2006-02-07 10:49:52 +01:00
+++ 1.130/sql/item_func.h	2006-06-08 15:41:14 +02:00
@@ -947,8 +947,6 @@
     double vreal;
     String *vstr;
   } save_result;
-  String save_buff;
-  
 
 public:
   LEX_STRING name; // keep it public
@@ -958,8 +956,8 @@
   double val();
   longlong val_int();
   String *val_str(String *str);
-  bool update_hash(void *ptr, uint length, enum Item_result type, 
-  		   CHARSET_INFO *cs, Derivation dv);
+  bool update_hash(void *ptr, uint length, enum Item_result type,
+  		   CHARSET_INFO *cs, Derivation dv, bool unsigned_arg= 0);
   bool check();
   bool update();
   enum Item_result result_type () const { return cached_result_type; }

--- 1.285/sql/sql_class.h	2006-04-07 21:48:18 +02:00
+++ 1.286/sql/sql_class.h	2006-06-08 15:41:15 +02:00
@@ -1457,6 +1457,7 @@
   char *value;
   ulong length, update_query_id, used_query_id;
   Item_result type;
+  bool unsigned_flag;
 
   double val(my_bool *null_value);
   longlong val_int(my_bool *null_value);

--- 1.140/sql/item_subselect.cc	2006-04-28 11:23:28 +02:00
+++ 1.141/sql/item_subselect.cc	2006-06-08 15:41:14 +02:00
@@ -463,8 +463,10 @@
   DBUG_ASSERT(fixed == 1);
   if (!exec() && !value->null_value)
   {
+    longlong nr= value->val_int();
     null_value= 0;
-    return value->val_int();
+    unsigned_flag= value->unsigned_flag;
+    return nr;
   }
   else
   {

--- 1.28/mysql-test/r/user_var.result	2005-07-25 20:25:23 +02:00
+++ 1.29/mysql-test/r/user_var.result	2006-06-08 15:41:14 +02:00
@@ -203,3 +203,39 @@
 select @@session.VERSION;
 @@session.VERSION
 #
+set @a=18446744071710965857;
+select @a;
+@a
+18446744071710965857
+CREATE TABLE `bigfailure` (
+`afield` BIGINT UNSIGNED NOT NULL
+);
+INSERT INTO `bigfailure` VALUES (18446744071710965857);
+SELECT * FROM bigfailure;
+afield
+18446744071710965857
+select * from (SELECT afield FROM bigfailure) as b;
+afield
+18446744071710965857
+select * from bigfailure where afield = (SELECT afield FROM bigfailure);
+afield
+18446744071710965857
+select * from bigfailure where afield = 18446744071710965857;
+afield
+18446744071710965857
+select * from bigfailure where afield = 18446744071710965856+1;
+afield
+18446744071710965857
+SET @a := (SELECT afield FROM bigfailure);
+SELECT @a;
+@a
+18446744071710965857
+SET @a := (select afield from (SELECT afield FROM bigfailure) as b);
+SELECT @a;
+@a
+18446744071710965857
+SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure));
+SELECT @a;
+@a
+18446744071710965857
+drop table bigfailure;

--- 1.22/mysql-test/t/user_var.test	2005-08-02 02:10:33 +02:00
+++ 1.23/mysql-test/t/user_var.test	2006-06-08 15:41:14 +02:00
@@ -141,4 +141,35 @@
 --replace_column 1 #
 select @@session.VERSION;
 
+#
+# Bug #7498 User variable SET saves SIGNED BIGINT as UNSIGNED BIGINT
+#
+
+# First part, set user var to large number and select it
+set @a=18446744071710965857;
+select @a;
+
+# Second part, set user var from large number in table
+# then select it
+CREATE TABLE `bigfailure` (
+  `afield` BIGINT UNSIGNED NOT NULL
+);
+INSERT INTO `bigfailure` VALUES (18446744071710965857);
+SELECT * FROM bigfailure;
+select * from (SELECT afield FROM bigfailure) as b;
+select * from bigfailure where afield = (SELECT afield FROM bigfailure);
+select * from bigfailure where afield = 18446744071710965857;
+# This is fixed in 5.0, to be uncommented there
+#select * from bigfailure where afield = '18446744071710965857';
+select * from bigfailure where afield = 18446744071710965856+1;
+
+SET @a := (SELECT afield FROM bigfailure);
+SELECT @a;
+SET @a := (select afield from (SELECT afield FROM bigfailure) as b);
+SELECT @a;
+SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure));
+SELECT @a;
+
+drop table bigfailure;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (msvensson:1.2473) BUG#7498msvensson8 Jun