List:Commits« Previous MessageNext Message »
From:msvensson Date:June 8 2006 11:03am
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 13:03:10 msvensson@neptunus.(none) +6 -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 13:02:58 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 13:02:58 msvensson@neptunus.(none) +3 -1
    Propagate unsigned_flag to Item_singlerow_subselect from the query it executed.

  sql/item_func.cc
    1.262 06/06/08 13:02:58 msvensson@neptunus.(none) +8 -1
    Add unsigned_flag to user_var_entry. Used when 'type' is INT_RESULT

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

  mysql-test/t/user_var.test
    1.23 06/06/08 13:02:56 msvensson@neptunus.(none) +31 -0
    Add test case

  mysql-test/r/user_var.result
    1.29 06/06/08 13:02:56 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 13:02:57 +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 13:02:58 +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:
@@ -2436,6 +2437,7 @@
     entry->length= length;
     entry->type=type;
     entry->collation.set(cs, dv);
+    entry->unsigned_flag= unsigned_flag;
   }
   return 0;
 
@@ -2506,7 +2508,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 +2552,8 @@
   case INT_RESULT:
   {
     save_result.vint= args[0]->val_int();
+    unsigned_flag= args[0]->unsigned_flag;
+
     break;
   }
   case STRING_RESULT:

--- 1.285/sql/sql_class.h	2006-04-07 21:48:18 +02:00
+++ 1.286/sql/sql_class.h	2006-06-08 13:02:58 +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 13:02:58 +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 13:02:56 +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 13:02:56 +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