diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 4 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 27 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 5 | ||||
-rw-r--r-- | client/mysqlcheck.c | 19 | ||||
-rw-r--r-- | client/mysqlslap.c | 9 | ||||
-rw-r--r-- | client/mysqltest.cc | 11 |
6 files changed, 69 insertions, 6 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index f98e520d564..6c0c6771ba1 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2868,7 +2868,7 @@ com_help(String *buffer __attribute__((unused)), "For developer information, including the MySQL Reference Manual, " "visit:\n" " http://dev.mysql.com/\n" - "To buy MySQL Network Support, training, or other products, visit:\n" + "To buy MySQL Enterprise support, training, or other products, visit:\n" " https://shop.mysql.com/\n", INFO_INFO); put_info("List of all MySQL commands:", INFO_INFO); if (!named_cmds) @@ -3566,7 +3566,7 @@ static void print_warnings() messages. To be safe, skip printing the duplicate only if it is the only warning. */ - if (!cur || num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10)) + if (!cur || (num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10))) goto end; /* Print the warnings */ diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index cfd7ed4ea56..52c3636219d 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -54,6 +54,8 @@ static char **defaults_argv; static my_bool not_used; /* Can't use GET_BOOL without a value pointer */ +static my_bool opt_write_binlog; + #include <help_start.h> static struct my_option my_long_options[]= @@ -124,6 +126,11 @@ static struct my_option my_long_options[]= {"verbose", 'v', "Display more output about the process", (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"write-binlog", OPT_WRITE_BINLOG, + "All commands including mysqlcheck are binlogged. Enabled by default;" + "use --skip-write-binlog when commands should not be sent to replication slaves.", + (uchar**) &opt_write_binlog, (uchar**) &opt_write_binlog, 0, GET_BOOL, NO_ARG, + 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -448,6 +455,8 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, int ret; File fd; char query_file_path[FN_REFLEN]; + const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;"; + DBUG_ENTER("run_query"); DBUG_PRINT("enter", ("query: %s", query)); if ((fd= create_temp_file(query_file_path, opt_tmpdir, @@ -455,6 +464,22 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, MYF(MY_WME))) < 0) die("Failed to create temporary file for defaults"); + /* + Master and slave should be upgraded separately. All statements executed + by mysql_upgrade will not be binlogged. + 'SET SQL_LOG_BIN=0' is executed before any other statements. + */ + if (!opt_write_binlog) + { + if (my_write(fd, sql_log_bin, sizeof(sql_log_bin)-1, + MYF(MY_FNABP | MY_WME))) + { + my_close(fd, MYF(0)); + my_delete(query_file_path, MYF(0)); + die("Failed to write to '%s'", query_file_path); + } + } + if (my_write(fd, (uchar*) query, strlen(query), MYF(MY_FNABP | MY_WME))) { @@ -648,6 +673,7 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", + opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } @@ -662,6 +688,7 @@ static int run_mysqlcheck_fixnames(void) "--all-databases", "--fix-db-names", "--fix-table-names", + opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index a01918caad4..5bfde5b606c 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -726,7 +726,10 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, switch (ev_type) { case QUERY_EVENT: - if (shall_skip_database(((Query_log_event*)ev)->db)) + if (strncmp(((Query_log_event*)ev)->query, "BEGIN", 5) && + strncmp(((Query_log_event*)ev)->query, "COMMIT", 6) && + strncmp(((Query_log_event*)ev)->query, "ROLLBACK", 8) && + shall_skip_database(((Query_log_event*)ev)->db)) goto end; if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS) { diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 82aabd77b24..1533e602639 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -652,6 +652,17 @@ static int use_db(char *database) return 0; } /* use_db */ +static int disable_binlog() +{ + const char *stmt= "SET SQL_LOG_BIN=0"; + if (mysql_query(sock, stmt)) + { + fprintf(stderr, "Failed to %s\n", stmt); + fprintf(stderr, "Error: %s\n", mysql_error(sock)); + return 1; + } + return 0; +} static int handle_request_for_tables(char *tables, uint length) { @@ -844,6 +855,14 @@ int main(int argc, char **argv) if (dbConnect(current_host, current_user, opt_password)) exit(EX_MYSQLERR); + if (!opt_write_binlog) + { + if (disable_binlog()) { + first_error= 1; + goto end; + } + } + if (opt_auto_repair && my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,64)) { diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 0bbc15eb24e..f13b5099766 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -423,6 +423,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr) stats *sptr; conclusions conclusion; unsigned long long client_limit; + int sysret; head_sptr= (stats *)my_malloc(sizeof(stats) * iterations, MYF(MY_ZEROFILL|MY_FAE|MY_WME)); @@ -463,7 +464,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr) run_query(mysql, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); if (pre_system) - system(pre_system); + if ((sysret= system(pre_system)) != 0) + fprintf(stderr, "Warning: Execution of pre_system option returned %d.\n", + sysret); /* Pre statements are always run after all other logic so they can @@ -478,7 +481,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr) run_statements(mysql, post_statements); if (post_system) - system(post_system); + if ((sysret= system(post_system)) != 0) + fprintf(stderr, "Warning: Execution of post_system option returned %d.\n", + sysret); /* We are finished with this run */ if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9e8f31178ad..e37b7d89a93 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -6775,8 +6775,10 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, MYSQL_STMT *stmt; DYNAMIC_STRING ds_prepare_warnings; DYNAMIC_STRING ds_execute_warnings; + ulonglong affected_rows; DBUG_ENTER("run_query_stmt"); DBUG_PRINT("query", ("'%-.60s'", query)); + LINT_INIT(affected_rows); /* Init a new stmt if it's not already one created for this connection @@ -6907,6 +6909,13 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, */ } + /* + Need to grab affected rows information before getting + warnings here + */ + if (!disable_info) + affected_rows= mysql_affected_rows(mysql); + if (!disable_warnings) { /* Get the warnings from execute */ @@ -6931,7 +6940,7 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, } if (!disable_info) - append_info(ds, mysql_affected_rows(mysql), mysql_info(mysql)); + append_info(ds, affected_rows, mysql_info(mysql)); } |