From dab880274afbae01571257feebb819d94b861c01 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 22 Jun 2005 16:14:14 -0700 Subject: Fix LOAD DATA to handle having the escape and enclosed-by character be the same. (Bug #11203) --- sql/sql_load.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'sql/sql_load.cc') 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) -- cgit v1.2.1