summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h2
-rw-r--r--client/mysql.cc14
-rw-r--r--client/mysql_upgrade.c14
-rw-r--r--client/mysqladmin.cc5
-rw-r--r--client/mysqlbinlog.cc560
-rw-r--r--client/mysqlcheck.c5
-rw-r--r--client/mysqldump.c158
-rw-r--r--client/mysqltest.cc157
-rw-r--r--client/readline.cc3
9 files changed, 559 insertions, 359 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index 3905f323156..c0c4954cdf0 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -93,8 +93,6 @@ enum options_client
OPT_REPORT_PROGRESS,
OPT_SKIP_ANNOTATE_ROWS_EVENTS,
OPT_SSL_CRL, OPT_SSL_CRLPATH,
- OPT_USE_GTID,
- OPT_GALERA_SST_MODE,
OPT_MAX_CLIENT_OPTION /* should be always the last */
};
diff --git a/client/mysql.cc b/client/mysql.cc
index 4b20e4d98cb..136713e3a1b 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -597,8 +597,6 @@ static COMMANDS commands[] = {
{ "NAMES", 0, 0, 0, ""},
{ "NATIONAL", 0, 0, 0, ""},
{ "NATURAL", 0, 0, 0, ""},
- { "NDB", 0, 0, 0, ""},
- { "NDBCLUSTER", 0, 0, 0, ""},
{ "NCHAR", 0, 0, 0, ""},
{ "NEW", 0, 0, 0, ""},
{ "NEXT", 0, 0, 0, ""},
@@ -3083,9 +3081,7 @@ static int com_server_help(String *buffer __attribute__((unused)),
init_pager();
char last_char= 0;
- int num_name= 0, num_cat= 0;
- LINT_INIT(num_name);
- LINT_INIT(num_cat);
+ int UNINIT_VAR(num_name), UNINIT_VAR(num_cat);
if (num_fields == 2)
{
@@ -3222,7 +3218,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
}
/* Remove garbage for nicer messages */
- LINT_INIT(buff[0]);
+ LINT_INIT_STRUCT(buff[0]);
remove_cntrl(*buffer);
if (buffer->is_empty())
@@ -4715,8 +4711,7 @@ com_status(String *buffer __attribute__((unused)),
const char *status_str;
char buff[40];
ulonglong id;
- MYSQL_RES *result;
- LINT_INIT(result);
+ MYSQL_RES *UNINIT_VAR(result);
if (mysql_real_query_for_lazy(
C_STRING_WITH_LEN("select DATABASE(), USER() limit 1")))
@@ -5276,8 +5271,7 @@ static void init_username()
my_free(full_username);
my_free(part_username);
- MYSQL_RES *result;
- LINT_INIT(result);
+ MYSQL_RES *UNINIT_VAR(result);
if (!mysql_query(&mysql,"select USER()") &&
(result=mysql_use_result(&mysql)))
{
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 737f9c9c8d7..e400087a2e8 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -536,7 +536,21 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
int ret;
File fd;
char query_file_path[FN_REFLEN];
+#ifdef WITH_WSREP
+ /*
+ Strictly speaking, WITH_WSREP on the client only means that the
+ client was compiled with WSREP, it doesn't mean the server was,
+ so the server might not have WSREP_ON variable.
+
+ But mysql_upgrade is tightly bound to a specific server version
+ anyway - it was mysql_fix_privilege_tables_sql script embedded
+ into its binary - so even if it won't assume anything about server
+ wsrep-ness, it won't be any less server-dependend.
+ */
+ const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0, WSREP_ON=OFF;";
+#else
const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;";
+#endif /* WITH_WSREP */
DBUG_ENTER("run_query");
DBUG_PRINT("enter", ("query: %s", query));
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 7f32658f1b2..9642903ae79 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -698,10 +698,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
if (mysql_refresh(mysql,
(uint) ~(REFRESH_GRANT | REFRESH_STATUS |
REFRESH_READ_LOCK | REFRESH_SLAVE |
- REFRESH_MASTER | REFRESH_TABLE_STATS |
- REFRESH_INDEX_STATS |
- REFRESH_USER_STATS |
- REFRESH_CLIENT_STATS)))
+ REFRESH_MASTER)))
{
my_printf_error(0, "refresh failed; error: '%s'", error_flags,
mysql_error(mysql));
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 4be31421f9b..e27a4a8e4e3 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -74,6 +74,8 @@ ulong opt_binlog_rows_event_max_size;
uint test_flags = 0;
static uint opt_protocol= 0;
static FILE *result_file;
+static char *result_file_name= 0;
+static const char *output_prefix= "";
#ifndef DBUG_OFF
static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
@@ -97,6 +99,8 @@ static char* database= 0;
static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
static my_bool debug_info_flag, debug_check_flag;
static my_bool force_if_open_opt= 1;
+static my_bool opt_raw_mode= 0, opt_stop_never= 0;
+static ulong opt_stop_never_slave_server_id= 0;
static my_bool opt_verify_binlog_checksum= 1;
static ulonglong offset = 0;
static char* host = 0;
@@ -121,7 +125,6 @@ static ulonglong start_position, stop_position;
static char *start_datetime_str, *stop_datetime_str;
static my_time_t start_datetime= 0, stop_datetime= MY_TIME_T_MAX;
static ulonglong rec_count= 0;
-static short binlog_flags = 0;
static MYSQL* mysql = NULL;
static const char* dirname_for_local_load= 0;
static bool opt_skip_annotate_row_events= 0;
@@ -143,7 +146,9 @@ enum Exit_status {
/** An error occurred and execution should stop. */
ERROR_STOP,
/** No error occurred but execution should stop. */
- OK_STOP
+ OK_STOP,
+ /** No error occurred - end of file reached. */
+ OK_EOF,
};
/**
@@ -1252,6 +1257,9 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
goto err;
break;
}
+ case START_ENCRYPTION_EVENT:
+ glob_description_event->start_decryption((Start_encryption_log_event*)ev);
+ /* fall through */
default:
print_skip_replication_statement(print_event_info, ev);
ev->print(result_file, print_event_info);
@@ -1369,8 +1377,14 @@ static struct my_option my_options[] =
{"read-from-remote-server", 'R', "Read binary logs from a MySQL server.",
&remote_opt, &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
- {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"raw", 0, "Requires -R. Output raw binlog data instead of SQL "
+ "statements. Output files named after server logs.",
+ &opt_raw_mode, &opt_raw_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
+ 0, 0},
+ {"result-file", 'r', "Direct output to a given file. With --raw this is a "
+ "prefix for the file names.",
+ &result_file_name, &result_file_name, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
{"server-id", 0,
"Extract only binlog entries created by the server having the given id.",
&server_id, &server_id, 0, GET_ULONG,
@@ -1407,8 +1421,11 @@ static struct my_option my_options[] =
"passed on the command line.",
&start_position, &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 */
- (ulonglong)(~(uint32)0), 0, 0, 0},
+ /*
+ COM_BINLOG_DUMP accepts only 4 bytes for the position
+ so remote log reading has lower limit.
+ */
+ (ulonglong)(0xffffffffffffffffULL), 0, 0, 0},
{"stop-datetime", OPT_STOP_DATETIME,
"Stop reading the binlog at first event having a datetime equal or "
"posterior to the argument; the argument must be a date and time "
@@ -1417,6 +1434,14 @@ static struct my_option my_options[] =
"(you should probably use quotes for your shell to set it properly).",
&stop_datetime_str, &stop_datetime_str,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"stop-never", 0, "Wait for more data from the server "
+ "instead of stopping at the end of the last log. Implies --to-last-log.",
+ &opt_stop_never, &opt_stop_never, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"stop-never-slave-server-id", 0,
+ "The slave server_id used for --read-from-remote-server --stop-never.",
+ &opt_stop_never_slave_server_id, &opt_stop_never_slave_server_id, 0,
+ GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"stop-position", OPT_STOP_POSITION,
"Stop reading the binlog at position N. Applies to the last binlog "
"passed on the command line.",
@@ -1620,10 +1645,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else
tty_password=1;
break;
- case 'r':
- if (!(result_file = my_fopen(argument, O_WRONLY | O_BINARY, MYF(MY_WME))))
- exit(1);
- break;
case 'R':
remote_opt= 1;
break;
@@ -1719,13 +1740,20 @@ static int parse_args(int *argc, char*** argv)
{
int ho_error;
- result_file = stdout;
if ((ho_error=handle_options(argc, argv, my_options, get_one_option)))
exit(ho_error);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
else if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
+ if (start_position > UINT_MAX32 && remote_opt)
+ {
+ /* Here we just emulate old behaviour of option limit handling */
+ fprintf(stderr, "Warning: option 'start-position': unsigned value %llu "
+ "adjusted to 4294967295 (limitation of the client-server protocol)",
+ start_position);
+ start_position= UINT_MAX32;
+ }
return 0;
}
@@ -1813,7 +1841,8 @@ static Exit_status dump_log_entries(const char* logname)
Set safe delimiter, to dump things
like CREATE PROCEDURE safely
*/
- fprintf(result_file, "DELIMITER /*!*/;\n");
+ if (!opt_raw_mode)
+ fprintf(result_file, "DELIMITER /*!*/;\n");
strmov(print_event_info.delimiter, "/*!*/;");
print_event_info.verbose= short_form ? 0 : verbose;
@@ -1822,7 +1851,8 @@ static Exit_status dump_log_entries(const char* logname)
dump_local_log_entries(&print_event_info, logname));
/* Set delimiter back to semicolon */
- fprintf(result_file, "DELIMITER ;\n");
+ if (!opt_raw_mode)
+ fprintf(result_file, "DELIMITER ;\n");
strmov(print_event_info.delimiter, ";");
return rc;
}
@@ -1928,6 +1958,247 @@ err:
}
+static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info,
+ ulong *len,
+ const char* logname,
+ uint logname_len, my_off_t old_off)
+{
+ const char *error_msg;
+ Log_event *ev;
+ NET *net= &mysql->net;
+ DBUG_ENTER("handle_event_text_mode");
+
+ if (net->read_pos[5] == ANNOTATE_ROWS_EVENT)
+ {
+ if (!(ev= read_remote_annotate_event(net->read_pos + 1, *len - 1,
+ &error_msg)))
+ {
+ error("Could not construct annotate event object: %s", error_msg);
+ DBUG_RETURN(ERROR_STOP);
+ }
+ }
+ else
+ {
+ if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
+ *len - 1, &error_msg,
+ glob_description_event,
+ opt_verify_binlog_checksum)))
+ {
+ error("Could not construct log event object: %s", error_msg);
+ DBUG_RETURN(ERROR_STOP);
+ }
+ /*
+ If reading from a remote host, ensure the temp_buf for the
+ Log_event class is pointing to the incoming stream.
+ */
+ ev->register_temp_buf((char *) net->read_pos + 1, FALSE);
+ }
+
+ Log_event_type type= ev->get_type_code();
+ if (glob_description_event->binlog_version >= 3 ||
+ (type != LOAD_EVENT && type != CREATE_FILE_EVENT))
+ {
+ /*
+ If this is a Rotate event, maybe it's the end of the requested binlog;
+ in this case we are done (stop transfer).
+ This is suitable for binlogs, not relay logs (but for now we don't read
+ relay logs remotely because the server is not able to do that). If one
+ day we read relay logs remotely, then we will have a problem with the
+ detection below: relay logs contain Rotate events which are about the
+ binlogs, so which would trigger the end-detection below.
+ */
+ if (type == ROTATE_EVENT)
+ {
+ Rotate_log_event *rev= (Rotate_log_event *)ev;
+ /*
+ If this is a fake Rotate event, and not about our log, we can stop
+ transfer. If this a real Rotate event (so it's not about our log,
+ it's in our log describing the next log), we print it (because it's
+ part of our log) and then we will stop when we receive the fake one
+ soon.
+ */
+ if (rev->when == 0)
+ {
+ *len= 1; // fake Rotate, so don't increment old_off
+ if (!to_last_remote_log)
+ {
+ if ((rev->ident_len != logname_len) ||
+ memcmp(rev->new_log_ident, logname, logname_len))
+ {
+ delete ev;
+ DBUG_RETURN(OK_EOF);
+ }
+ /*
+ Otherwise, this is a fake Rotate for our log, at the very
+ beginning for sure. Skip it, because it was not in the original
+ log. If we are running with to_last_remote_log, we print it,
+ because it serves as a useful marker between binlogs then.
+ */
+ delete ev;
+ DBUG_RETURN(OK_CONTINUE);
+ }
+ }
+ }
+ else if (type == FORMAT_DESCRIPTION_EVENT)
+ {
+ /*
+ This could be an fake Format_description_log_event that server
+ (5.0+) automatically sends to a slave on connect, before sending
+ a first event at the requested position. If this is the case,
+ don't increment old_off. Real Format_description_log_event always
+ starts from BIN_LOG_HEADER_SIZE position.
+ */
+ if (old_off != BIN_LOG_HEADER_SIZE)
+ *len= 1; // fake event, don't increment old_off
+ }
+ Exit_status retval= process_event(print_event_info, ev, old_off, logname);
+ if (retval != OK_CONTINUE)
+ DBUG_RETURN(retval);
+ }
+ else
+ {
+ Load_log_event *le= (Load_log_event*)ev;
+ const char *old_fname= le->fname;
+ uint old_len= le->fname_len;
+ File file;
+ Exit_status retval;
+ char fname[FN_REFLEN+1];
+
+ if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0)
+ {
+ DBUG_RETURN(ERROR_STOP);
+ }
+
+ retval= process_event(print_event_info, ev, old_off, logname);
+ if (retval != OK_CONTINUE)
+ {
+ my_close(file,MYF(MY_WME));
+ DBUG_RETURN(retval);
+ }
+ retval= load_processor.load_old_format_file(net,old_fname,old_len,file);
+ my_close(file,MYF(MY_WME));
+ if (retval != OK_CONTINUE)
+ DBUG_RETURN(retval);
+ }
+
+ DBUG_RETURN(OK_CONTINUE);
+}
+
+
+static char out_file_name[FN_REFLEN + 1];
+
+static Exit_status handle_event_raw_mode(PRINT_EVENT_INFO *print_event_info,
+ ulong *len,
+ const char* logname, uint logname_len)
+{
+ const char *error_msg;
+ const unsigned char *read_pos= mysql->net.read_pos + 1;
+ Log_event_type type;
+ DBUG_ENTER("handle_event_raw_mode");
+ DBUG_ASSERT(opt_raw_mode && remote_opt);
+
+ type= (Log_event_type) read_pos[EVENT_TYPE_OFFSET];
+
+ if (type == HEARTBEAT_LOG_EVENT)
+ DBUG_RETURN(OK_CONTINUE);
+
+ if (type == ROTATE_EVENT || type == FORMAT_DESCRIPTION_EVENT)
+ {
+ Log_event *ev;
+ if (!(ev= Log_event::read_log_event((const char*) read_pos ,
+ *len - 1, &error_msg,
+ glob_description_event,
+ opt_verify_binlog_checksum)))
+ {
+ error("Could not construct %s event object: %s",
+ type == ROTATE_EVENT ? "rotate" : "format description", error_msg);
+ DBUG_RETURN(ERROR_STOP);
+ }
+ /*
+ If reading from a remote host, ensure the temp_buf for the
+ Log_event class is pointing to the incoming stream.
+ */
+ ev->register_temp_buf((char *) read_pos, FALSE);
+
+ if (type == ROTATE_EVENT)
+ {
+ Exit_status ret_val= OK_CONTINUE;
+ Rotate_log_event *rev= (Rotate_log_event *)ev;
+ char *pe= strmake(out_file_name, output_prefix, sizeof(out_file_name)-1);
+ strmake(pe, rev->new_log_ident, sizeof(out_file_name) - (pe-out_file_name));
+
+ /*
+ If this is a fake Rotate event, and not about our log, we can stop
+ transfer. If this a real Rotate event (so it's not about our log,
+ it's in our log describing the next log), we print it (because it's
+ part of our log) and then we will stop when we receive the fake one
+ soon.
+ */
+ if (rev->when == 0)
+ {
+ if (!to_last_remote_log)
+ {
+ if ((rev->ident_len != logname_len) ||
+ memcmp(rev->new_log_ident, logname, logname_len))
+ {
+ ret_val= OK_EOF;
+ }
+ /*
+ Otherwise, this is a fake Rotate for our log, at the very
+ beginning for sure. Skip it, because it was not in the original
+ log. If we are running with to_last_remote_log, we print it,
+ because it serves as a useful marker between binlogs then.
+ */
+ }
+ *len= 1; // fake Rotate, so don't increment old_off
+ ev->temp_buf= 0;
+ delete ev;
+ DBUG_RETURN(ret_val);
+ }
+ ev->temp_buf= 0;
+ delete ev;
+ }
+ else /* if (type == FORMAT_DESCRIPTION_EVENT) */
+ {
+ DBUG_ASSERT(type == FORMAT_DESCRIPTION_EVENT);
+
+ if (result_file)
+ my_fclose(result_file, MYF(0));
+
+ if (!(result_file= my_fopen(out_file_name,
+ O_WRONLY | O_BINARY, MYF(MY_WME))))
+ {
+ error("Could not create output log file: %s", out_file_name);
+ DBUG_RETURN(ERROR_STOP);
+ }
+ /* TODO - add write error simulation here */
+
+ if (my_fwrite(result_file, (const uchar *) BINLOG_MAGIC,
+ BIN_LOG_HEADER_SIZE, MYF(MY_NABP)))
+ {
+ error("Could not write into log file '%s'", out_file_name);
+ DBUG_RETURN(ERROR_STOP);
+ }
+
+ delete glob_description_event;
+ glob_description_event= (Format_description_log_event*) ev;
+ print_event_info->common_header_len=
+ glob_description_event->common_header_len;
+ ev->temp_buf= 0;
+ /* We do not want to delete the event here. */
+ }
+ }
+
+ if (my_fwrite(result_file, read_pos, *len - 1, MYF(MY_NABP)))
+ {
+ error("Could not write into log file '%s'", out_file_name);
+ DBUG_RETURN(ERROR_STOP);
+ }
+
+ DBUG_RETURN(OK_CONTINUE);
+}
+
+
/**
Requests binlog dump from a remote server and prints the events it
receives.
@@ -1950,8 +2221,9 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
uint logname_len;
NET* net;
my_off_t old_off= start_position_mot;
- char fname[FN_REFLEN+1];
Exit_status retval= OK_CONTINUE;
+ short binlog_flags = 0;
+ ulong slave_id;
DBUG_ENTER("dump_remote_log_entries");
/*
@@ -1970,9 +2242,13 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
COM_BINLOG_DUMP accepts only 4 bytes for the position, so we are forced to
cast to uint32.
*/
+ DBUG_ASSERT(start_position <= UINT_MAX32);
int4store(buf, (uint32)start_position);
if (!opt_skip_annotate_row_events)
binlog_flags|= BINLOG_SEND_ANNOTATE_ROWS_EVENT;
+ if (!opt_stop_never)
+ binlog_flags|= BINLOG_DUMP_NON_BLOCK;
+
int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);
size_t tlen = strlen(logname);
@@ -1982,7 +2258,15 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
DBUG_RETURN(ERROR_STOP);
}
logname_len = (uint) tlen;
- int4store(buf + 6, 0);
+ if (opt_stop_never)
+ {
+ DBUG_ASSERT(to_last_remote_log);
+ slave_id= (opt_stop_never_slave_server_id == 0) ?
+ 1 : opt_stop_never_slave_server_id;
+ }
+ else
+ slave_id= 0;
+ int4store(buf + 6, slave_id);
memcpy(buf + 10, logname, logname_len);
if (simple_command(mysql, COM_BINLOG_DUMP, buf, logname_len + 10, 1))
{
@@ -1992,9 +2276,6 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
for (;;)
{
- const char *error_msg;
- Log_event *ev;
-
len= cli_safe_read(mysql);
if (len == packet_error)
{
@@ -2005,117 +2286,23 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
break; // end of data
DBUG_PRINT("info",( "len: %lu net->read_pos[5]: %d\n",
len, net->read_pos[5]));
- if (net->read_pos[5] == ANNOTATE_ROWS_EVENT)
+ if (opt_raw_mode)
{
- if (!(ev= read_remote_annotate_event(net->read_pos + 1, len - 1,
- &error_msg)))
- {
- error("Could not construct annotate event object: %s", error_msg);
- DBUG_RETURN(ERROR_STOP);
- }
+ retval= handle_event_raw_mode(print_event_info, &len,
+ logname, logname_len);
}
else
{
- if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
- len - 1, &error_msg,
- glob_description_event,
- opt_verify_binlog_checksum)))
- {
- error("Could not construct log event object: %s", error_msg);
- DBUG_RETURN(ERROR_STOP);
- }
- /*
- If reading from a remote host, ensure the temp_buf for the
- Log_event class is pointing to the incoming stream.
- */
- ev->register_temp_buf((char *) net->read_pos + 1, FALSE);
+ retval= handle_event_text_mode(print_event_info, &len,
+ logname, logname_len, old_off);
}
-
- Log_event_type type= ev->get_type_code();
- if (glob_description_event->binlog_version >= 3 ||
- (type != LOAD_EVENT && type != CREATE_FILE_EVENT))
+ if (retval != OK_CONTINUE)
{
- /*
- If this is a Rotate event, maybe it's the end of the requested binlog;
- in this case we are done (stop transfer).
- This is suitable for binlogs, not relay logs (but for now we don't read
- relay logs remotely because the server is not able to do that). If one
- day we read relay logs remotely, then we will have a problem with the
- detection below: relay logs contain Rotate events which are about the
- binlogs, so which would trigger the end-detection below.
- */
- if (type == ROTATE_EVENT)
- {
- Rotate_log_event *rev= (Rotate_log_event *)ev;
- /*
- If this is a fake Rotate event, and not about our log, we can stop
- transfer. If this a real Rotate event (so it's not about our log,
- it's in our log describing the next log), we print it (because it's
- part of our log) and then we will stop when we receive the fake one
- soon.
- */
- if (rev->when == 0)
- {
- if (!to_last_remote_log)
- {
- if ((rev->ident_len != logname_len) ||
- memcmp(rev->new_log_ident, logname, logname_len))
- {
- delete ev;
- DBUG_RETURN(OK_CONTINUE);
- }
- /*
- Otherwise, this is a fake Rotate for our log, at the very
- beginning for sure. Skip it, because it was not in the original
- log. If we are running with to_last_remote_log, we print it,
- because it serves as a useful marker between binlogs then.
- */
- delete ev;
- continue;
- }
- len= 1; // fake Rotate, so don't increment old_off
- }
- }
- else if (type == FORMAT_DESCRIPTION_EVENT)
- {
- /*
- This could be an fake Format_description_log_event that server
- (5.0+) automatically sends to a slave on connect, before sending
- a first event at the requested position. If this is the case,
- don't increment old_off. Real Format_description_log_event always
- starts from BIN_LOG_HEADER_SIZE position.
- */
- if (old_off != BIN_LOG_HEADER_SIZE)
- len= 1; // fake event, don't increment old_off
- }
- Exit_status retval= process_event(print_event_info, ev, old_off, logname);
- if (retval != OK_CONTINUE)
- DBUG_RETURN(retval);
+ if (retval == OK_EOF)
+ break;
+ DBUG_RETURN(retval);
}
- else
- {
- Load_log_event *le= (Load_log_event*)ev;
- const char *old_fname= le->fname;
- uint old_len= le->fname_len;
- File file;
- Exit_status retval;
-
- if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0)
- {
- DBUG_RETURN(ERROR_STOP);
- }
- retval= process_event(print_event_info, ev, old_off, logname);
- if (retval != OK_CONTINUE)
- {
- my_close(file,MYF(MY_WME));
- DBUG_RETURN(retval);
- }
- retval= load_processor.load_old_format_file(net,old_fname,old_len,file);
- my_close(file,MYF(MY_WME));
- if (retval != OK_CONTINUE)
- DBUG_RETURN(retval);
- }
/*
Let's adjust offset for remote log as for local log to produce
similar text and to have --stop-position to work identically.
@@ -2261,7 +2448,7 @@ static Exit_status check_header(IO_CACHE* file,
Format_description_log_event *new_description_event;
my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!(new_description_event= (Format_description_log_event*)
- Log_event::read_log_event(file, glob_description_event,
+ Log_event::read_log_event(file, 0, glob_description_event,
opt_verify_binlog_checksum)))
/* EOF can't be hit here normally, so it's a real error */
{
@@ -2295,7 +2482,7 @@ static Exit_status check_header(IO_CACHE* file,
{
Log_event *ev;
my_b_seek(file, tmp_pos); /* seek back to event's start */
- if (!(ev= Log_event::read_log_event(file, glob_description_event,
+ if (!(ev= Log_event::read_log_event(file, 0, glob_description_event,
opt_verify_binlog_checksum)))
{
/* EOF can't be hit here normally, so it's a real error */
@@ -2409,7 +2596,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
char llbuff[21];
my_off_t old_off = my_b_tell(file);
- Log_event* ev = Log_event::read_log_event(file, glob_description_event,
+ Log_event* ev = Log_event::read_log_event(file, 0, glob_description_event,
opt_verify_binlog_checksum);
if (!ev)
{
@@ -2502,6 +2689,43 @@ int main(int argc, char** argv)
my_set_max_open_files(open_files_limit);
+ if (opt_stop_never)
+ to_last_remote_log= TRUE;
+
+ if (opt_raw_mode)
+ {
+ if (!remote_opt)
+ {
+ error("The --raw mode only works with --read-from-remote-server");
+ exit(1);
+ }
+ if (one_database)
+ warning("The --database option is ignored in raw mode");
+
+ if (stop_position != (ulonglong)(~(my_off_t)0))
+ warning("The --stop-position option is ignored in raw mode");
+
+ if (stop_datetime != MY_TIME_T_MAX)
+ warning("The --stop-datetime option is ignored in raw mode");
+ result_file= 0;
+ if (result_file_name)
+ output_prefix= result_file_name;
+ }
+ else
+ {
+ if (result_file_name)
+ {
+ if (!(result_file= my_fopen(result_file_name,
+ O_WRONLY | O_BINARY, MYF(MY_WME))))
+ {
+ error("Could not create log file '%s'", result_file_name);
+ exit(1);
+ }
+ }
+ else
+ result_file= stdout;
+ }
+
MY_TMPDIR tmpdir;
tmpdir.list= 0;
if (!dirname_for_local_load)
@@ -2524,29 +2748,32 @@ int main(int argc, char** argv)
else
load_processor.init_by_cur_dir();
- fprintf(result_file, "/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;\n");
-
- fprintf(result_file,
- "/*!40019 SET @@session.max_insert_delayed_threads=0*/;\n");
+ if (!opt_raw_mode)
+ {
+ fprintf(result_file, "/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;\n");
- if (disable_log_bin)
fprintf(result_file,
- "/*!32316 SET @OLD_SQL_LOG_BIN=@@SQL_LOG_BIN, SQL_LOG_BIN=0*/;\n");
+ "/*!40019 SET @@session.max_insert_delayed_threads=0*/;\n");
- /*
- In mysqlbinlog|mysql, don't want mysql to be disconnected after each
- transaction (which would be the case with GLOBAL.COMPLETION_TYPE==2).
- */
- fprintf(result_file,
- "/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,"
- "COMPLETION_TYPE=0*/;\n");
+ if (disable_log_bin)
+ fprintf(result_file,
+ "/*!32316 SET @OLD_SQL_LOG_BIN=@@SQL_LOG_BIN, SQL_LOG_BIN=0*/;\n");
- if (charset)
+ /*
+ In mysqlbinlog|mysql, don't want mysql to be disconnected after each
+ transaction (which would be the case with GLOBAL.COMPLETION_TYPE==2).
+ */
fprintf(result_file,
- "\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
- "\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"
- "\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"
- "\n/*!40101 SET NAMES %s */;\n", charset);
+ "/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,"
+ "COMPLETION_TYPE=0*/;\n");
+
+ if (charset)
+ fprintf(result_file,
+ "\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
+ "\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"
+ "\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"
+ "\n/*!40101 SET NAMES %s */;\n", charset);
+ }
for (save_stop_position= stop_position, stop_position= ~(my_off_t)0 ;
(--argc >= 0) ; )
@@ -2560,27 +2787,30 @@ int main(int argc, char** argv)
start_position= BIN_LOG_HEADER_SIZE;
}
- /*
- Issue a ROLLBACK in case the last printed binlog was crashed and had half
- of transaction.
- */
- fprintf(result_file,
- "# End of log file\nROLLBACK /* added by mysqlbinlog */;\n"
- "/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;\n");
- if (disable_log_bin)
- fprintf(result_file, "/*!32316 SET SQL_LOG_BIN=@OLD_SQL_LOG_BIN*/;\n");
-
- if (charset)
+ if (!opt_raw_mode)
+ {
+ /*
+ Issue a ROLLBACK in case the last printed binlog was crashed and had half
+ of transaction.
+ */
fprintf(result_file,
- "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n"
- "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n"
- "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
-
- fprintf(result_file, "/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;\n");
+ "# End of log file\nROLLBACK /* added by mysqlbinlog */;\n"
+ "/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;\n");
+ if (disable_log_bin)
+ fprintf(result_file, "/*!32316 SET SQL_LOG_BIN=@OLD_SQL_LOG_BIN*/;\n");
+
+ if (charset)
+ fprintf(result_file,
+ "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n"
+ "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n"
+ "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
+
+ fprintf(result_file, "/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;\n");
+ }
if (tmpdir.list)
free_tmpdir(&tmpdir);
- if (result_file != stdout)
+ if (result_file && result_file != stdout)
my_fclose(result_file, MYF(0));
cleanup();
free_annotate_event();
@@ -2610,6 +2840,18 @@ void *sql_alloc(size_t size)
return alloc_root(&s_mem_root, size);
}
+uint dummy1() { return 1; }
+struct encryption_service_st encryption_handler=
+{
+ (uint(*)(uint))dummy1,
+ (uint(*)(uint, uint, uchar*, uint*))dummy1,
+ (uint(*)(uint, uint))dummy1,
+ (int (*)(void*, const uchar*, uint, const uchar*, uint, int, uint, uint))dummy1,
+ (int (*)(void*, const uchar*, uint, uchar*, uint*))dummy1,
+ (int (*)(void*, uchar*, uint*))dummy1,
+ (uint (*)(uint, uint, uint))dummy1
+};
+
/*
We must include this here as it's compiled with different options for
the server
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 0c34ef35966..3a6f5462ced 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -857,10 +857,11 @@ static int use_db(char *database)
DBUG_RETURN(0);
} /* use_db */
+/* Do not send commands to replication slaves. */
static int disable_binlog()
{
- const char *stmt= "SET SQL_LOG_BIN=0";
- return run_query(stmt, 0);
+ mysql_query(sock, "SET WSREP_ON=0"); /* ignore the error, if any */
+ return run_query("SET SQL_LOG_BIN=0", 0);
}
static int handle_request_for_tables(char *tables, size_t length,
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 64ed21ac7fc..ced65f78986 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -39,7 +39,7 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/
-#define DUMP_VERSION "10.15"
+#define DUMP_VERSION "10.16"
#include <my_global.h>
#include <my_sys.h>
@@ -114,7 +114,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_m
opt_slave_apply= 0,
opt_include_master_host_port= 0,
opt_events= 0, opt_comments_used= 0,
- opt_alltspcs=0, opt_notspcs= 0;
+ opt_alltspcs=0, opt_notspcs= 0, opt_logging;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*mysql=0;
@@ -358,7 +358,7 @@ static struct my_option my_long_options[] =
{"force", 'f', "Continue even if we get an SQL error.",
&ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
- {"gtid", OPT_USE_GTID, "Used together with --master-data=1 or --dump-slave=1."
+ {"gtid", 0, "Used together with --master-data=1 or --dump-slave=1."
"When enabled, the output from those options will set the GTID position "
"instead of the binlog file and offset; the file/offset will appear only as "
"a comment. When disabled, the GTID position will still appear in the "
@@ -400,6 +400,8 @@ static struct my_option my_long_options[] =
{"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.",
&log_error_file, &log_error_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"log-queries", 0, "When restoring the dump, the server will, if logging turned on, log the queries to the general and slow query log.",
+ &opt_logging, &opt_logging, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"master-data", OPT_MASTER_DATA,
"This causes the binary log position and filename to be appended to the "
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
@@ -707,6 +709,10 @@ static void write_header(FILE *sql_file, char *db_name)
print_comment(sql_file, 0, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection));
+ if (!opt_logging)
+ fprintf(sql_file,
+"\n/*M!100101 SET LOCAL SQL_LOG_OFF=0, LOCAL SLOW_QUERY_LOG=0 */;");
+
if (opt_set_charset)
fprintf(sql_file,
"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
@@ -1771,11 +1777,11 @@ static my_bool test_if_special_chars(const char *str)
} /* test_if_special_chars */
-
/*
quote_name(name, buff, force)
- Quotes char string, taking into account compatible mode
+ Quotes a string, if it requires quoting. To force quoting regardless
+ of the characters within the string, the force flag can be set to true.
Args
@@ -1784,8 +1790,8 @@ static my_bool test_if_special_chars(const char *str)
force Flag to make it ignore 'test_if_special_chars'
Returns
-
- buff quoted string
+ A pointer to the quoted string, or the original string if nothing has
+ changed.
*/
static char *quote_name(const char *name, char *buff, my_bool force)
@@ -1851,6 +1857,26 @@ static char *quote_for_like(const char *name, char *buff)
return buff;
}
+static char *quote_for_equal(const char *name, char *buff)
+{
+ char *to= buff;
+ *to++= '\'';
+ while (*name)
+ {
+ if (*name == '\\')
+ {
+ *to++='\\';
+ }
+ if (*name == '\'')
+ *to++= '\\';
+ *to++= *name++;
+ }
+ to[0]= '\'';
+ to[1]= 0;
+ return buff;
+
+}
+
/**
Quote and print a string.
@@ -2663,6 +2689,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
+ char temp_buff[NAME_LEN*2 + 3], temp_buff2[NAME_LEN*2 + 3];
const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, "
"`COLUMN_TYPE` AS `Type`, "
"`IS_NULLABLE` AS `Null`, "
@@ -2671,7 +2698,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
"`EXTRA` AS `Extra`, "
"`COLUMN_COMMENT` AS `Comment` "
"FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE "
- "TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
+ "TABLE_SCHEMA = %s AND TABLE_NAME = %s";
FILE *sql_file= md_result_file;
int len;
my_bool is_log_table;
@@ -2984,7 +3011,9 @@ static uint get_table_structure(char *table, char *db, char *table_type,
verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
my_progname_short, mysql_error(mysql));
- my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
+ my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt,
+ quote_for_equal(db, temp_buff),
+ quote_for_equal(table, temp_buff2));
if (mysql_query_with_error_report(mysql, &result, query_buff))
DBUG_RETURN(0);
@@ -3401,8 +3430,10 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
/* Get list of triggers. */
my_snprintf(query_buff, sizeof(query_buff),
- "SHOW TRIGGERS LIKE %s",
- quote_for_like(table_name, name_buff));
+ "SELECT TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS "
+ "WHERE EVENT_OBJECT_SCHEMA = DATABASE() AND "
+ "EVENT_OBJECT_TABLE = %s",
+ quote_for_equal(table_name, name_buff));
if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff))
goto done;
@@ -4766,29 +4797,37 @@ static my_bool dump_all_views_in_db(char *database)
/*
- get_actual_table_name -- executes a SHOW TABLES LIKE '%s' to get the actual
- table name from the server for the table name given on the command line.
- we do this because the table name given on the command line may be a
- different case (e.g. T1 vs t1)
-
- RETURN
- pointer to the table name
- 0 if error
+ See get_actual_table_name. Used to retrieve the correct table name
+ from the database schema.
*/
-
-static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root)
+static char *get_actual_table_name_helper(const char *old_table_name,
+ my_bool case_sensitive,
+ MEM_ROOT *root)
{
char *name= 0;
MYSQL_RES *table_res;
MYSQL_ROW row;
char query[50 + 2*NAME_LEN];
char show_name_buff[FN_REFLEN];
- DBUG_ENTER("get_actual_table_name");
+ DBUG_ENTER("get_actual_table_name_helper");
/* Check memory for quote_for_like() */
DBUG_ASSERT(2*sizeof(old_table_name) < sizeof(show_name_buff));
- my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
- quote_for_like(old_table_name, show_name_buff));
+
+ if (case_sensitive)
+ {
+ DBUG_PRINT("info", ("case sensitive search"));
+ my_snprintf(query, sizeof(query),
+ "SELECT table_name FROM INFORMATION_SCHEMA.TABLES "
+ "WHERE table_schema = DATABASE() AND table_name = %s",
+ quote_for_equal(old_table_name, show_name_buff));
+ }
+ else
+ {
+ DBUG_PRINT("info", ("case insensitive search"));
+ my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
+ quote_for_like(old_table_name, show_name_buff));
+ }
if (mysql_query_with_error_report(mysql, 0, query))
return NullS;
@@ -4813,12 +4852,67 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root)
DBUG_RETURN(name);
}
+/*
+ get_actual_table_name -- executes a SELECT .. FROM I_S.tables to check
+ if the table name given on the command line matches the one in the database.
+ If the table is not found, it falls back to a slower SHOW TABLES LIKE '%s' to
+ get the actual table name from the server.
+
+ We do this because the table name given on the command line may be a
+ different case (e.g. T1 vs t1), but checking this takes a long time
+ when there are many tables present.
+
+ RETURN
+ pointer to the table name
+ 0 if error
+*/
+
+static char *get_actual_table_name(const char *old_table_name,
+ int lower_case_table_names,
+ MEM_ROOT *root)
+{
+ char *name= 0;
+ DBUG_ENTER("get_actual_table_name");
+
+ name= get_actual_table_name_helper(old_table_name, TRUE, root);
+ if (!name && !lower_case_table_names)
+ name= get_actual_table_name_helper(old_table_name, FALSE, root);
+ DBUG_RETURN(name);
+}
+
+/*
+ Retrieve the value for the server system variable lower_case_table_names.
+
+ RETURN
+ 0 case sensitive.
+ > 0 case insensitive
+*/
+static int get_sys_var_lower_case_table_names()
+{
+ int lower_case_table_names = 0;
+ MYSQL_RES *table_res;
+ MYSQL_ROW row;
+ const char *show_var_query = "SHOW VARIABLES LIKE 'lower_case_table_names'";
+ if (mysql_query_with_error_report(mysql, &table_res, show_var_query))
+ return 0; /* In case of error, assume default value of 0 */
+
+ if ((row= mysql_fetch_row(table_res)))
+ {
+ lower_case_table_names= atoi(row[1]);
+ mysql_free_result(table_res);
+ }
+
+ return lower_case_table_names;
+}
+
+
static int dump_selected_tables(char *db, char **table_names, int tables)
{
char table_buff[NAME_LEN*2+3];
DYNAMIC_STRING lock_tables_query;
char **dump_tables, **pos, **end;
+ int lower_case_table_names;
DBUG_ENTER("dump_selected_tables");
if (init_dumping(db, init_dumping_tables))
@@ -4829,11 +4923,15 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
tables * sizeof(char *))))
die(EX_EOM, "alloc_root failure.");
+ /* Figure out how to compare table names. */
+ lower_case_table_names = get_sys_var_lower_case_table_names();
+
init_dynamic_string_checked(&lock_tables_query, "LOCK TABLES ", 256, 1024);
for (; tables > 0 ; tables-- , table_names++)
{
/* the table name passed on commandline may be wrong case */
- if ((*pos= get_actual_table_name(*table_names, &glob_root)))
+ if ((*pos= get_actual_table_name(*table_names, lower_case_table_names,
+ &glob_root)))
{
/* Add found table name to lock_tables_query */
if (lock_tables)
@@ -5449,8 +5547,10 @@ char check_if_ignore_table(const char *table_name, char *table_type)
/* Check memory for quote_for_like() */
DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff));
- my_snprintf(buff, sizeof(buff), "show table status like %s",
- quote_for_like(table_name, show_name_buff));
+ my_snprintf(buff, sizeof(buff),
+ "SELECT engine FROM INFORMATION_SCHEMA.TABLES "
+ "WHERE table_schema = DATABASE() AND table_name = %s",
+ quote_for_equal(table_name, show_name_buff));
if (mysql_query_with_error_report(mysql, &res, buff))
{
if (mysql_errno(mysql) != ER_PARSE_ERROR)
@@ -5468,7 +5568,7 @@ char check_if_ignore_table(const char *table_name, char *table_type)
mysql_free_result(res);
DBUG_RETURN(result); /* assume table is ok */
}
- if (!(row[1]))
+ if (!(row[0]))
strmake(table_type, "VIEW", NAME_LEN-1);
else
{
@@ -5478,7 +5578,7 @@ char check_if_ignore_table(const char *table_name, char *table_type)
these types, but we do want to use delayed inserts in the dump if
the table type is _NOT_ one of these types
*/
- strmake(table_type, row[1], NAME_LEN-1);
+ strmake(table_type, row[0], NAME_LEN-1);
if (opt_delayed)
{
if (strcmp(table_type,"MyISAM") &&
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index ecc8c07605e..afdd2394bc3 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -33,7 +33,7 @@
And many others
*/
-#define MTEST_VERSION "3.4"
+#define MTEST_VERSION "3.5"
#include "client_priv.h"
#include <mysql_version.h>
@@ -2634,12 +2634,11 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
{
char *end = (char*)((query_end && *query_end) ?
*query_end : query + strlen(query));
- MYSQL_RES *res;
+ MYSQL_RES *UNINIT_VAR(res);
MYSQL_ROW row;
MYSQL* mysql = cur_con->mysql;
DYNAMIC_STRING ds_query;
DBUG_ENTER("var_query_set");
- LINT_INIT(res);
if (!mysql)
{
@@ -2685,7 +2684,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
report_or_die("Query '%s' didn't return a result set", ds_query.str);
dynstr_free(&ds_query);
eval_expr(var, "", 0);
- return;
+ DBUG_VOID_RETURN;
}
dynstr_free(&ds_query);
@@ -2818,7 +2817,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
{
long row_no;
int col_no= -1;
- MYSQL_RES* res;
+ MYSQL_RES* UNINIT_VAR(res);
MYSQL* mysql= cur_con->mysql;
static DYNAMIC_STRING ds_query;
@@ -2831,7 +2830,6 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
};
DBUG_ENTER("var_set_query_get_value");
- LINT_INIT(res);
if (!mysql)
{
@@ -4772,10 +4770,6 @@ void do_sync_with_master(struct st_command *command)
}
-/*
- when ndb binlog is on, this call will wait until last updated epoch
- (locally in the mysqld) has been received into the binlog
-*/
int do_save_master_pos()
{
MYSQL_RES *res;
@@ -4784,144 +4778,6 @@ int do_save_master_pos()
const char *query;
DBUG_ENTER("do_save_master_pos");
-#ifdef HAVE_NDB_BINLOG
- /*
- Wait for ndb binlog to be up-to-date with all changes
- done on the local mysql server
- */
- {
- ulong have_ndbcluster;
- if (mysql_query(mysql, query= "show variables like 'have_ndbcluster'"))
- die("'%s' failed: %d %s", query,
- mysql_errno(mysql), mysql_error(mysql));
- if (!(res= mysql_store_result(mysql)))
- die("mysql_store_result() returned NULL for '%s'", query);
- if (!(row= mysql_fetch_row(res)))
- die("Query '%s' returned empty result", query);
-
- have_ndbcluster= strcmp("YES", row[1]) == 0;
- mysql_free_result(res);
-
- if (have_ndbcluster)
- {
- ulonglong start_epoch= 0, handled_epoch= 0,
- latest_epoch=0, latest_trans_epoch=0,
- latest_handled_binlog_epoch= 0, latest_received_binlog_epoch= 0,
- latest_applied_binlog_epoch= 0;
- int count= 0;
- int do_continue= 1;
- while (do_continue)
- {
- const char binlog[]= "binlog";
- const char latest_epoch_str[]=
- "latest_epoch=";
- const char latest_trans_epoch_str[]=
- "latest_trans_epoch=";
- const char latest_received_binlog_epoch_str[]=
- "latest_received_binlog_epoch";
- const char latest_handled_binlog_epoch_str[]=
- "latest_handled_binlog_epoch=";
- const char latest_applied_binlog_epoch_str[]=
- "latest_applied_binlog_epoch=";
- if (count)
- my_sleep(100*1000); /* 100ms */
- if (mysql_query(mysql, query= "show engine ndb status"))
- die("failed in '%s': %d %s", query,
- mysql_errno(mysql), mysql_error(mysql));
- if (!(res= mysql_store_result(mysql)))
- die("mysql_store_result() returned NULL for '%s'", query);
- while ((row= mysql_fetch_row(res)))
- {
- if (strcmp(row[1], binlog) == 0)
- {
- const char *status= row[2];
-
- /* latest_epoch */
- while (*status && strncmp(status, latest_epoch_str,
- sizeof(latest_epoch_str)-1))
- status++;
- if (*status)
- {
- status+= sizeof(latest_epoch_str)-1;
- latest_epoch= strtoull(status, (char**) 0, 10);
- }
- else
- die("result does not contain '%s' in '%s'",
- latest_epoch_str, query);
- /* latest_trans_epoch */
- while (*status && strncmp(status, latest_trans_epoch_str,
- sizeof(latest_trans_epoch_str)-1))
- status++;
- if (*status)
- {
- status+= sizeof(latest_trans_epoch_str)-1;
- latest_trans_epoch= strtoull(status, (char**) 0, 10);
- }
- else
- die("result does not contain '%s' in '%s'",
- latest_trans_epoch_str, query);
- /* latest_received_binlog_epoch */
- while (*status &&
- strncmp(status, latest_received_binlog_epoch_str,
- sizeof(latest_received_binlog_epoch_str)-1))
- status++;
- if (*status)
- {
- status+= sizeof(latest_received_binlog_epoch_str)-1;
- latest_received_binlog_epoch= strtoull(status, (char**) 0, 10);
- }
- else
- die("result does not contain '%s' in '%s'",
- latest_received_binlog_epoch_str, query);
- /* latest_handled_binlog */
- while (*status &&
- strncmp(status, latest_handled_binlog_epoch_str,
- sizeof(latest_handled_binlog_epoch_str)-1))
- status++;
- if (*status)
- {
- status+= sizeof(latest_handled_binlog_epoch_str)-1;
- latest_handled_binlog_epoch= strtoull(status, (char**) 0, 10);
- }
- else
- die("result does not contain '%s' in '%s'",
- latest_handled_binlog_epoch_str, query);
- /* latest_applied_binlog_epoch */
- while (*status &&
- strncmp(status, latest_applied_binlog_epoch_str,
- sizeof(latest_applied_binlog_epoch_str)-1))
- status++;
- if (*status)
- {
- status+= sizeof(latest_applied_binlog_epoch_str)-1;
- latest_applied_binlog_epoch= strtoull(status, (char**) 0, 10);
- }
- else
- die("result does not contain '%s' in '%s'",
- latest_applied_binlog_epoch_str, query);
- if (count == 0)
- start_epoch= latest_trans_epoch;
- break;
- }
- }
- if (!row)
- die("result does not contain '%s' in '%s'",
- binlog, query);
- if (latest_handled_binlog_epoch > handled_epoch)
- count= 0;
- handled_epoch= latest_handled_binlog_epoch;
- count++;
- if (latest_handled_binlog_epoch >= start_epoch)
- do_continue= 0;
- else if (count > 300) /* 30s */
- {
- break;
- }
- mysql_free_result(res);
- }
- }
- }
-#endif
if (mysql_query(mysql, query= "show master status"))
die("failed in 'show master status': %d %s",
mysql_errno(mysql), mysql_error(mysql));
@@ -5172,7 +5028,7 @@ static int my_kill(int pid, int sig)
void do_shutdown_server(struct st_command *command)
{
- long timeout=60;
+ long timeout= opt_wait_for_pos_timeout ? opt_wait_for_pos_timeout / 5 : 300;
int pid;
DYNAMIC_STRING ds_pidfile_name;
MYSQL* mysql = cur_con->mysql;
@@ -5241,7 +5097,6 @@ void do_shutdown_server(struct st_command *command)
(void)my_kill(pid, 9);
DBUG_VOID_RETURN;
-
}
@@ -10277,7 +10132,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
{
/* find the match */
err_code= regexec(&r,str_p, r.re_nsub+1, subs,
- (str_p == string) ? REG_NOTBOL : 0);
+ (str_p == string) ? 0 : REG_NOTBOL);
/* if regular expression error (eg. bad syntax, or out of memory) */
if (err_code && err_code != REG_NOMATCH)
diff --git a/client/readline.cc b/client/readline.cc
index b6643b86356..23b1f8d7ac7 100644
--- a/client/readline.cc
+++ b/client/readline.cc
@@ -57,8 +57,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
char *batch_readline(LINE_BUFFER *line_buff, bool binary_mode)
{
char *pos;
- ulong out_length;
- LINT_INIT(out_length);
+ ulong UNINIT_VAR(out_length);
if (!(pos=intern_read_line(line_buff, &out_length)))
return 0;