diff options
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r-- | client/mysqlbinlog.cc | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 1d519294042..38e430f9f7b 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -50,6 +50,7 @@ Rpl_filter *binlog_filter; #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) + char server_version[SERVER_VERSION_LENGTH]; ulong server_id = 0; @@ -87,6 +88,9 @@ static const char* host = 0; static int port= 0; static uint my_end_arg; static const char* sock= 0; +#ifdef HAVE_SMEM +static char *shared_memory_base_name= 0; +#endif static const char* user = 0; static char* pass = 0; static char *charset= 0; @@ -773,7 +777,10 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, case QUERY_EVENT: { Query_log_event *qe= (Query_log_event*)ev; - if (shall_skip_database(qe->db)) + if (strncmp(qe->query, "BEGIN", 5) && + strncmp(qe->query, "COMMIT", 6) && + strncmp(qe->query, "ROLLBACK", 8) && + shall_skip_database(qe->db)) goto end; print_use_stmt(print_event_info, qe->db, qe->db_len); if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS) @@ -1048,13 +1055,13 @@ static struct my_option my_long_options[] = /* 'unspec' is not mentioned because it is just a placeholder. */ "Determine when the output statements should be base64-encoded BINLOG " "statements: 'never' disables it and works only for binlogs without " - "row-based events; 'auto' is the default and prints base64 only when " - "necessary (i.e., for row-based events and format description events); " - "'decode-rows' suppresses BINLOG statements for row events, but does " - "not exit as an error if a row event is found, unlike 'never'; " - "'always' prints base64 whenever possible. 'always' is for debugging " - "only and should not be used in a production system. The default is " - "'auto'. --base64-output is a short form for --base64-output=always." + "row-based events; 'decode-rows' decodes row events into commented SQL " + "statements if the --verbose option is also given; 'auto' prints base64 " + "only when necessary (i.e., for row-based events and format description " + "events); 'always' prints base64 whenever possible. 'always' is for " + "debugging only and should not be used in a production system. If this " + "argument is not given, the default is 'auto'; if it is given with no " + "argument, 'always' is used." ,(uchar**) &opt_base64_output_mode_str, (uchar**) &opt_base64_output_mode_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -1113,7 +1120,7 @@ static struct my_option my_long_options[] = "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"position", 'j', "Deprecated. Use --start-position instead.", + {"position", OPT_POSITION, "Deprecated. Use --start-position instead.", (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, /* COM_BINLOG_DUMP accepts only 4 bytes for the position */ @@ -1133,6 +1140,12 @@ static struct my_option my_long_options[] = {"set-charset", OPT_SET_CHARSET, "Add 'SET NAMES character_set' to the output.", (uchar**) &charset, (uchar**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#ifdef HAVE_SMEM + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, + (uchar**) &shared_memory_base_name, + 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#endif {"short-form", 's', "Just show regular queries: no extra info and no " "row-based events. This is for testing only, and should not be used in " "production systems. If you want to suppress base64-output, consider " @@ -1150,7 +1163,7 @@ static struct my_option my_long_options[] = "(you should probably use quotes for your shell to set it properly).", (uchar**) &start_datetime_str, (uchar**) &start_datetime_str, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"start-position", OPT_START_POSITION, + {"start-position", 'j', "Start reading the binlog at position N. Applies to the first binlog " "passed on the command line.", (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL, @@ -1365,6 +1378,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'R': remote_opt= 1; break; + case OPT_POSITION: + WARN_DEPRECATED(VER_CELOSIA, "--position", "--start-position"); + break; case OPT_MYSQL_PROTOCOL: opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, opt->name); @@ -1476,6 +1492,10 @@ static int parse_args(int *argc, char*** argv) */ static Exit_status safe_connect() { + /* Close and old connections to MySQL */ + if (mysql) + mysql_close(mysql); + mysql= mysql_init(NULL); if (!mysql) @@ -1486,6 +1506,11 @@ static Exit_status safe_connect() if (opt_protocol) mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); +#ifdef HAVE_SMEM + if (shared_memory_base_name) + mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME, + shared_memory_base_name); +#endif if (!mysql_real_connect(mysql, host, user, pass, 0, port, sock, 0)) { error("Failed on connect: %s", mysql_error(mysql)); |