Skip to content

Commit 09348e2

Browse files
fixed 'STARTING BY' in replication
1 parent d2bfaed commit 09348e2

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

mysql-test/r/rpl_loaddata.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ slave start;
77
create table t1(a int not null auto_increment, b int, primary key(a) );
88
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
99
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
10-
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' ignore 1 lines;
10+
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
1111
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
1212
insert into t3 select * from t2;
1313
select * from t1;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
2003-01-21,6328,%a%,%aaaaa%
1+
>2003-01-21,6328,%a%,%aaaaa%
22
##
3-
2003-02-22,2461,b,%a a a @@ @% @b ' " a%
3+
>2003-02-22,2461,b,%a a a @@ @% @b ' " a%
44
##
5-
2003-03-22,2161,%c%,%asdf%
5+
>2003-03-22,2161,%c%,%asdf%
66
##
7-
2003-04-22,2416,%a%,%bbbbb%
7+
>2003-04-22,2416,%a%,%bbbbb%
88
##

mysql-test/t/rpl_loaddata.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ create table t1(a int not null auto_increment, b int, primary key(a) );
1010
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
1111

1212
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
13-
#load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionaly enclosed by '%' escaped by '@' lines terminated by '\n%%\n' ignore 1 lines;
14-
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' ignore 1 lines;
13+
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
1514

1615
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
1716
insert into t3 select * from t2;

sql/log_event.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,19 @@ void Load_log_event::pack_info(String* packet)
309309
pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len);
310310
}
311311

312+
bool line_lexem_added= false;
312313
if (sql_ex.line_term_len)
313314
{
314315
tmp.append(" LINES TERMINATED BY ");
315316
pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len);
317+
line_lexem_added= true;
316318
}
317319

318320
if (sql_ex.line_start_len)
319321
{
320-
tmp.append(" LINES STARTING BY ");
322+
if (!line_lexem_added)
323+
tmp.append(" LINES");
324+
tmp.append(" STARTING BY ");
321325
pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len);
322326
}
323327

@@ -1299,15 +1303,19 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db)
12991303
pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len);
13001304
}
13011305

1306+
bool line_lexem_added= false;
13021307
if (sql_ex.line_term)
13031308
{
13041309
fprintf(file," LINES TERMINATED BY ");
13051310
pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len);
1311+
line_lexem_added= true;
13061312
}
13071313

13081314
if (sql_ex.line_start)
13091315
{
1310-
fprintf(file," LINES STARTING BY ");
1316+
if (!line_lexem_added)
1317+
fprintf(file," LINES");
1318+
fprintf(file," STARTING BY ");
13111319
pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len);
13121320
}
13131321

0 commit comments

Comments
 (0)