diff options
author | gshchepa/uchum@gleb.loc <> | 2007-07-06 03:43:23 +0500 |
---|---|---|
committer | gshchepa/uchum@gleb.loc <> | 2007-07-06 03:43:23 +0500 |
commit | c33f4d3d85fdbedd21e9b9830341b7e3e3434151 (patch) | |
tree | 38e72a5d8c618981a5dbae64c641605be1408d86 /sql/sql_class.cc | |
parent | eb454f85d96666f2116e683c2e016d6dfcf83854 (diff) | |
download | mariadb-git-c33f4d3d85fdbedd21e9b9830341b7e3e3434151.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.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 117c20352ce..036ba217a9b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1210,6 +1210,7 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u) field_term_length ? (*exchange->field_term)[0] : INT_MAX); escape_char= (exchange->escaped->length() ? (*exchange->escaped)[0] : -1); is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char)); + is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char)); line_sep_char= (exchange->line_term->length() ? (*exchange->line_term)[0] : INT_MAX); if (!field_term_length) @@ -1284,7 +1285,8 @@ bool select_export::send_data(List<Item> &items) used_length=min(res->length(),item->max_length); else used_length=res->length(); - if (result_type == STRING_RESULT && escape_char != -1) + if ((result_type == STRING_RESULT || is_unsafe_field_sep) && + escape_char != -1) { char *pos, *start, *end; CHARSET_INFO *res_charset= res->charset(); |