diff options
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 83 |
1 files changed, 32 insertions, 51 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c3a39354ff1..c752905d14c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1998,8 +1998,13 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, case 0: // removed temporary table tmp_table_deleted= 1; - if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED && - thd->is_current_stmt_binlog_format_row()) + /* + One needs to always log any temporary table drop if the current + statement logging format is set to row. This happens because one + might have created a temporary table while the statement logging + format was statement and then switched to mixed or row format. + */ + if (thd->is_current_stmt_binlog_format_row()) { if (built_tmp_query.is_empty()) { @@ -2191,7 +2196,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, deleted one or more non-temporary tables (and no temporary tables). In this case, we can write the original query into the binary log. - */ + */ error |= write_bin_log(thd, !error, thd->query(), thd->query_length()); } else if (thd->is_current_stmt_binlog_format_row() && @@ -2218,11 +2223,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } /* - One needs to always log any temporary table drop, if: - 1. thread logging format is mixed mode; AND - 2. current statement logging format is set to row. + One needs to always log any temporary table drop if the current + statement logging format is set to row. This happens because one + might have created a temporary table while the statement logging + format was statement and then switched to mixed or row format. */ - if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED) + if (thd->is_current_stmt_binlog_format_row()) { /* In this case we have deleted some temporary tables but we are using @@ -2233,8 +2239,14 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, */ built_tmp_query.chop(); // Chop of the last comma built_tmp_query.append(" /* generated by server */"); - error|= write_bin_log(thd, !error, built_tmp_query.ptr(), built_tmp_query.length(), - thd->in_multi_stmt_transaction()); + /* + We cannot call the write_bin_log as we do not care about any errors + in the master as the statement is always DROP TEMPORARY TABLE IF EXISTS + and as such there will be no errors in the slave. + */ + error|= thd->binlog_query(THD::STMT_QUERY_TYPE, built_tmp_query.ptr(), + built_tmp_query.length(), FALSE, FALSE, FALSE, + 0); } } @@ -3749,43 +3761,6 @@ void sp_prepare_create_field(THD *thd, Create_field *sql_field) (void) prepare_blob_field(thd, sql_field); } - -/* - Write CREATE TABLE binlog - - SYNOPSIS - write_create_table_bin_log() - thd Thread object - create_info Create information - internal_tmp_table Set to 1 if this is an internal temporary table - - DESCRIPTION - This function only is called in mysql_create_table_no_lock and - mysql_create_table - - RETURN VALUES - NONE - */ -static inline int write_create_table_bin_log(THD *thd, - const HA_CREATE_INFO *create_info, - bool internal_tmp_table) -{ - /* - Don't write statement if: - - It is an internal temporary table, - - Row-based logging is used and it we are creating a temporary table, or - - The binary log is not open. - Otherwise, the statement shall be binlogged. - */ - if (!internal_tmp_table && - (!thd->is_current_stmt_binlog_format_row() || - (thd->is_current_stmt_binlog_format_row() && - !(create_info->options & HA_LEX_CREATE_TMP_TABLE)))) - return write_bin_log(thd, TRUE, thd->query(), thd->query_length()); - return 0; -} - - /* Create a table @@ -5042,11 +5017,17 @@ send_result_message: { /* Clear the ticket released in close_thread_tables(). */ table->mdl_request.ticket= NULL; - if ((table->table= open_ltable(thd, table, lock_type, 0)) && - ((result_code= table->table->file->ha_analyze(thd, check_opt)) > 0)) - result_code= 0; // analyze went ok - if (result_code) // analyze failed - table->table->file->print_error(result_code, MYF(0)); + DEBUG_SYNC(thd, "ha_admin_open_ltable"); + if (table->table= open_ltable(thd, table, lock_type, 0)) + { + result_code= table->table->file->ha_analyze(thd, check_opt); + if (result_code == HA_ADMIN_ALREADY_DONE) + result_code= HA_ADMIN_OK; + else if (result_code) // analyze failed + table->table->file->print_error(result_code, MYF(0)); + } + else + result_code= -1; // open failed } /* Start a new row for the final status row */ protocol->prepare_for_resend(); |