summaryrefslogtreecommitdiff
path: root/mysql-test/t/mysql.test
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@sun.com>2009-03-18 11:18:24 +0300
committerAlexey Kopytov <Alexey.Kopytov@sun.com>2009-03-18 11:18:24 +0300
commit73a7d99331d8fd0819fb9f7a10081e393590a94d (patch)
tree2165879ba56fa3d6417a48e08d8533be302af75f /mysql-test/t/mysql.test
parent5d2fc5335411bdd05a08a9b062d3441d4308dcaa (diff)
downloadmariadb-git-73a7d99331d8fd0819fb9f7a10081e393590a94d.tar.gz
Fix for bug#41486: extra character appears in BLOB for every
~40Mb after mysqldump/import When the input string exceeds the maximum allowed size for the internal buffer, batch_readline() returns a truncated string. Since there was no way for a caller to determine whether the string was truncated or not, the command line client assumed batch_readline() to always return the whole input string and appended a newline character. This resulted in garbled data when importing dumps containing strings longer than the maximum input buffer size. Fixed by adding a flag to the batch_readline() interface to signal a truncated string to the caller. Other minor problems fixed during patch implementation: - The maximum allowed buffer size for batch_readline() was set up depending on the client's max_allowed_packet value. It does not actully make any sense, as those variables are not related. The input buffer size limit is now always set to 1 MB. - fill_buffer() did not always set the EOF flag. - The input buffer could actually grow twice as the specified limit due to insufficient checks in intern_read_line(). client/my_readline.h: Changed the interface of batch_readline(). client/mysql.cc: Honor the truncated flag returned by batch_readline() and do not append the newline character if it was set. Since we can't change the interfaces for readline()/fgets() used in the interactive mode, always assume the returned string was not truncated. In addition, always set the batch_readline() internal buffer to 1 MB, independently from the client's max_allowed_packet. client/readline.cc: Added the 'truncated' argument do batch_readline() to signal truncated string to a caller. Fixed fill_buffer() to set the EOF flag correctly. Fixed checks in intern_read_line() to not allow the internal buffer grow past the specified limit. mysql-test/r/mysql.result: Added a test case for bug #41486. mysql-test/t/mysql.test: Added a test case for bug #41486.
Diffstat (limited to 'mysql-test/t/mysql.test')
-rw-r--r--mysql-test/t/mysql.test27
1 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index 594d10e46a5..0030f624be6 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -331,4 +331,31 @@ EOF
remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
+#
+# Bug #41486: extra character appears in BLOB for every ~40Mb after
+# mysqldump/import
+#
+
+# Have to change the global variable as the mysql client will use
+# a separate session
+set @old_max_allowed_packet = @@global.max_allowed_packet;
+# 2 MB blob length + some space for the rest of INSERT query
+set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024;
+set @@max_allowed_packet = @@global.max_allowed_packet;
+
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024);
+
+--exec $MYSQL_DUMP test t1 >$MYSQLTEST_VARDIR/tmp/bug41486.sql
+# Check that the mysql client does not insert extra newlines when loading
+# strings longer than client's max_allowed_packet
+--exec $MYSQL --max_allowed_packet=1M test < $MYSQLTEST_VARDIR/tmp/bug41486.sql 2>&1
+SELECT LENGTH(data) FROM t1;
+
+remove_file $MYSQLTEST_VARDIR/tmp/bug41486.sql;
+DROP TABLE t1;
+
+set @@global.max_allowed_packet = @old_max_allowed_packet;
+set @@max_allowed_packet = @@global.max_allowed_packet;
+
--echo End of 5.0 tests