List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:May 6 2010 8:52pm
Subject:bzr push into mysql-pe branch (gshchepa:4058 to 4059)
View as plain text  
 4059 Gleb Shchepa	2010-05-07 [merge]
      auto-merge mysql-5.1-bugteam --> mysql-pe (bug 53088)

    modified:
      mysql-test/r/mysqldump.result
      mysql-test/r/outfile_loaddata.result
      mysql-test/t/mysqldump.test
      mysql-test/t/outfile_loaddata.test
      sql/sql_class.cc
 4058 Martin Hansson	2010-05-06 [merge]
      Merge of fix for Bug#52357

    modified:
      mysql-test/r/join_outer.result
      mysql-test/r/join_outer_jcl6.result
      mysql-test/t/join_outer.test
      sql/sql_select.cc
      sql/table.h
=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2010-04-19 08:49:47 +0000
+++ b/mysql-test/r/mysqldump.result	2010-05-06 20:48:31 +0000
@@ -4563,5 +4563,20 @@ a	b	c
 SET NAMES default;
 DROP TABLE t1, t2;
 #
+# Bug #53088: mysqldump with -T & --default-character-set set
+#             truncates text/blob to 766 chars
+#
+# Also see outfile_loaddata.test
+#
+CREATE TABLE t1 (a BLOB) CHARSET latin1;
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t1 VALUES (REPEAT('.', 800));
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.txt' INTO TABLE t2 CHARACTER SET latin1;
+# should be 800
+SELECT LENGTH(a) FROM t2;
+LENGTH(a)
+800
+DROP TABLE t1, t2;
+#
 # End of 5.1 tests
 #

=== modified file 'mysql-test/r/outfile_loaddata.result'
--- a/mysql-test/r/outfile_loaddata.result	2010-01-13 06:34:01 +0000
+++ b/mysql-test/r/outfile_loaddata.result	2010-05-06 20:48:31 +0000
@@ -239,4 +239,24 @@ a	b	c
 2	NULL	NULL
 SET NAMES default;
 DROP TABLE t1, t2;
+#
+# Bug #53088: mysqldump with -T & --default-character-set set
+#             truncates text/blob to 766 chars
+#
+# Also see mysqldump.test
+#
+CREATE TABLE t1 (a BLOB) CHARSET latin1;
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t1 VALUES (REPEAT('.', 800));
+SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug53088.txt' CHARACTER SET latin1 FROM t1;
+# should be greater than 800
+SELECT LENGTH(LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug53088.txt'));
+LENGTH(LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug53088.txt'))
+801
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug53088.txt' INTO TABLE t2;
+# should be 800
+SELECT LENGTH(a) FROM t2;
+LENGTH(a)
+800
+DROP TABLE t1, t2;
 # End of 5.1 tests.

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2010-04-11 07:12:00 +0000
+++ b/mysql-test/t/mysqldump.test	2010-05-06 20:48:31 +0000
@@ -2140,6 +2140,35 @@ SELECT * FROM t1 UNION SELECT * FROM t2 
 SET NAMES default;
 
 DROP TABLE t1, t2;
+###########################################################################
+
+--echo #
+--echo # Bug #53088: mysqldump with -T & --default-character-set set
+--echo #             truncates text/blob to 766 chars
+--echo #
+--echo # Also see outfile_loaddata.test
+--echo #
+
+CREATE TABLE t1 (a BLOB) CHARSET latin1;
+CREATE TABLE t2 LIKE t1;
+
+let $table= t1;
+let $dir= $MYSQLTEST_VARDIR/tmp;
+let $file= $dir/$table.txt;
+let $length= 800;
+
+--eval INSERT INTO t1 VALUES (REPEAT('.', $length))
+
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --tab=$dir/ test $table
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+
+--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET latin1
+--remove_file $file
+
+--echo # should be $length
+SELECT LENGTH(a) FROM t2;
+
+DROP TABLE t1, t2;
 
 ###########################################################################
 --echo #

=== modified file 'mysql-test/t/outfile_loaddata.test'
--- a/mysql-test/t/outfile_loaddata.test	2009-10-12 09:08:34 +0000
+++ b/mysql-test/t/outfile_loaddata.test	2010-05-06 20:48:31 +0000
@@ -251,6 +251,40 @@ SELECT * FROM t1 UNION SELECT * FROM t2 
 SET NAMES default;
 
 DROP TABLE t1, t2;
+###########################################################################
+
+--echo #
+--echo # Bug #53088: mysqldump with -T & --default-character-set set
+--echo #             truncates text/blob to 766 chars
+--echo #
+--echo # Also see mysqldump.test
+--echo #
+
+CREATE TABLE t1 (a BLOB) CHARSET latin1;
+CREATE TABLE t2 LIKE t1;
+
+let $file= '$MYSQLTEST_VARDIR/tmp/bug53088.txt';
+let $length= 800;
+
+--eval INSERT INTO t1 VALUES (REPEAT('.', $length))
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT * INTO OUTFILE $file CHARACTER SET latin1 FROM t1
+
+--echo # should be greater than $length
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT LENGTH(LOAD_FILE($file))
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval LOAD DATA INFILE $file INTO TABLE t2
+
+--remove_file $MYSQLTEST_VARDIR/tmp/bug53088.txt
+
+--echo # should be $length
+SELECT LENGTH(a) FROM t2;
+
+DROP TABLE t1, t2;
+
 
 ###########################################################################
 --echo # End of 5.1 tests.

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-05-04 15:21:22 +0000
+++ b/sql/sql_class.cc	2010-05-06 20:48:31 +0000
@@ -2179,9 +2179,21 @@ bool select_export::send_data(List<Item>
       const char *from_end_pos;
       const char *error_pos;
       uint32 bytes;
-      bytes= well_formed_copy_nchars(write_cs, cvt_buff, sizeof(cvt_buff),
+      uint64 estimated_bytes=
+        ((uint64) res->length() / res->charset()->mbminlen + 1) *
+        write_cs->mbmaxlen + 1;
+      set_if_smaller(estimated_bytes, UINT_MAX32);
+      if (cvt_str.realloc((uint32) estimated_bytes))
+      {
+        my_error(ER_OUTOFMEMORY, MYF(0), (uint32) estimated_bytes);
+        goto err;
+      }
+
+      bytes= well_formed_copy_nchars(write_cs, (char *) cvt_str.ptr(),
+                                     cvt_str.alloced_length(),
                                      res->charset(), res->ptr(), res->length(),
-                                     sizeof(cvt_buff),
+                                     UINT_MAX32, // copy all input chars,
+                                                 // i.e. ignore nchars parameter
                                      &well_formed_error_pos,
                                      &cannot_convert_error_pos,
                                      &from_end_pos);
@@ -2199,6 +2211,15 @@ bool select_export::send_data(List<Item>
                             "string", printable_buff,
                             item->name, row_count);
       }
+      else if (from_end_pos < res->ptr() + res->length())
+      { 
+        /*
+          result is longer than UINT_MAX32 and doesn't fit into String
+        */
+        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                            WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
+                            item->full_name(), row_count);
+      }
       cvt_str.length(bytes);
       res= &cvt_str;
     }


Attachment: [text/bzr-bundle] bzr/gshchepa@mysql.com-20100506204831-tv0gkx9hmkxl79gt.bundle
Thread
bzr push into mysql-pe branch (gshchepa:4058 to 4059)Gleb Shchepa6 May