Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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@stripped, 2007-10-19 17:12:10+05:00, gshchepa@stripped +5 -0
Fixed bug #31663: if the FIELDS TERMINATED BY string
in the SELECT INTO OUTFILE clause starts with a special
character (one of n, t, r, b, 0, Z or N) and ENCLOSED BY
is empty, every occurrence of this character within a
field value is duplicated.
Duplication has been avoided.
New warning message has been added: "First character of
the FIELDS TERMINATED string is ambiguous; please use
FIELDS ENCLOSED BY".
mysql-test/r/outfile.result@stripped, 2007-10-19 16:52:31+05:00, gshchepa@stripped +25 -1
Added test case for bug #31663.
mysql-test/t/outfile.test@stripped, 2007-10-19 16:52:18+05:00, gshchepa@stripped +37 -0
Added test case for bug #31663.
sql/share/errmsg.txt@stripped, 2007-10-19 16:59:41+05:00, gshchepa@stripped +2 -0
Fixed bug #31663.
The ER_AMBIGUOUS_FIELD_TERM warning has been added.
sql/sql_class.cc@stripped, 2007-10-19 16:52:14+05:00, gshchepa@stripped +21 -6
Fixed bug #31663.
The select_export::prepare method has been modified to calculate
a value of the select_export::is_ambiguous_field_term field and
to warn if this value is true.
The select_export::send_data method has been modified to
avoid escaping or duplication of the field_set_char if
is_ambiguous_field_term is true.
sql/sql_class.h@stripped, 2007-10-19 16:51:56+05:00, gshchepa@stripped +6 -0
Fixed bug #31663.
The select_export::is_ambiguous_field_term has been added.
This field is true if select_export::field_sep_char contains
the first char of the FIELDS TERMINATED BY (ENCLOSED BY is empty),
and items can contain this character.
Binary files a/mysql-test/r/outfile.result and b/mysql-test/r/outfile.result differ
diff -Nrup a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test
--- a/mysql-test/t/outfile.test 2007-05-18 01:17:44 +05:00
+++ b/mysql-test/t/outfile.test 2007-10-19 16:52:18 +05:00
@@ -131,3 +131,40 @@ revoke all privileges on *.* from user_1
drop user user_1@localhost;
drop database mysqltest;
+#
+# Bug#31663 FIELDS TERMINATED BY special character
+#
+
+CREATE TABLE t1 (c1 VARCHAR(256), c2 VARCHAR(256), i1 int, i2 int);
+INSERT INTO t1 VALUES ('-r-', '=r=', 101, 202);
+SELECT * FROM t1;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval
+SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt'
+ FIELDS TERMINATED BY 'raker'
+ FROM t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt');
+--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval
+SELECT i1, i2 INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt'
+ FIELDS TERMINATED BY 'r'
+ FROM t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt');
+--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval
+SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt'
+ FIELDS TERMINATED BY '0'
+ FROM t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt');
+--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
+
+DROP TABLE t1;
+
diff -Nrup a/sql/share/errmsg.txt b/sql/share/errmsg.txt
--- a/sql/share/errmsg.txt 2007-09-13 18:30:34 +05:00
+++ b/sql/share/errmsg.txt 2007-10-19 16:59:41 +05:00
@@ -5639,3 +5639,5 @@ ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
eng "Too high level of nesting for select"
ER_NAME_BECOMES_EMPTY
eng "Name '%-.64s' has become ''"
+ER_AMBIGUOUS_FIELD_TERM
+ eng "First character of the FIELDS TERMINATED string is ambiguous; please use FIELDS ENCLOSED BY"
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc 2007-08-02 05:39:10 +05:00
+++ b/sql/sql_class.cc 2007-10-19 16:52:14 +05:00
@@ -1194,6 +1194,7 @@ int
select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{
bool blob_flag=0;
+ bool string_results= FALSE;
unit= u;
if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN)
strmake(path,exchange->file_name,FN_REFLEN-1);
@@ -1211,6 +1212,8 @@ select_export::prepare(List<Item> &list,
blob_flag=1;
break;
}
+ if (item->result_type() == STRING_RESULT)
+ string_results= TRUE;
}
}
field_term_length=exchange->field_term->length();
@@ -1229,6 +1232,17 @@ select_export::prepare(List<Item> &list,
exchange->opt_enclosed=1; // A little quicker loop
fixed_row_size= (!field_term_length && !exchange->enclosed->length() &&
!blob_flag);
+
+ if (is_ambiguous_field_sep && exchange->enclosed->is_empty() &&
+ (string_results || field_sep_char == '0'))
+ {
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_AMBIGUOUS_FIELD_TERM, ER(ER_AMBIGUOUS_FIELD_TERM));
+ is_ambiguous_field_term= TRUE;
+ }
+ else
+ is_ambiguous_field_term= FALSE;
+
return 0;
}
@@ -1355,14 +1369,15 @@ bool select_export::send_data(List<Item>
DBUG_ASSERT before the loop makes that sure.
*/
- if (NEED_ESCAPING(*pos) ||
- (check_second_byte &&
- my_mbcharlen(character_set_client, (uchar) *pos) == 2 &&
- pos + 1 < end &&
- NEED_ESCAPING(pos[1])))
+ if ((NEED_ESCAPING(*pos) ||
+ (check_second_byte &&
+ my_mbcharlen(character_set_client, (uchar) *pos) == 2 &&
+ pos + 1 < end &&
+ NEED_ESCAPING(pos[1]))) &&
+ (!is_ambiguous_field_term || (uchar) *pos != field_sep_char))
{
char tmp_buff[2];
- tmp_buff[0]= ((int) *pos == field_sep_char &&
+ tmp_buff[0]= ((uchar) *pos == field_sep_char &&
is_ambiguous_field_sep) ?
field_sep_char : escape_char;
tmp_buff[1]= *pos ? *pos : '0';
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h 2007-09-21 13:06:30 +05:00
+++ b/sql/sql_class.h 2007-10-19 16:51:56 +05:00
@@ -1999,6 +1999,12 @@ class select_export :public select_to_fi
*/
bool is_ambiguous_field_sep;
/*
+ The is_ambiguous_field_term is true if field_sep_char contains the first
+ char of the FIELDS TERMINATED BY (ENCLOSED BY is empty), and items can
+ contain this character.
+ */
+ bool is_ambiguous_field_term;
+ /*
The is_unsafe_field_sep field is true if a value of the field_sep_char
field is one of the '0'..'9', '+', '-', '.' and 'e' characters
(see the NUMERIC_CHARS constant value).
| Thread |
|---|
| • bk commit into 5.0 tree (gshchepa:1.2544) BUG#31663 | gshchepa | 19 Oct |