diff options
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r-- | client/mysqlbinlog.cc | 84 |
1 files changed, 29 insertions, 55 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d7fc64d730a..33f0bf609ed 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -100,8 +100,6 @@ static const char *output_prefix= ""; static char **defaults_argv= 0; static MEM_ROOT glob_root; -static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT; - #ifndef DBUG_OFF static const char *default_dbug_option = "d:t:o,/tmp/mariadb-binlog.trace"; const char *current_dbug_option= default_dbug_option; @@ -1817,6 +1815,11 @@ static void cleanup() my_free_open_file_info(); load_processor.destroy(); mysql_server_end(); + if (opt_flashback) + { + delete_dynamic(&binlog_events); + delete_dynamic(&events_in_stmt); + } DBUG_VOID_RETURN; } @@ -1904,11 +1907,11 @@ static void extend_main_gtid_event_filter(Gtid_event_filter *new_filter) } } -static void die() +static void die(int err) { cleanup(); my_end(MY_DONT_FREE_DBUG); - exit(1); + exit(err); } @@ -1939,7 +1942,7 @@ static my_time_t convert_str_to_timestamp(const char* str) l_time.time_type != MYSQL_TIMESTAMP_DATETIME || status.warnings) { error("Incorrect date and time argument: %s", str); - die(); + die(1); } /* Note that Feb 30th, Apr 31st cause no error messages and are mapped to @@ -2056,13 +2059,11 @@ int parse_gtid_filter_option( } extern "C" my_bool -get_one_option(const struct my_option *opt, const char *argument, const char *filename) +get_one_option(const struct my_option *opt, const char *argument, + const char *filename) { bool tty_password=0; - /* Track when protocol is set via CLI to not force overrides */ - static my_bool ignore_protocol_override = FALSE; - switch (opt->id) { #ifndef DBUG_OFF case '#': @@ -2110,16 +2111,8 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi opt->name)) <= 0) { sf_leaking_memory= 1; /* no memory leak reports here */ - die(); + die(1); } - - /* Specification of protocol via CLI trumps implicit overrides */ - if (filename[0] == '\0') - { - ignore_protocol_override = TRUE; - protocol_to_force = MYSQL_PROTOCOL_DEFAULT; - } - break; #ifdef WHEN_FLASHBACK_REVIEW_READY case opt_flashback_review: @@ -2139,7 +2132,7 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi opt->name)) <= 0) { sf_leaking_memory= 1; /* no memory leak reports here */ - die(); + die(1); } opt_base64_output_mode= (enum_base64_output_mode)(val - 1); break; @@ -2160,35 +2153,17 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi print_row_event_positions_used= 1; break; case 'P': - /* If port and socket are set, fall back to default behavior */ - if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE) - { - ignore_protocol_override = TRUE; - protocol_to_force = MYSQL_PROTOCOL_DEFAULT; - } - - /* If port is set via CLI, try to force protocol to TCP */ - if (filename[0] == '\0' && - !ignore_protocol_override && - protocol_to_force == MYSQL_PROTOCOL_DEFAULT) + if (filename[0] == '\0') { - protocol_to_force = MYSQL_PROTOCOL_TCP; + /* Port given on command line, switch protocol to use TCP */ + opt_protocol= MYSQL_PROTOCOL_TCP; } break; case 'S': - /* If port and socket are set, fall back to default behavior */ - if (protocol_to_force == MYSQL_PROTOCOL_TCP) - { - ignore_protocol_override = TRUE; - protocol_to_force = MYSQL_PROTOCOL_DEFAULT; - } - - /* Prioritize socket if set via command line */ - if (filename[0] == '\0' && - !ignore_protocol_override && - protocol_to_force == MYSQL_PROTOCOL_DEFAULT) + if (filename[0] == '\0') { - protocol_to_force = SOCKET_PROTOCOL_TO_FORCE; + /* Socket given on command line, switch protocol to use SOCKETSt */ + opt_protocol= MYSQL_PROTOCOL_SOCKET; } break; case 'v': @@ -2289,7 +2264,7 @@ static int parse_args(int *argc, char*** argv) if ((ho_error=handle_options(argc, argv, my_options, get_one_option))) { - die(); + die(ho_error); } if (debug_info_flag) my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; @@ -2322,7 +2297,7 @@ static int parse_args(int *argc, char*** argv) quit in error. Note that any specific error messages will have already been written. */ - die(); + die(1); } extend_main_gtid_event_filter(position_gtid_filter); @@ -3256,13 +3231,6 @@ int main(int argc, char** argv) parse_args(&argc, (char***)&argv); - /* Command line options override configured protocol */ - if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT - && protocol_to_force != opt_protocol) - { - warn_protocol_override(host, &opt_protocol, protocol_to_force); - } - if (!argc || opt_version) { if (!opt_version) @@ -3278,6 +3246,12 @@ int main(int argc, char** argv) my_set_max_open_files(open_files_limit); + if (opt_flashback && opt_raw_mode) + { + error("The --raw mode is not allowed with --flashback mode"); + die(1); + } + if (opt_flashback) { my_init_dynamic_array(PSI_NOT_INSTRUMENTED, &binlog_events, @@ -3293,7 +3267,7 @@ int main(int argc, char** argv) if (!remote_opt) { error("The --raw mode only works with --read-from-remote-server"); - die(); + die(1); } if (one_database) warning("The --database option is ignored in raw mode"); @@ -3315,7 +3289,7 @@ int main(int argc, char** argv) O_WRONLY | O_BINARY, MYF(MY_WME)))) { error("Could not create log file '%s'", result_file_name); - die(); + die(1); } } else @@ -3404,7 +3378,7 @@ int main(int argc, char** argv) /* Set delimiter back to semicolon */ if (retval != ERROR_STOP) { - if (!stop_event_string.is_empty()) + if (!stop_event_string.is_empty() && result_file) fprintf(result_file, "%s", stop_event_string.ptr()); if (!opt_raw_mode && opt_flashback) fprintf(result_file, "DELIMITER ;\n"); |