summaryrefslogtreecommitdiff
path: root/mysql-test/t/loaddata.test
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-07-06 03:43:23 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-07-06 03:43:23 +0500
commit725b49716b2bfb88361f37df2fd882578998b131 (patch)
tree38e72a5d8c618981a5dbae64c641605be1408d86 /mysql-test/t/loaddata.test
parente0f93ca8c1955cc2766c224703a278e66d9c05bc (diff)
downloadmariadb-git-725b49716b2bfb88361f37df2fd882578998b131.tar.gz
Fixed bug #29442.
The SELECT INTO OUTFILE FIELDS ENCLOSED BY digit or minus sign, followed by the same LOAD DATA INFILE statement, used wrond encoding of non-string fields contained the enclosed character in their text representation. Example: SELECT 15, 9 INTO OUTFILE 'text' FIELDS ENCLOSED BY '5'; Old encoded result in the text file: 5155 595 ^ was decoded as the 1st enclosing character of the 2nd field; ^ was skipped as garbage; ^ ^ was decoded as a pair of englosing characters of the 1st field; ^ was decoded as traling space of the first field; ^^ was decoded as a doubled enclosed character. New encoded result in the text file: 51\55 595 ^ ^ pair of enclosing characters of the 1st field; ^^ escaped enclosed character. sql/sql_class.h: Fixed bug #29442. The NUMERIC_CHARS macro constant has been defined to enumerate all possible characters of a numeric value text representation. The select_export::is_unsafe_field_sep boolean flag has been added to apply the encoding algorithm to non-string values when it is necessary. sql/sql_class.cc: Fixed bug #29442. The select_export::send_data method has been modified to encode text representation of fields of all data types like string fields. mysql-test/t/loaddata.test: Updated test case for bug #29442. mysql-test/r/loaddata.result: Updated test case for bug #29442.
Diffstat (limited to 'mysql-test/t/loaddata.test')
-rw-r--r--mysql-test/t/loaddata.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index cdd3bb80b6e..260e760e7b3 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -213,4 +213,29 @@ select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
--exec rm $MYSQLTEST_VARDIR/tmp/t2
drop table t1,t2;
+#
+# Bug#29442: SELECT INTO OUTFILE FIELDS ENCLOSED BY digit, minus sign etc
+# corrupts non-string fields containing this character.
+#
+
+CREATE TABLE t1 (c1 INT, c2 TIMESTAMP, c3 REAL, c4 DOUBLE);
+
+INSERT INTO t1 (c1, c2, c3, c4) VALUES (10, '1970-02-01 01:02:03', 1.1E-100, 1.1E+100);
+SELECT * FROM t1;
+
+--exec rm -f $MYSQLTEST_VARDIR/tmp/t1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1;
+--exec cat $MYSQLTEST_VARDIR/tmp/t1
+--exec echo EOF
+
+TRUNCATE t1;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t1 FIELDS ENCLOSED BY '-';
+SELECT * FROM t1;
+
+--exec rm $MYSQLTEST_VARDIR/tmp/t1
+DROP TABLE t1;
+
# End of 5.0 tests