List:Commits« Previous MessageNext Message »
From:kpettersson Date:February 22 2007 7:55pm
Subject:bk commit into 5.0 tree (Kristofer.Pettersson:1.2414) BUG#2077
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of Kristofer Pettersson. When Kristofer Pettersson 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-02-22 20:54:32+01:00, Kristofer.Pettersson@naruto. +4 -0
  Bug#2077 Function w BIGINT UNSIGNED shows diff. behaviour with and without --ps-protocol
  
  - Stored procedures returning unsigned values returns signed values if
    text protocol is used. The reason is that the stored proceedure item
    Item_func_sp wasn't initializing the member variables properly based
    on the information contained in the associated result field.
  - The fix is to upon sp-execution set the value for 
    Item_func_sp::unsigned_flag.

  mysql-test/r/sp.result@stripped, 2007-02-22 20:54:17+01:00, Kristofer.Pettersson@naruto. +97 -0
    - Added test

  mysql-test/t/sp.test@stripped, 2007-02-22 20:54:18+01:00, Kristofer.Pettersson@naruto. +49 -0
    - Added test

  sql/item_func.cc@stripped, 2007-02-22 20:54:20+01:00, Kristofer.Pettersson@naruto. +17 -1
    - Added function to properly initialize member variables through
      the Field interface.

  sql/item_func.h@stripped, 2007-02-22 20:54:21+01:00, Kristofer.Pettersson@naruto. +7 -0
    - Added function to properly initialize member variables through
      the Field interface.

# 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:	Kristofer.Pettersson
# Host:	naruto.
# Root:	C:/cpp/bug20777/my50-bug20777

--- 1.327/sql/item_func.cc	2007-02-22 20:55:06 +01:00
+++ 1.328/sql/item_func.cc	2007-02-22 20:55:06 +01:00
@@ -4998,6 +4998,7 @@ Item_func_sp::Item_func_sp(Name_resoluti
   dummy_table= (TABLE*) sql_calloc(sizeof(TABLE));
 }
 
+
 void
 Item_func_sp::cleanup()
 {
@@ -5053,6 +5054,12 @@ Item_func_sp::sp_result_field(void) cons
       DBUG_RETURN(0);
     }
   }
+
+  /*
+     A Field need to be attached to a Table.
+     Below we "create" a dummy table by initializing 
+     the needed pointers.
+   */
   if (!dummy_table->s)
   {
     char *empty_name= (char *) "";
@@ -5065,6 +5072,8 @@ Item_func_sp::sp_result_field(void) cons
     share->table_cache_key = empty_name;
     share->table_name = empty_name;
   }
+
+
   if (!(field= m_sp->create_result_field(max_length, name, dummy_table)))
     my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
 
@@ -5099,13 +5108,15 @@ Item_func_sp::execute(Field **flp)
       null_value= 1;
       return TRUE;
     }
-
     f->move_field((f->pack_length() > sizeof(result_buf)) ?
                   sql_alloc(f->pack_length()) : result_buf);
     f->null_ptr= (uchar *)&null_value;
     f->null_bit= 1;
+    set_field(f);
   }
 
+
+
   /* Execute function and store the return value in the field. */
 
   if (execute_impl(thd, f))
@@ -5122,6 +5133,11 @@ Item_func_sp::execute(Field **flp)
   return null_value;
 }
 
+void
+Item_func_sp::set_field(Field *f)
+{
+    unsigned_flag= test(f->flags & UNSIGNED_FLAG);
+}
 
 bool
 Item_func_sp::execute_impl(THD *thd, Field *return_value_fld)

--- 1.160/sql/item_func.h	2007-02-22 20:55:06 +01:00
+++ 1.161/sql/item_func.h	2007-02-22 20:55:06 +01:00
@@ -1412,6 +1412,13 @@ private:
   bool execute_impl(THD *thd, Field *return_value_fld);
   Field *sp_result_field(void) const;
 
