List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:December 9 2008 12:09pm
Subject:bzr commit into mysql-6.0-bugteam branch (Sergey.Glukhov:2785)
View as plain text  
#At file:///home/gluh/MySQL/mysql-6.0-bugteam/ based on revid:sergey.glukhov@stripped

 2785 Sergey Glukhov	2008-12-09 [merge]
      5.1-bugteam -> 6.0-bugteam merge
modified:
  mysql-test/r/func_str.result
  mysql-test/r/partition_datatype.result
  mysql-test/r/type_bit.result
  mysql-test/t/func_str.test
  mysql-test/t/type_bit.test
  sql/item.cc
  sql/item_strfunc.cc
  sql/sql_show.cc

per-file messages:
  mysql-test/r/func_str.result
    5.1-bugteam -> 6.0-bugteam merge
  mysql-test/r/partition_datatype.result
    5.1-bugteam -> 6.0-bugteam merge
  mysql-test/r/type_bit.result
    5.1-bugteam -> 6.0-bugteam merge
  mysql-test/t/func_str.test
    5.1-bugteam -> 6.0-bugteam merge
  mysql-test/t/type_bit.test
    5.1-bugteam -> 6.0-bugteam merge
  sql/item.cc
    5.1-bugteam -> 6.0-bugteam merge
  sql/item_strfunc.cc
    5.1-bugteam -> 6.0-bugteam merge
  sql/sql_show.cc
    5.1-bugteam -> 6.0-bugteam merge
=== modified file 'mysql-test/r/func_str.result'
--- a/mysql-test/r/func_str.result	2008-07-14 12:49:19 +0000
+++ b/mysql-test/r/func_str.result	2008-12-09 12:08:02 +0000
@@ -717,8 +717,6 @@ insert(_latin2'abcd',2,3,_latin2'ef'),
 replace(_latin2'abcd',_latin2'b',_latin2'B'),
 encode('abcd','ab')
 ;
