From: Date: June 23 2005 1:14am Subject: bk commit into 4.1 tree (jimw:1.2311) BUG#11203 List-Archive: http://lists.mysql.com/internals/26346 X-Bug: 11203 Message-Id: <20050622231417.9EC61A8900@rama.trainedmonkey.com> Below is the list of changes that have just been committed into a local 4.1 repository of jimw. When jimw 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 1.2311 05/06/22 16:14:14 jimw@stripped +4 -0 Fix LOAD DATA to handle having the escape and enclosed-by character be the same. (Bug #11203) mysql-test/std_data/loaddata5.dat 1.1 05/06/22 16:14:11 jimw@stripped +3 -0 New BitKeeper file ``mysql-test/std_data/loaddata5.dat'' sql/sql_load.cc 1.84 05/06/22 16:14:11 jimw@stripped +17 -2 Handle having escape_char and enclosed_char the same when loading data. mysql-test/t/loaddata.test 1.8 05/06/22 16:14:11 jimw@stripped +8 -0 Add new test mysql-test/std_data/loaddata5.dat 1.0 05/06/22 16:14:11 jimw@stripped +0 -0 BitKeeper file /home/jimw/my/mysql-4.1-11203/mysql-test/std_data/loaddata5.dat mysql-test/r/loaddata.result 1.15 05/06/22 16:14:11 jimw@stripped +8 -0 Update results # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: jimw # Host: rama.(none) # Root: /home/jimw/my/mysql-4.1-11203 --- 1.83/sql/sql_load.cc 2004-12-31 02:04:30 -08:00 +++ 1.84/sql/sql_load.cc 2005-06-22 16:14:11 -07:00 @@ -799,8 +799,23 @@ *to++= (byte) escape_char; goto found_eof; } - *to++ = (byte) unescape((char) chr); - continue; + /* + When escape_char == enclosed_char, we treat it like we do for + handling quotes in SQL parsing -- you can double-up the + escape_char to include it literally, but it doesn't do escapes + like \n. This allows: LOAD DATA ... ENCLOSED BY '"' ESCAPED BY '"' + with data like: "fie""ld1", "field2" + */ + if (escape_char != enclosed_char || chr == escape_char) + { + *to++ = (byte) unescape((char) chr); + continue; + } + else + { + PUSH(chr); + chr= escape_char; + } } #ifdef ALLOW_LINESEPARATOR_IN_STRINGS if (chr == line_term_char) --- New file --- +++ mysql-test/std_data/loaddata5.dat 05/06/22 16:14:11 "field1","field2" "a""b","cd""ef" "a"b",c"d"e --- 1.14/mysql-test/r/loaddata.result 2004-06-15 13:38:33 -07:00 +++ 1.15/mysql-test/r/loaddata.result 2005-06-22 16:14:11 -07:00 @@ -66,3 +66,11 @@ 3 row 3 0 drop table t1; +create table t1 (a varchar(20), b varchar(20)); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); +select * from t1; +a b +field1 field2 +a"b cd"ef +a"b c"d"e +drop table t1; --- 1.7/mysql-test/t/loaddata.test 2004-03-20 02:29:41 -08:00 +++ 1.8/mysql-test/t/loaddata.test 2005-06-22 16:14:11 -07:00 @@ -31,3 +31,11 @@ select * from t1; drop table t1; +# +# Bug #11203: LOAD DATA does not accept same characters for ESCAPED and +# ENCLOSED +# +create table t1 (a varchar(20), b varchar(20)); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); +select * from t1; +drop table t1;