summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <lars/lthalmann@dl145j.mysql.com>2007-01-12 12:31:44 +0100
committerunknown <lars/lthalmann@dl145j.mysql.com>2007-01-12 12:31:44 +0100
commitbb484726010c9e448ed2ee9e9731150b22c15d8f (patch)
tree8f05ed2f7b6984f4ca7df8e1eafad42a9d4235e2 /client
parent84e8991666227a538f38d99548ab27f21a38fbf2 (diff)
parentff9c35006fd887fba6ad921e5ec4f7bdbb364248 (diff)
downloadmariadb-git-bb484726010c9e448ed2ee9e9731150b22c15d8f.tar.gz
Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl
into mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge client/mysqlbinlog.cc: Auto merged client/mysqldump.c: Auto merged configure.in: Auto merged include/config-win.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged libmysqld/CMakeLists.txt: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/rpl_row_tabledefs_2myisam.result: Auto merged mysql-test/r/rpl_row_tabledefs_3innodb.result: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/t/disabled.def: Auto merged mysys/my_thr_init.c: Auto merged sql/CMakeLists.txt: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/handler.cc: Auto merged sql/item_create.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/log.cc: Auto merged sql/log.h: Auto merged sql/log_event.h: Auto merged sql/mysql_priv.h: Auto merged sql/rpl_injector.cc: Auto merged sql/rpl_injector.h: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_locale.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.cc: Auto merged unittest/mysys/my_atomic-t.c: Auto merged sql/log_event.cc: Manual merge main->rpl sql/mysqld.cc: Manual merge main->rpl
Diffstat (limited to 'client')
-rw-r--r--client/mysqlbinlog.cc59
1 files changed, 48 insertions, 11 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index a95f3d3b836..8242a481c5b 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -66,6 +66,7 @@ static bool opt_hexdump= 0;
static bool opt_base64_output= 0;
static const char* database= 0;
static my_bool force_opt= 0, short_form= 0, remote_opt= 0, info_flag;
+static my_bool force_if_open_opt= 1;
static ulonglong offset = 0;
static const char* host = 0;
static int port= 0;
@@ -85,6 +86,7 @@ static short binlog_flags = 0;
static MYSQL* mysql = NULL;
static const char* dirname_for_local_load= 0;
static bool stop_passed= 0;
+static my_bool file_not_closed_error= 0;
/*
check_header() will set the pointer below.
@@ -94,8 +96,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, ...);
@@ -645,6 +649,12 @@ Create_file event for file_id: %u\n",exv->file_id);
later.
*/
ev= 0;
+ if (!force_if_open_opt &&
+ (description_event->flags & LOG_EVENT_BINLOG_IN_USE_F))
+ {
+ file_not_closed_error= 1;
+ DBUG_RETURN(1);
+ }
break;
case BEGIN_LOAD_QUERY_EVENT:
ev->print(result_file, print_event_info);
@@ -724,6 +734,9 @@ static struct my_option my_long_options[] =
"already have. NOTE: you will need a SUPER privilege to use this option.",
(gptr*) &disable_log_bin, (gptr*) &disable_log_bin, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"force-if-open", 'F', "Force if binlog was not closed properly.",
+ (gptr*) &force_if_open_opt, (gptr*) &force_if_open_opt, 0, GET_BOOL, NO_ARG,
+ 1, 0, 0, 0, 0, 0},
{"force-read", 'f', "Force reading unknown binlog events.",
(gptr*) &force_opt, (gptr*) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
@@ -1001,8 +1014,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;
}
@@ -1067,11 +1094,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;
@@ -1194,7 +1221,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;
@@ -1213,7 +1240,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);
@@ -1339,11 +1366,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;
@@ -1430,7 +1457,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;
@@ -1547,6 +1574,16 @@ int main(int argc, char** argv)
my_free_open_file_info();
/* We cannot free DBUG, it is used in global destructors after exit(). */
my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG);
+
+ if (file_not_closed_error)
+ {
+ fprintf(stderr,
+"\nError: attempting to dump binlog '%s' which was not closed properly.\n"
+"Most probably mysqld is still writting it, or crashed.\n"
+"Your current options specify --disable-force-if-open\n"
+"which means to abort on this problem.\n"
+"You can rerun using --force-if-open to ignore this problem.\n\n", argv[-1]);
+ }
exit(exit_value);
DBUG_RETURN(exit_value); // Keep compilers happy
}