MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:<gshchepa Date:February 8 2008 12:04pm
Subject:bk commit into 5.0 tree (gshchepa:1.2600) BUG#15409
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gshchepa.  When gshchepa 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, 2008-02-08 16:04:01+04:00, gshchepa@stripped +3 -0
  Fixed bug#15409: Columns with 64-element SET may not be updated with integers.
  
  SET column storing procedure has been modified to be 64bit-clean.

  mysql-test/r/type_set.result@stripped, 2008-02-08 16:03:45+04:00, gshchepa@stripped +8 -0
    Added test case for bug#15409.

  mysql-test/t/type_set.test@stripped, 2008-02-08 16:03:47+04:00, gshchepa@stripped +20 -0
    Added test case for bug#15409.

  sql/field.cc@stripped, 2008-02-08 16:03:48+04:00, gshchepa@stripped +3 -3
    Fixed bug#15409.
    The Field_set::store(longlong nr,...) method incompletely
    calculates a bit mask for the comparison with a given number:
    if that number is greater than 0x7F00 0000 0000 0000 (LONGLONG_MAX),
    it uses zero bit mask instead of 0xFFFF FFFF FFFF FFFF (ULONGLONG_MAX).
    
    Incomplete expression has been replaced with a set_bits macro call.

diff -Nrup a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result
--- a/mysql-test/r/type_set.result	2007-04-02 15:01:18 +05:00
+++ b/mysql-test/r/type_set.result	2008-02-08 16:03:45 +04:00
@@ -85,3 +85,11 @@ t1	CREATE TABLE `t1` (
   `f1` set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1') default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
+CREATE TABLE t1(c set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64'));
+INSERT INTO t1 VALUES(7);
+INSERT INTO t1 VALUES(9223372036854775808);
+SELECT * FROM t1;
+c
+1,2,3
+64
+DROP TABLE t1;
diff -Nrup a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test
--- a/mysql-test/t/type_set.test	2007-04-02 15:01:18 +05:00
+++ b/mysql-test/t/type_set.test	2008-02-08 16:03:47 +04:00
@@ -56,3 +56,23 @@ set('1','2','3','4','5','6','7','8','9',
 '50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1'));
 show create table t1;
 drop table t1;
+
+#
+# Bug#15409: Columns with SET datatype with 64-element sets
+#            may not be updated with integers
+#
+
+let $i=64;
+let $s='$i';
+dec $i;
+while ($i) {
+  let $s='$i',$s;
+  dec $i;
+}
+--eval CREATE TABLE t1(c set($s))
+INSERT INTO t1 VALUES(7); 
+INSERT INTO t1 VALUES(9223372036854775808);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--# echo End of 5.0 tests
diff -Nrup a/sql/field.cc b/sql/field.cc
--- a/sql/field.cc	2008-02-07 02:33:02 +04:00
+++ b/sql/field.cc	2008-02-08 16:03:48 +04:00
@@ -7871,10 +7871,10 @@ int Field_set::store(const char *from,ui
 int Field_set::store(longlong nr, bool unsigned_val)
 {
   int error= 0;
-  if ((ulonglong) nr > (ulonglong) (((longlong) 1 << typelib->count) -
-				    (longlong) 1))
+  ulonglong max_nr= set_bits(ulonglong, typelib->count);
+  if ((ulonglong) nr > max_nr)
   {
-    nr&= (longlong) (((longlong) 1 << typelib->count) - (longlong) 1);    
+    nr&= max_nr;
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
     error=1;
   }
Thread
bk commit into 5.0 tree (gshchepa:1.2600) BUG#15409gshchepa8 Feb