diff options
author | unknown <lars@mysql.com> | 2006-06-16 01:15:19 +0200 |
---|---|---|
committer | unknown <lars@mysql.com> | 2006-06-16 01:15:19 +0200 |
commit | 9933c3bd3a21f8b7dfbe80068ae455be325d8d3f (patch) | |
tree | 3d62694dfc5e3c919e109127dafeb40e4a665a75 /sql/sql_delete.cc | |
parent | ed849efcc176b4d7b500ca69cf0ee7b1ec39f8ab (diff) | |
parent | 684bda9a06a3967d83d25907a3077aa3849468ad (diff) | |
download | mariadb-git-9933c3bd3a21f8b7dfbe80068ae455be325d8d3f.tar.gz |
Merge mysql.com:/users/lthalmann/bkroot/mysql-5.1-new-rpl
into mysql.com:/users/lthalmann/bk/MERGE/mysql-5.1-merge
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Auto merged
mysql-test/r/federated.result:
Auto merged
mysql-test/r/innodb.result:
Auto merged
mysql-test/extra/rpl_tests/rpl_ddl.test:
Auto merged
mysql-test/r/rpl_ddl.result:
Auto merged
mysql-test/r/sp-error.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/r/rpl_ndb_charset.result:
Auto merged
mysql-test/r/type_ranges.result:
Auto merged
mysql-test/r/view.result:
Auto merged
mysql-test/r/trigger-grant.result:
Auto merged
mysql-test/t/archive.test:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/disabled.def:
Auto merged
mysql-test/t/federated.test:
Auto merged
mysql-test/t/innodb.test:
Auto merged
mysql-test/t/innodb_mysql.test:
Auto merged
mysql-test/t/sp.test:
Auto merged
mysql-test/t/trigger-grant.test:
Auto merged
mysql-test/t/view.test:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/log.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
mysql-test/r/create.result:
Manual merge
mysql-test/r/innodb_mysql.result:
Manual merge
sql/handler.cc:
Manual merge
sql/share/errmsg.txt:
Manual merge
sql/sql_class.h:
Manual merge
sql/sql_delete.cc:
Manual merge
sql/sql_insert.cc:
Manual merge
sql/sql_table.cc:
Manual merge
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index dd4748bc15c..73a0a9a69c2 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -42,8 +42,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ha_rows deleted= 0; uint usable_index= MAX_KEY; SELECT_LEX *select_lex= &thd->lex->select_lex; - bool ha_delete_all_rows= 0; - ulonglong const saved_options= thd->options; DBUG_ENTER("mysql_delete"); if (open_and_lock_tables(thd, table_list)) @@ -75,20 +73,19 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, Test if the user wants to delete all rows and deletion doesn't have any side-effects (because of triggers), so we can use optimized handler::delete_all_rows() method. + + If row-based replication is used, we also delete the table row by + row. */ if (!using_limit && const_cond && (!conds || conds->val_int()) && !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) && - !(table->triggers && table->triggers->has_delete_triggers())) + !(table->triggers && table->triggers->has_delete_triggers()) && + !thd->current_stmt_binlog_row_based) { /* Update the table->file->stats.records number */ table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); ha_rows const maybe_deleted= table->file->stats.records; - /* - If all rows shall be deleted, we (almost) always log this - statement-based (see [binlog], below), so we set this flag and - test it below. - */ - ha_delete_all_rows= 1; + DBUG_PRINT("debug", ("Trying to use delete_all_rows()")); if (!(error=table->file->delete_all_rows())) { error= -1; // ok @@ -218,13 +215,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, thd->proc_info="updating"; will_batch= !table->file->start_bulk_delete(); - /* - We saved the thread options above before clearing the - OPTION_BIN_LOG, and will restore below, effectively disabling the - binary log (unless it was already disabled, of course). - */ - if (ha_delete_all_rows) - thd->options&= ~static_cast<ulonglong>(OPTION_BIN_LOG); table->mark_columns_needed_for_delete(); @@ -318,12 +308,6 @@ cleanup: delete select; transactional_table= table->file->has_transactions(); - /* - Restore the saved value of the OPTION_BIN_LOG bit in the thread - options before executing binlog_query() below. - */ - thd->options|= (saved_options & OPTION_BIN_LOG); - /* See similar binlogging code in sql_update.cc, for comments */ if ((error < 0) || (deleted && !transactional_table)) { @@ -338,11 +322,7 @@ cleanup: statement-based; otherwise, 'ha_delete_row()' was used to delete specific rows which we might log row-based. */ - THD::enum_binlog_query_type const - query_type(ha_delete_all_rows && !table->file->is_injective() ? - THD::STMT_QUERY_TYPE : - THD::ROW_QUERY_TYPE); - int log_result= thd->binlog_query(query_type, + int log_result= thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, transactional_table, FALSE); @@ -1004,6 +984,9 @@ trunc_by_del: thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT); ha_enable_transaction(thd, FALSE); mysql_init_select(thd->lex); +#ifdef HAVE_ROW_BASED_REPLICATION + thd->clear_current_stmt_binlog_row_based(); +#endif error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, HA_POS_ERROR, LL(0), TRUE); ha_enable_transaction(thd, TRUE); |