+  /*
+    @brief Use the Field interface to set relevant
+           local variables.
+
+  */
+  void set_field(Field *result_field);
+
 public:
 
   Item_func_sp(Name_resolution_context *context_arg, sp_name *name);

--- 1.218/mysql-test/r/sp.result	2007-02-22 20:55:06 +01:00
+++ 1.219/mysql-test/r/sp.result	2007-02-22 20:55:06 +01:00
@@ -5742,3 +5742,100 @@ CALL bug24117()|
 DROP PROCEDURE bug24117|
 DROP TABLE t3|
 drop table t1,t2;
+create function bug20777(f1 bigint unsigned) returns bigint unsigned
+begin
+set f1 = (f1 - 10); set f1 = (f1 + 10);
+return f1;
+end//
+select bug20777(9223372036854775803) as '9223372036854775803   2**63-5';
+9223372036854775803   2**63-5
+9223372036854775803
+select bug20777(9223372036854775804) as '9223372036854775804   2**63-4';
+9223372036854775804   2**63-4
+9223372036854775804
+select bug20777(9223372036854775805) as '9223372036854775805   2**63-3';
+9223372036854775805   2**63-3
+9223372036854775805
+select bug20777(9223372036854775806) as '9223372036854775806   2**63-2';
+9223372036854775806   2**63-2
+9223372036854775806
+select bug20777(9223372036854775807) as '9223372036854775807   2**63-1';
+9223372036854775807   2**63-1
+9223372036854775807
+select bug20777(9223372036854775808) as '9223372036854775808   2**63+0';
+9223372036854775808   2**63+0
+9223372036854775808
+select bug20777(9223372036854775809) as '9223372036854775809   2**63+1';
+9223372036854775809   2**63+1
+9223372036854775809
+select bug20777(9223372036854775810) as '9223372036854775810   2**63+2';
+9223372036854775810   2**63+2
+9223372036854775810
+Should clip:
+select bug20777(-9223372036854775808) as 'lower bounds signed bigint';
+lower bounds signed bigint
+0
+Warnings:
+Warning	1264	Out of range value adjusted for column 'f1' at row 1
+select bug20777(9223372036854775807) as 'upper bounds signed bigint';
+upper bounds signed bigint
+9223372036854775807
+select bug20777(0) as 'lower bounds unsigned bigint';
+lower bounds unsigned bigint
+0
+select bug20777(18446744073709551615) as 'upper bounds unsigned bigint';
+upper bounds unsigned bigint
+18446744073709551615
+Should clip:
+select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1';
+upper bounds unsigned bigint + 1
+18446744073709551615
+Warnings:
+Warning	1264	Out of range value adjusted for column 'f1' at row 1
+Should clip:
+select bug20777(-1) as 'lower bounds unsigned bigint - 1';
+lower bounds unsigned bigint - 1
+0
+Warnings:
+Warning	1264	Out of range value adjusted for column 'f1' at row 1
+select bug20777(1.84e+19) as 'submitter value, 1.84e19';
+submitter value, 1.84e19
+9223372036854775808
+create table examplebug20777 as select 
+0 as 'i',
+bug20777(9223372036854775806) as '2**63-2',
+bug20777(9223372036854775807) as '2**63-1',
+bug20777(9223372036854775808) as '2**63',
+bug20777(9223372036854775809) as '2**63+1',
+bug20777(18446744073709551614) as '2**64-2',
+bug20777(18446744073709551615) as '2**64-1', 
+bug20777(18446744073709551616) as '2**64',
+bug20777(0) as '0',
+bug20777(-1) as '-1';
+Warnings:
+Warning	1264	Out of range value adjusted for column 'f1' at row 1
+Warning	1264	Out of range value adjusted for column 'f1' at row 1
+insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1);
+Warnings:
+Warning	1264	Out of range value adjusted for column '-1' at row 1
+show create table examplebug20777;
+Table	Create Table
+examplebug20777	CREATE TABLE `examplebug20777` (
+  `i` int(1) NOT NULL default '0',
+  `2**63-2` bigint(20) unsigned default NULL,
+  `2**63-1` bigint(20) unsigned default NULL,
+  `2**63` bigint(20) unsigned default NULL,
+  `2**63+1` bigint(20) unsigned default NULL,
+  `2**64-2` bigint(20) unsigned default NULL,
+  `2**64-1` bigint(20) unsigned default NULL,
+  `2**64` bigint(20) unsigned default NULL,
+  `0` bigint(20) unsigned default NULL,
+  `-1` bigint(20) unsigned default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from examplebug20777 order by i;
+i	2**63-2	2**63-1	2**63	2**63+1	2**64-2	2**64-1	2**64	0	-1
+0	9223372036854775806	9223372036854775807	9223372036854775808	9223372036854775809	18446744073709551614	18446744073709551615	18446744073709551615	0	0
+1	9223372036854775806	9223372036854775807	223372036854775808	9223372036854775809	18446744073709551614	18446744073709551615	8446744073709551616	0	0
+drop table examplebug20777;
+drop function bug20777;
+End of 5.0 tests.

--- 1.208/mysql-test/t/sp.test	2007-02-22 20:55:07 +01:00
+++ 1.209/mysql-test/t/sp.test	2007-02-22 20:55:07 +01:00
@@ -6731,3 +6731,52 @@ DROP TABLE t3|
 # practical, or create table t3, t4 etc temporarily (and drop them).
 delimiter ;|
 drop table t1,t2;
+#
+# Bug#20777: Function w BIGINT UNSIGNED shows diff. behaviour --ps-protocol
+#
+delimiter //;
+create function bug20777(f1 bigint unsigned) returns bigint unsigned
+begin
+  set f1 = (f1 - 10); set f1 = (f1 + 10);
+return f1;
+end//
+delimiter ;//
+select bug20777(9223372036854775803) as '9223372036854775803   2**63-5';
+select bug20777(9223372036854775804) as '9223372036854775804   2**63-4';
+select bug20777(9223372036854775805) as '9223372036854775805   2**63-3';
+select bug20777(9223372036854775806) as '9223372036854775806   2**63-2';
+select bug20777(9223372036854775807) as '9223372036854775807   2**63-1';
+select bug20777(9223372036854775808) as '9223372036854775808   2**63+0';
+select bug20777(9223372036854775809) as '9223372036854775809   2**63+1';
+select bug20777(9223372036854775810) as '9223372036854775810   2**63+2';
+--echo Should clip:
+select bug20777(-9223372036854775808) as 'lower bounds signed bigint';
+select bug20777(9223372036854775807) as 'upper bounds signed bigint';
+select bug20777(0) as 'lower bounds unsigned bigint';
+select bug20777(18446744073709551615) as 'upper bounds unsigned bigint';
+--echo Should clip:
+select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1';
+--echo Should clip:
+select bug20777(-1) as 'lower bounds unsigned bigint - 1';
+select bug20777(1.84e+19) as 'submitter value, 1.84e19';
+
+create table examplebug20777 as select 
+  0 as 'i',
+  bug20777(9223372036854775806) as '2**63-2',
+  bug20777(9223372036854775807) as '2**63-1',
+  bug20777(9223372036854775808) as '2**63',
+  bug20777(9223372036854775809) as '2**63+1',
+  bug20777(18446744073709551614) as '2**64-2',
+  bug20777(18446744073709551615) as '2**64-1', 
+  bug20777(18446744073709551616) as '2**64',
+  bug20777(0) as '0',
+  bug20777(-1) as '-1';
+insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1);
+show create table examplebug20777;
+select * from examplebug20777 order by i;
+drop table examplebug20777;
+
+drop function bug20777;
+
+###
+--echo End of 5.0 tests.


Thread
bk commit into 5.0 tree (Kristofer.Pettersson:1.2414) BUG#2077kpettersson22 Feb