Loading mysql-test/r/loaddata.result +8 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,14 @@ id 0 SET @@SQL_MODE=@OLD_SQL_MODE; drop table t1; create table t1 (a varchar(20), b varchar(20)); load data infile '../../std_data/loaddata_dq.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; create table t1 (a int default 100, b int, c varchar(60)); load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); select * from t1; Loading mysql-test/std_data/loaddata_dq.dat 0 → 100644 +3 −0 Original line number Diff line number Diff line "field1","field2" "a""b","cd""ef" "a"b",c"d"e mysql-test/t/loaddata.test +11 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated select * from t1; drop table t1; # # Bug #12053 LOAD DATA INFILE ignores NO_AUTO_VALUE_ON_ZERO setting # Loading Loading @@ -59,6 +58,15 @@ select * from t1; SET @@SQL_MODE=@OLD_SQL_MODE; 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/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); select * from t1; drop table t1; # End of 4.1 tests # Loading Loading @@ -104,3 +112,5 @@ select * from t1; # cleanup drop table t1, t2; # End of 5.0 tests sql/item.cc +1 −1 Original line number Diff line number Diff line Loading @@ -3248,7 +3248,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) Item** res= find_item_in_list(this, thd->lex->current_select->item_list, &counter, REPORT_EXCEPT_NOT_FOUND, ¬_used); if (res != not_found_item && (*res)->type() == Item::FIELD_ITEM) if (res != (Item **)not_found_item && (*res)->type() == Item::FIELD_ITEM) { set_field((*((Item_field**)res))->field); return 0; Loading sql/sql_load.cc +17 −2 Original line number Diff line number Diff line Loading @@ -1014,9 +1014,24 @@ int READ_INFO::read_field() *to++= (byte) escape_char; goto found_eof; } /* 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) #else Loading Loading
mysql-test/r/loaddata.result +8 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,14 @@ id 0 SET @@SQL_MODE=@OLD_SQL_MODE; drop table t1; create table t1 (a varchar(20), b varchar(20)); load data infile '../../std_data/loaddata_dq.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; create table t1 (a int default 100, b int, c varchar(60)); load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); select * from t1; Loading
mysql-test/std_data/loaddata_dq.dat 0 → 100644 +3 −0 Original line number Diff line number Diff line "field1","field2" "a""b","cd""ef" "a"b",c"d"e
mysql-test/t/loaddata.test +11 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated select * from t1; drop table t1; # # Bug #12053 LOAD DATA INFILE ignores NO_AUTO_VALUE_ON_ZERO setting # Loading Loading @@ -59,6 +58,15 @@ select * from t1; SET @@SQL_MODE=@OLD_SQL_MODE; 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/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); select * from t1; drop table t1; # End of 4.1 tests # Loading Loading @@ -104,3 +112,5 @@ select * from t1; # cleanup drop table t1, t2; # End of 5.0 tests
sql/item.cc +1 −1 Original line number Diff line number Diff line Loading @@ -3248,7 +3248,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) Item** res= find_item_in_list(this, thd->lex->current_select->item_list, &counter, REPORT_EXCEPT_NOT_FOUND, ¬_used); if (res != not_found_item && (*res)->type() == Item::FIELD_ITEM) if (res != (Item **)not_found_item && (*res)->type() == Item::FIELD_ITEM) { set_field((*((Item_field**)res))->field); return 0; Loading
sql/sql_load.cc +17 −2 Original line number Diff line number Diff line Loading @@ -1014,9 +1014,24 @@ int READ_INFO::read_field() *to++= (byte) escape_char; goto found_eof; } /* 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) #else Loading