Commit d505e3de authored by unknown's avatar unknown

Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails

Problem: when loading mysqlbinlog dumps, CREATE PROCEDURE having semicolons
in their bodies failed.
Fix: Using safe delimiter "/*!*/;" to dump log entries.


client/mysqlbinlog.cc:
  - Adding PRINT_EVENT_INFO argument to dump_xxx_log_entries()
  - Setting delimiter to "/*!*/;" before calling dump functions
mysql-test/r/ctype_ucs_binlog.result:
  Fixing test results
mysql-test/r/mix_innodb_myisam_binlog.result:
  Fixing test results
mysql-test/r/mysqlbinlog.result:
  Fixing test results
  Adding test case
mysql-test/r/mysqlbinlog2.result:
  Fixing test results
mysql-test/r/rpl_charset.result:
  Fixing test results
mysql-test/r/rpl_timezone.result:
  Fixing test results
mysql-test/r/user_var-binlog.result:
  Fixing test results
mysql-test/t/mix_innodb_myisam_binlog.test:
  Fixing LIKE expression
mysql-test/t/mysqlbinlog.test:
  Adding test case
sql/log_event.cc:
  Using print_event_info->delimiter instead of
  hard-coded semicolon as a query end marker.
sql/log_event.h:
  Adding new member to store delimiter.
