summaryrefslogtreecommitdiff
path: root/sql/sql_load.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-06-22 16:14:14 -0700
committerunknown <jimw@mysql.com>2005-06-22 16:14:14 -0700
commitc686f699b22c8ff7f3f9f2a6f550cdcb23db4793 (patch)
treec437713521665097653a262fd2146db1abd22f80 /sql/sql_load.cc
parent31d07866873631f79177fb1277bacfec62062c80 (diff)
downloadmariadb-git-c686f699b22c8ff7f3f9f2a6f550cdcb23db4793.tar.gz
Fix LOAD DATA to handle having the escape and enclosed-by character
be the same. (Bug #11203) mysql-test/r/loaddata.result: Update results mysql-test/t/loaddata.test: Add new test sql/sql_load.cc: Handle having escape_char and enclosed_char the same when loading data. mysql-test/std_data/loaddata5.dat: New BitKeeper file ``mysql-test/std_data/loaddata5.dat''
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r--sql/sql_load.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index c4f5b1427af..b998f39971c 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -799,8 +799,23 @@ int READ_INFO::read_field()
*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)