-Warnings:
-Warning	1265	Data truncated for column 'format(130,10)' at row 1
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -727,7 +725,7 @@ t1	CREATE TABLE `t1` (
   `conv(130,16,10)` varchar(64) DEFAULT NULL,
   `hex(130)` varchar(6) NOT NULL DEFAULT '',
   `char(130)` varbinary(4) NOT NULL DEFAULT '',
-  `format(130,10)` varchar(4) NOT NULL DEFAULT '',
+  `format(130,10)` varchar(37) NOT NULL DEFAULT '',
   `left(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
   `right(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
   `lcase(_latin2'a')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
@@ -2513,4 +2511,12 @@ SELECT HEX(c1) from v1;
 HEX(c1)
 414243
 DROP VIEW v1;
+create table t1(a float);
+insert into t1 values (1.33);
+select format(a, 2) from t1;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					format(a, 2)	253	49	4	Y	0	31	8
+format(a, 2)
+1.33
+drop table t1;
 End of 5.0 tests

=== modified file 'mysql-test/r/partition_datatype.result'
--- a/mysql-test/r/partition_datatype.result	2008-11-04 07:43:21 +0000
+++ b/mysql-test/r/partition_datatype.result	2008-12-09 11:16:39 +0000
@@ -324,7 +324,7 @@ partition by hash (a)
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `a` bit(27) NOT NULL DEFAULT '\0\0\0\0',
+  `a` bit(27) NOT NULL DEFAULT b'0',
   PRIMARY KEY (`a`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (a)

=== modified file 'mysql-test/r/type_bit.result'
--- a/mysql-test/r/type_bit.result	2008-08-28 11:17:29 +0000
+++ b/mysql-test/r/type_bit.result	2008-12-09 12:08:02 +0000
@@ -708,6 +708,21 @@ HEX(b1)	HEX(b2)	i2
 1	0	100
 1	0	200
 DROP TABLE t1, t2;
+CREATE TABLE IF NOT EXISTS t1 (
+f1 bit(2) NOT NULL default b'10',
+f2 bit(14) NOT NULL default b'11110000111100'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `f1` bit(2) NOT NULL DEFAULT b'10',
+  `f2` bit(14) NOT NULL DEFAULT b'11110000111100'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
+DROP TABLE t1;
+CREATE TABLE IF NOT EXISTS t1 (
+f1 bit(2) NOT NULL default b''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+ERROR 42000: Invalid default value for 'f1'
 End of 5.0 tests
 create table t1(a bit(7));
 insert into t1 values(0x40);

=== modified file 'mysql-test/t/func_str.test'
--- a/mysql-test/t/func_str.test	2008-02-24 00:31:54 +0000
+++ b/mysql-test/t/func_str.test	2008-12-09 11:16:39 +0000
@@ -1263,4 +1263,14 @@ CREATE VIEW v1 AS SELECT CHAR(0x414243) 
 SELECT HEX(c1) from v1;
 DROP VIEW v1;
 
+#
+# Bug #35558 Wrong server metadata blows up the client
+#
+create table t1(a float);
+insert into t1 values (1.33);
+--enable_metadata
+select format(a, 2) from t1;
+--disable_metadata
+drop table t1;
+
 --echo End of 5.0 tests

=== modified file 'mysql-test/t/type_bit.test'
--- a/mysql-test/t/type_bit.test	2008-08-28 09:54:50 +0000
+++ b/mysql-test/t/type_bit.test	2008-12-09 11:16:39 +0000
@@ -352,6 +352,21 @@ SELECT HEX(b1), HEX(b2), i2 FROM t2
 
 DROP TABLE t1, t2;
 
+#
+# Bug #35796 SHOW CREATE TABLE and default value for BIT field
+#
+CREATE TABLE IF NOT EXISTS t1 (
+f1 bit(2) NOT NULL default b'10',
+f2 bit(14) NOT NULL default b'11110000111100'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error ER_INVALID_DEFAULT
+CREATE TABLE IF NOT EXISTS t1 (
+f1 bit(2) NOT NULL default b''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
 --echo End of 5.0 tests
 
 #

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2008-11-06 18:39:27 +0000
+++ b/sql/item.cc	2008-12-09 12:08:02 +0000
@@ -5294,6 +5294,9 @@ int Item_hex_string::save_in_field(Field
 
   ulonglong nr;
   uint32 length= str_value.length();
+  if (!length)
+    return 1;
+
   if (length > 8)
   {
     nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX;

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2008-10-20 09:16:47 +0000
+++ b/sql/item_strfunc.cc	2008-12-09 12:08:02 +0000
@@ -2177,10 +2177,11 @@ Item_func_format::Item_func_format(Item 
 
 void Item_func_format::fix_length_and_dec()
 {
-  collation.set(default_charset());
   uint char_length= args[0]->max_length/args[0]->collation.collation->mbmaxlen;
-  max_length= ((char_length + (char_length-args[0]->decimals)/3) *
-               collation.collation->mbmaxlen);
+  uint max_sep_count= char_length/3 + (decimals ? 1 : 0) + /*sign*/1;
+  collation.set(default_charset());
+  max_length= (char_length + max_sep_count + decimals) *
+    collation.collation->mbmaxlen;
 }
 
 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2008-11-28 16:30:27 +0000
+++ b/sql/sql_show.cc	2008-12-09 12:08:02 +0000
@@ -862,6 +862,7 @@ static bool get_field_default_value(THD 
 {
   bool has_default;
   bool has_now_default;
+  enum enum_field_types field_type= field->type();
 
   /*
      We are using CURRENT_TIMESTAMP instead of NOW because it is
@@ -870,7 +871,7 @@ static bool get_field_default_value(THD 
   has_now_default= (timestamp_field == field &&
                     field->unireg_check != Field::TIMESTAMP_UN_FIELD);
 
-  has_default= (field->type() != FIELD_TYPE_BLOB &&
+  has_default= (field_type != FIELD_TYPE_BLOB &&
                 !(field->flags & NO_DEFAULT_VALUE_FLAG) &&
                 field->unireg_check != Field::NEXT_NUMBER &&
                 !((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
@@ -885,7 +886,19 @@ static bool get_field_default_value(THD 
     {                                             // Not null by default
       char tmp[MAX_FIELD_WIDTH];
       String type(tmp, sizeof(tmp), field->charset());
-      field->val_str(&type);
+      if (field_type == MYSQL_TYPE_BIT)
+      {
+        longlong dec= field->val_int();
+        char *ptr= longlong2str(dec, tmp + 2, 2);
+        uint32 length= (uint32) (ptr - tmp);
+        tmp[0]= 'b';
+        tmp[1]= '\'';        
+        tmp[length]= '\'';
+        type.length(length + 1);
+        quoted= 0;
+      }
+      else
+        field->val_str(&type);
       if (type.length())
       {
         String def_val;

Thread
bzr commit into mysql-6.0-bugteam branch (Sergey.Glukhov:2785)Sergey Glukhov9 Dec