List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:October 21 2007 5:45pm
Subject:bk commit into 5.0 tree (kaa:1.2546) BUG#28550
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kaa. When kaa 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-10-21 21:45:31+04:00, kaa@polly.(none) +5 -0
  Bug #28550 "Potential bugs related to the return type of the CHAR function".
    
  Since, as of MySQL 5.0.15, CHAR() arguments larger than 255 are converted into multiple result bytes, a single CHAR() argument can now take up to 4 bytes. This patch fixes Item_func_char::fix_length_and_dec() to take this into account.
    
  This patch also fixes a regression introduced by the patch for bug21513. As now we do not always have the 'name' member of Item set for Item_hex_string and Item_bin_string, an own print() method has been added to Item_hex_string so that it could correctly be printed by Item_func::print_args().

  mysql-test/r/func_str.result@stripped, 2007-10-21 21:00:18+04:00, kaa@polly.(none) +11 -1
    Import patch bug288550.patch

  mysql-test/t/func_str.test@stripped, 2007-10-21 21:00:18+04:00, kaa@polly.(none) +12 -0
    Import patch bug288550.patch

  sql/item.cc@stripped, 2007-10-21 21:00:18+04:00, kaa@polly.(none) +13 -0
    Import patch bug288550.patch

  sql/item.h@stripped, 2007-10-21 21:00:18+04:00, kaa@polly.(none) +1 -0
    Import patch bug288550.patch

  sql/item_strfunc.h@stripped, 2007-10-21 21:00:18+04:00, kaa@polly.(none) +1 -1
    Import patch bug288550.patch

diff -Nrup a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
--- a/mysql-test/r/func_str.result	2007-06-17 22:43:47 +04:00
+++ b/mysql-test/r/func_str.result	2007-10-21 21:00:18 +04:00
@@ -726,7 +726,7 @@ t1	CREATE TABLE `t1` (
   `oct(130)` varchar(64) NOT NULL default '',
   `conv(130,16,10)` varchar(64) NOT NULL default '',
   `hex(130)` varchar(6) NOT NULL default '',
-  `char(130)` varbinary(1) NOT NULL default '',
+  `char(130)` varbinary(4) NOT NULL default '',
   `format(130,10)` varchar(4) 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 '',
@@ -2153,4 +2153,14 @@ SUBSTR(a,1,len)
 ba
 
 DROP TABLE t1;
+CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1;
+SELECT HEX(c1) from t1;
+HEX(c1)
+414243
+DROP TABLE t1;
+CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1;
+SELECT HEX(c1) from v1;
+HEX(c1)
+414243
+DROP VIEW v1;
 End of 5.0 tests
diff -Nrup a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
--- a/mysql-test/t/func_str.test	2007-06-17 22:35:12 +04:00
+++ b/mysql-test/t/func_str.test	2007-10-21 21:00:18 +04:00
@@ -1124,4 +1124,16 @@ SELECT SUBSTR(a,1,len) FROM t1;
 
 DROP TABLE t1; 
 
+#
+# Bug #28850: Potential bugs related to the return type of the CHAR function
+#
+
+CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1;
+SELECT HEX(c1) from t1;
+DROP TABLE t1;
+
+CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1;
+SELECT HEX(c1) from v1;
+DROP VIEW v1;
+
 --echo End of 5.0 tests
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2007-10-16 12:17:35 +04:00
+++ b/sql/item.cc	2007-10-21 21:00:18 +04:00
@@ -4807,6 +4807,19 @@ warn:
 }
 
 
+void Item_hex_string::print(String *str)
+{
+  char *end= (char*) str_value.ptr() + str_value.length(),
+       *ptr= end - min(str_value.length(), sizeof(longlong));
+  str->append("0x");
+  for (; ptr != end ; ptr++)
+  {
+    str->append(_dig_vec_lower[((uchar) *ptr) >> 4]);
+    str->append(_dig_vec_lower[((uchar) *ptr) & 0x0F]);
+  }
+}
+
+
 bool Item_hex_string::eq(const Item *arg, bool binary_cmp) const
 {
   if (arg->basic_const_item() && arg->type() == type())
diff -Nrup a/sql/item.h b/sql/item.h
--- a/sql/item.h	2007-10-16 12:19:00 +04:00
+++ b/sql/item.h	2007-10-21 21:00:18 +04:00
@@ -1858,6 +1858,7 @@ public:
   enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
   // to prevent drop fixed flag (no need parent cleanup call)
   void cleanup() {}
+  void print(String *str);
   bool eq(const Item *item, bool binary_cmp) const;
   virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
 };
diff -Nrup a/sql/item_strfunc.h b/sql/item_strfunc.h
--- a/sql/item_strfunc.h	2007-10-11 15:07:09 +04:00
+++ b/sql/item_strfunc.h	2007-10-21 21:00:18 +04:00
@@ -534,7 +534,7 @@ public:
   String *val_str(String *);
   void fix_length_and_dec() 
   {
-    max_length= arg_count * collation.collation->mbmaxlen;
+    max_length= arg_count * 4;
   }
   const char *func_name() const { return "char"; }
 };
Thread
bk commit into 5.0 tree (kaa:1.2546) BUG#28550Alexey Kopytov21 Oct