parent eb717155
......@@ -94,8 +94,10 @@ static bool stop_passed= 0;
*/
Format_description_log_event* description_event;
static int dump_local_log_entries(const char* logname);
static int dump_remote_log_entries(const char* logname);
static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname);
static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname);
static int dump_log_entries(const char* logname);
static int dump_remote_file(NET* net, const char* fname);
static void die(const char* fmt, ...);
......@@ -950,8 +952,22 @@ static MYSQL* safe_connect()
static int dump_log_entries(const char* logname)
{
return (remote_opt ? dump_remote_log_entries(logname) :
dump_local_log_entries(logname));
int rc;
PRINT_EVENT_INFO print_event_info;
/*
Set safe delimiter, to dump things
like CREATE PROCEDURE safely
*/
fprintf(result_file, "DELIMITER /*!*/;\n");
strcpy(print_event_info.delimiter, "/*!*/;");
rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) :
dump_local_log_entries(&print_event_info, logname));
/* Set delimiter back to semicolon */
fprintf(result_file, "DELIMITER ;\n");
strcpy(print_event_info.delimiter, ";");
return rc;
}
......@@ -1016,11 +1032,11 @@ static int check_master_version(MYSQL* mysql,
}
static int dump_remote_log_entries(const char* logname)
static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname)
{
char buf[128];
PRINT_EVENT_INFO print_event_info;
ulong len;
uint logname_len;
NET* net;
......@@ -1143,7 +1159,7 @@ could be out of memory");
len= 1; // fake Rotate, so don't increment old_off
}
}
if ((error= process_event(&print_event_info, ev, old_off)))
if ((error= process_event(print_event_info, ev, old_off)))
{
error= ((error < 0) ? 0 : 1);
goto err;
......@@ -1162,7 +1178,7 @@ could be out of memory");
goto err;
}
if ((error= process_event(&print_event_info, ev, old_off)))
if ((error= process_event(print_event_info, ev, old_off)))
{
my_close(file,MYF(MY_WME));
error= ((error < 0) ? 0 : 1);
......@@ -1288,11 +1304,11 @@ at offset %lu ; this could be a log format error or read error",
}
static int dump_local_log_entries(const char* logname)
static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname)
{
File fd = -1;
IO_CACHE cache,*file= &cache;
PRINT_EVENT_INFO print_event_info;
byte tmp_buff[BIN_LOG_HEADER_SIZE];
int error= 0;
......@@ -1364,7 +1380,7 @@ static int dump_local_log_entries(const char* logname)
// file->error == 0 means EOF, that's OK, we break in this case
break;
}
if ((error= process_event(&print_event_info, ev, old_off)))
if ((error= process_event(print_event_info, ev, old_off)))
{
if (error < 0)
error= 0;
......
......@@ -9,15 +9,17 @@ master-bin.000001 98 User var 1 138 @`v`=_ucs2 0x006100620063 COLLATE ucs2_gener
master-bin.000001 138 Query 1 227 use `test`; insert into t2 values (@v)
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
ROLLBACK;
SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`;
use test;
SET TIMESTAMP=10000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
SET @@session.sql_mode=0;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t2 values (@v);
DELIMITER /*!*/;
ROLLBACK/*!*/;
SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
use test/*!*/;
SET TIMESTAMP=10000/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
insert into t2 values (@v)/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
......
......@@ -275,8 +275,8 @@ is not null;
is not null
1
select
@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%",
@a not like "%#%error_code=%error_code=%";
@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%"
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%"
1 1
drop table t1, t2;
This diff is collapsed.
This diff is collapsed.
......@@ -176,84 +176,86 @@ hex(c1) hex(c2)
CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
ROLLBACK;
SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
SET @@session.sql_mode=0;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
drop database if exists mysqltest2;
SET TIMESTAMP=1000000000;
drop database if exists mysqltest3;
SET TIMESTAMP=1000000000;
create database mysqltest2 character set latin2;
SET TIMESTAMP=1000000000;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=30;
create database mysqltest3;
SET TIMESTAMP=1000000000;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=64;
drop database mysqltest3;
SET TIMESTAMP=1000000000;
create database mysqltest3;
use mysqltest2;
SET TIMESTAMP=1000000000;
create table t1 (a int auto_increment primary key, b varchar(100));
SET INSERT_ID=1;
SET TIMESTAMP=1000000000;
/*!\C cp850 */;
SET @@session.character_set_client=4,@@session.collation_connection=27,@@session.collation_server=64;
insert into t1 (b) values(@@character_set_server);
SET INSERT_ID=2;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(@@collation_server);
SET INSERT_ID=3;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(@@character_set_client);
SET INSERT_ID=4;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(@@character_set_connection);
SET INSERT_ID=5;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(@@collation_connection);
SET TIMESTAMP=1000000000;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=5,@@session.collation_server=64;
truncate table t1;
SET INSERT_ID=1;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(@@collation_connection);
SET INSERT_ID=2;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(LEAST("Mller","Muffler"));
SET INSERT_ID=3;
SET TIMESTAMP=1000000000;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=31,@@session.collation_server=64;
insert into t1 (b) values(@@collation_connection);
SET INSERT_ID=4;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(LEAST("Mller","Muffler"));
SET TIMESTAMP=1000000000;
truncate table t1;
SET INSERT_ID=1;
SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`;
SET TIMESTAMP=1000000000;
insert into t1 (b) values(collation(@a));
SET TIMESTAMP=1000000000;
drop database mysqltest2;
SET TIMESTAMP=1000000000;
drop database mysqltest3;
use test;
SET TIMESTAMP=1000000000;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=30;
CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255));
SET TIMESTAMP=1000000000;
/*!\C koi8r */;
SET @@session.character_set_client=7,@@session.collation_connection=51,@@session.collation_server=30;
INSERT INTO t1 (c1, c2) VALUES (', ',', ');
DELIMITER /*!*/;
ROLLBACK/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
drop database if exists mysqltest2/*!*/;
SET TIMESTAMP=1000000000/*!*/;
drop database if exists mysqltest3/*!*/;
SET TIMESTAMP=1000000000/*!*/;
create database mysqltest2 character set latin2/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=30/*!*/;
create database mysqltest3/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=64/*!*/;
drop database mysqltest3/*!*/;
SET TIMESTAMP=1000000000/*!*/;
create database mysqltest3/*!*/;
use mysqltest2/*!*/;
SET TIMESTAMP=1000000000/*!*/;
create table t1 (a int auto_increment primary key, b varchar(100))/*!*/;
SET INSERT_ID=1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C cp850 *//*!*/;
SET @@session.character_set_client=4,@@session.collation_connection=27,@@session.collation_server=64/*!*/;
insert into t1 (b) values(@@character_set_server)/*!*/;
SET INSERT_ID=2/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(@@collation_server)/*!*/;
SET INSERT_ID=3/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(@@character_set_client)/*!*/;
SET INSERT_ID=4/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(@@character_set_connection)/*!*/;
SET INSERT_ID=5/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(@@collation_connection)/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=5,@@session.collation_server=64/*!*/;
truncate table t1/*!*/;
SET INSERT_ID=1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(@@collation_connection)/*!*/;
SET INSERT_ID=2/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(LEAST("Mller","Muffler"))/*!*/;
SET INSERT_ID=3/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=31,@@session.collation_server=64/*!*/;
insert into t1 (b) values(@@collation_connection)/*!*/;
SET INSERT_ID=4/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(LEAST("Mller","Muffler"))/*!*/;
SET TIMESTAMP=1000000000/*!*/;
truncate table t1/*!*/;
SET INSERT_ID=1/*!*/;
SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 (b) values(collation(@a))/*!*/;
SET TIMESTAMP=1000000000/*!*/;
drop database mysqltest2/*!*/;
SET TIMESTAMP=1000000000/*!*/;
drop database mysqltest3/*!*/;
use test/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=30/*!*/;
CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255))/*!*/;
SET TIMESTAMP=1000000000/*!*/;
/*!\C koi8r *//*!*/;
SET @@session.character_set_client=7,@@session.collation_connection=51,@@session.collation_server=30/*!*/;
INSERT INTO t1 (c1, c2) VALUES (', ',', ')/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
......
......@@ -43,27 +43,29 @@ t
2004-06-11 09:39:02
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=100000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
SET @@session.sql_mode=0;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
create table t1 (t timestamp);
SET TIMESTAMP=100000000;
create table t2 (t char(32));
SET TIMESTAMP=100000000;
SET @@session.time_zone='Europe/Moscow';
insert into t1 values ('20050101000000'), ('20050611093902');
SET TIMESTAMP=100000000;
SET @@session.time_zone='UTC';
insert into t1 values ('20040101000000'), ('20040611093902');
SET TIMESTAMP=100000000;
delete from t1;
SET TIMESTAMP=100000000;
SET @@session.time_zone='Europe/Moscow';
insert into t1 values ('20040101000000'), ('20040611093902');
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
SET TIMESTAMP=100000000/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
create table t1 (t timestamp)/*!*/;
SET TIMESTAMP=100000000/*!*/;
create table t2 (t char(32))/*!*/;
SET TIMESTAMP=100000000/*!*/;
SET @@session.time_zone='Europe/Moscow'/*!*/;
insert into t1 values ('20050101000000'), ('20050611093902')/*!*/;
SET TIMESTAMP=100000000/*!*/;
SET @@session.time_zone='UTC'/*!*/;
insert into t1 values ('20040101000000'), ('20040611093902')/*!*/;
SET TIMESTAMP=100000000/*!*/;
delete from t1/*!*/;
SET TIMESTAMP=100000000/*!*/;
SET @@session.time_zone='Europe/Moscow'/*!*/;
insert into t1 values ('20040101000000'), ('20040611093902')/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
......
......@@ -15,19 +15,21 @@ master-bin.000001 273 User var 1 311 @`var2`=_binary 0x61 COLLATE binary
master-bin.000001 311 Query 1 411 use `test`; insert into t1 values (@var1),(@var2)
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
ROLLBACK;
SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`;
use test;
SET TIMESTAMP=10000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
SET @@session.sql_mode=0;
/*!\C latin1 */;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
INSERT INTO t1 VALUES(@`a b`);
SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`;
SET @`var2`:=_binary 0x61 COLLATE `binary`;
SET TIMESTAMP=10000;
insert into t1 values (@var1),(@var2);
DELIMITER /*!*/;
ROLLBACK/*!*/;
SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
use test/*!*/;
SET TIMESTAMP=10000/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
INSERT INTO t1 VALUES(@`a b`)/*!*/;
SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`/*!*/;
SET @`var2`:=_binary 0x61 COLLATE `binary`/*!*/;
SET TIMESTAMP=10000/*!*/;
insert into t1 values (@var1),(@var2)/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
......
......@@ -290,6 +290,6 @@ eval select
is not null;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval select
@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%",
@a not like "%#%error_code=%error_code=%";
drop table t1, t2;
......@@ -134,6 +134,30 @@ flush logs;
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000006 | $MYSQL
select * from t5 /* must be (1),(1) */;
#
# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
#
--disable_warnings
drop procedure if exists p1;
--enable_warnings
flush logs;
delimiter //;
create procedure p1()
begin
select 1;
end;
//
delimiter ;//
flush logs;
call p1();
drop procedure p1;
--error 1305
call p1();
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000007
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000007 | $MYSQL
call p1();
drop procedure p1;
# clean up
drop table t1, t2, t03, t04, t3, t4, t5;
......
......@@ -1506,15 +1506,16 @@ void Query_log_event::print_query_header(FILE* file,
if (different_db= memcmp(print_event_info->db, db, db_len + 1))
memcpy(print_event_info->db, db, db_len + 1);
if (db[0] && different_db)
fprintf(file, "use %s;\n", db);
fprintf(file, "use %s%s\n", db, print_event_info->delimiter);
}
end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
*end++=';';
end= strmov(end, print_event_info->delimiter);
*end++='\n';
my_fwrite(file, (byte*) buff, (uint) (end-buff),MYF(MY_NABP | MY_WME));
if (flags & LOG_EVENT_THREAD_SPECIFIC_F)
fprintf(file,"SET @@session.pseudo_thread_id=%lu;\n",(ulong)thread_id);
fprintf(file,"SET @@session.pseudo_thread_id=%lu%s\n",
(ulong)thread_id, print_event_info->delimiter);
/*
If flags2_inited==0, this is an event from 3.23 or 4.0; nothing to
......@@ -1543,7 +1544,7 @@ void Query_log_event::print_query_header(FILE* file,
"@@session.sql_auto_is_null", &need_comma);
print_set_option(file, tmp, OPTION_RELAXED_UNIQUE_CHECKS, ~flags2,
"@@session.unique_checks", &need_comma);
fprintf(file,";\n");
fprintf(file,"%s\n", print_event_info->delimiter);
print_event_info->flags2= flags2;
}
}
......@@ -1571,15 +1572,17 @@ void Query_log_event::print_query_header(FILE* file,
}
if (unlikely(print_event_info->sql_mode != sql_mode))
{
fprintf(file,"SET @@session.sql_mode=%lu;\n",(ulong)sql_mode);
fprintf(file,"SET @@session.sql_mode=%lu%s\n",
(ulong)sql_mode, print_event_info->delimiter);
print_event_info->sql_mode= sql_mode;
}
}
if (print_event_info->auto_increment_increment != auto_increment_increment ||
print_event_info->auto_increment_offset != auto_increment_offset)
{
fprintf(file,"SET @@session.auto_increment_increment=%lu, @@session.auto_increment_offset=%lu;\n",
auto_increment_increment,auto_increment_offset);
fprintf(file,"SET @@session.auto_increment_increment=%lu, @@session.auto_increment_offset=%lu%s\n",
auto_increment_increment,auto_increment_offset,
print_event_info->delimiter);
print_event_info->auto_increment_increment= auto_increment_increment;
print_event_info->auto_increment_offset= auto_increment_offset;
}
......@@ -1598,16 +1601,19 @@ void Query_log_event::print_query_header(FILE* file,
CHARSET_INFO *cs_info= get_charset(uint2korr(charset), MYF(MY_WME));
if (cs_info)
{
fprintf(file, "/*!\\C %s */;\n", cs_info->csname); /* for mysql client */
/* for mysql client */
fprintf(file, "/*!\\C %s */%s\n",
cs_info->csname, print_event_info->delimiter);
}
fprintf(file,"SET "
"@@session.character_set_client=%d,"
"@@session.collation_connection=%d,"
"@@session.collation_server=%d"
";\n",
"%s\n",
uint2korr(charset),
uint2korr(charset+2),
uint2korr(charset+4));
uint2korr(charset+4),
print_event_info->delimiter);
memcpy(print_event_info->charset, charset, 6);
}
}
......@@ -1615,7 +1621,8 @@ void Query_log_event::print_query_header(FILE* file,
{
if (bcmp(print_event_info->time_zone_str, time_zone_str, time_zone_len+1))
{
fprintf(file,"SET @@session.time_zone='%s';\n", time_zone_str);
fprintf(file,"SET @@session.time_zone='%s'%s\n",
time_zone_str, print_event_info->delimiter);
memcpy(print_event_info->time_zone_str, time_zone_str, time_zone_len+1);
}
}
......@@ -1626,7 +1633,7 @@ void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
print_query_header(file, print_event_info);
my_fwrite(file, (byte*) query, q_len, MYF(MY_NABP | MY_WME));
fputs(";\n", file);
fprintf(file, "%s\n", print_event_info->delimiter);
}
#endif /* MYSQL_CLIENT */
......@@ -1980,9 +1987,9 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
and rollback unfinished transaction.
Probably this can be done with RESET CONNECTION (syntax to be defined).
*/
fprintf(file,"RESET CONNECTION;\n");
fprintf(file,"RESET CONNECTION%s\n", print_event_info->delimiter);
#else
fprintf(file,"ROLLBACK;\n");
fprintf(file,"ROLLBACK%s\n", print_event_info->delimiter);
#endif
}
fflush(file);
......@@ -2716,13 +2723,14 @@ void Load_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info,
}
if (db && db[0] && different_db)
fprintf(file, "%suse %s;\n",
fprintf(file, "%suse %s%s\n",
commented ? "# " : "",
db);
db, print_event_info->delimiter);
if (flags & LOG_EVENT_THREAD_SPECIFIC_F)
fprintf(file,"%sSET @@session.pseudo_thread_id=%lu;\n",
commented ? "# " : "", (ulong)thread_id);
fprintf(file,"%sSET @@session.pseudo_thread_id=%lu%s\n",
commented ? "# " : "", (ulong)thread_id,
print_event_info->delimiter);
fprintf(file, "%sLOAD DATA ",
commented ? "# " : "");
if (check_fname_outside_temp_buf())
......@@ -2774,7 +2782,7 @@ void Load_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info,
fputc(')', file);
}
fprintf(file, ";\n");
fprintf(file, "%s\n", print_event_info->delimiter);
DBUG_VOID_RETURN;
}
#endif /* MYSQL_CLIENT */
......@@ -3351,7 +3359,8 @@ void Intvar_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
msg="INVALID_INT";
break;
}
fprintf(file, "%s=%s;\n", msg, llstr(val,llbuff));
fprintf(file, "%s=%s%s\n",
msg, llstr(val,llbuff), print_event_info->delimiter);
fflush(file);
}
#endif
......@@ -3426,8 +3435,9 @@ void Rand_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
print_header(file, print_event_info);
fprintf(file, "\tRand\n");
}
fprintf(file, "SET @@RAND_SEED1=%s, @@RAND_SEED2=%s;\n",
llstr(seed1, llbuff),llstr(seed2, llbuff2));
fprintf(file, "SET @@RAND_SEED1=%s, @@RAND_SEED2=%s%s\n",
llstr(seed1, llbuff),llstr(seed2, llbuff2),
print_event_info->delimiter);
fflush(file);
}
#endif /* MYSQL_CLIENT */
......@@ -3499,7 +3509,7 @@ void Xid_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
fprintf(file, "\tXid = %s\n", buf);
fflush(file);
}
fprintf(file, "COMMIT;\n");
fprintf(file, "COMMIT%s\n", print_event_info->delimiter);
}
#endif /* MYSQL_CLIENT */
......@@ -3700,7 +3710,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
if (is_null)
{
fprintf(file, ":=NULL;\n");
fprintf(file, ":=NULL%s\n", print_event_info->delimiter);
}
else
{
......@@ -3708,12 +3718,12 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
case REAL_RESULT:
double real_val;
float8get(real_val, val);
fprintf(file, ":=%.14g;\n", real_val);
fprintf(file, ":=%.14g%s\n", real_val, print_event_info->delimiter);
break;
case INT_RESULT:
char int_buf[22];
longlong10_to_str(uint8korr(val), int_buf, -10);
fprintf(file, ":=%s;\n", int_buf);
fprintf(file, ":=%s%s\n", int_buf, print_event_info->delimiter);
break;
case DECIMAL_RESULT:
{
......@@ -3729,7 +3739,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
bin2decimal(val+2, &dec, precision, scale);
decimal2string(&dec, str_buf, &str_len, 0, 0, 0);
str_buf[str_len]= 0;
fprintf(file, ":=%s;\n",str_buf);
fprintf(file, ":=%s%s\n",str_buf, print_event_info->delimiter);
break;
}
case STRING_RESULT:
......@@ -3765,9 +3775,10 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
Generate an unusable command (=> syntax error) is probably the best
thing we can do here.
*/
fprintf(file, ":=???;\n");
fprintf(file, ":=???%s\n", print_event_info->delimiter);
else
fprintf(file, ":=_%s %s COLLATE `%s`;\n", cs->csname, hex_str, cs->name);
fprintf(file, ":=_%s %s COLLATE `%s`%s\n",
cs->csname, hex_str, cs->name, print_event_info->delimiter);
my_afree(hex_str);
}
break;
......@@ -4866,12 +4877,12 @@ void Execute_load_query_log_event::print(FILE* file,
fprintf(file, " INTO");
my_fwrite(file, (byte*) query + fn_pos_end, q_len-fn_pos_end,
MYF(MY_NABP | MY_WME));
fprintf(file, ";\n");
fprintf(file, "%s\n", print_event_info->delimiter);
}
else
{
my_fwrite(file, (byte*) query, q_len, MYF(MY_NABP | MY_WME));
fprintf(file, ";\n");
fprintf(file, "%s\n", print_event_info->delimiter);
}
if (!print_event_info->short_form)
......
......@@ -519,12 +519,14 @@ typedef struct st_print_event_info
bzero(db, sizeof(db));
bzero(charset, sizeof(charset));
bzero(time_zone_str, sizeof(time_zone_str));
strcpy(delimiter, ";");
}
/* Settings on how to print the events */
bool short_form;
my_off_t hexdump_from;
uint8 common_header_len;
char delimiter[16];
} PRINT_EVENT_INFO;
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment