summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@mysql.com/bar.myoffice.izhnet.ru>2007-10-04 13:06:01 +0500
committerunknown <bar@mysql.com/bar.myoffice.izhnet.ru>2007-10-04 13:06:01 +0500
commitd0b076b66cef0335a884fa96c1c636bbef31a9db (patch)
tree9a32d919ba7b45b7843068fafa4433d65f6c1dff
parent11045636df54d53159cba0dfdfe4ffae47586cdb (diff)
downloadmariadb-git-d0b076b66cef0335a884fa96c1c636bbef31a9db.tar.gz
Bug#29323 mysql client only accetps ANSI encoded files
Fix: ignore BOM marker in the first line. client/mysql.cc: Skip BOM marker in the very first line. mysql-test/r/mysql.result: Adding test mysql-test/t/mysql.test: Adding test
-rw-r--r--client/mysql.cc11
-rw-r--r--mysql-test/r/mysql.result2
-rw-r--r--mysql-test/t/mysql.test9
3 files changed, 22 insertions, 0 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 8e1b6c2a9b4..3cc7f2ad090 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1042,6 +1042,17 @@ static int read_and_execute(bool interactive)
if (!interactive)
{
line=batch_readline(status.line_buff);
+ /*
+ Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
+ Editors like "notepad" put this marker in
+ the very beginning of a text file when
+ you save the file using "Unicode UTF-8" format.
+ */
+ if (!line_number &&
+ (uchar) line[0] == 0xEF &&
+ (uchar) line[1] == 0xBB &&
+ (uchar) line[2] == 0xBF)
+ line+= 3;
line_number++;
if (!glob_buffer.length())
status.query_start_line=line_number;
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index c6e589a5fb7..eded1a3fc3b 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -178,4 +178,6 @@ ERROR at line 1: DELIMITER cannot contain a backslash character
1
1
1
+This is a file starting with UTF8 BOM 0xEFBBBF
+This is a file starting with UTF8 BOM 0xEFBBBF
End of 5.0 tests
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index 6e97d0faede..182b292c817 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -281,4 +281,13 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
#
--exec $MYSQL test -e "/*! \C latin1 */ select 1;"
+#
+# Bug#29323 mysql client only accetps ANSI encoded files
+#
+--write_file $MYSQLTEST_VARDIR/tmp/bug29323.sql
+select "This is a file starting with UTF8 BOM 0xEFBBBF";
+EOF
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1
+remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql;
+
--echo End of 5.0 tests