Commit d189ab9b authored by unknown's avatar unknown

Merge mkindahl@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  mysql.com:/users/mkindahl/bk/b15923-mysql-5.1-new


mysql-test/t/disabled.def:
  Auto merged
sql/sql_delete.cc:
  Auto merged
parents 16dbe6cc 05671ba3
......@@ -262,21 +262,22 @@ master-bin.000001 209 Write_rows 1 #
master-bin.000001 243 Table_map 1 # test.t1
master-bin.000001 282 Write_rows 1 #
master-bin.000001 316 Xid 1 # COMMIT /* xid= */
master-bin.000001 343 Table_map 1 # test.t1
master-bin.000001 382 Delete_rows 1 #
master-bin.000001 421 Xid 1 # COMMIT /* xid= */
master-bin.000001 448 Query 1 # use `test`; alter table t2 type=MyISAM
master-bin.000001 537 Table_map 1 # test.t1
master-bin.000001 576 Write_rows 1 #
master-bin.000001 610 Xid 1 # COMMIT /* xid= */
master-bin.000001 637 Table_map 1 # test.t2
master-bin.000001 676 Write_rows 1 #
master-bin.000001 710 Query 1 # use `test`; drop table t1,t2
master-bin.000001 789 Query 1 # use `test`; create table t0 (n int)
master-bin.000001 875 Table_map 1 # test.t0
master-bin.000001 914 Write_rows 1 #
master-bin.000001 948 Table_map 1 # test.t0
master-bin.000001 987 Write_rows 1 #
master-bin.000001 1021 Query 1 # use `test`; create table t2 (n int) engine=innodb
master-bin.000001 343 Query 1 # use `test`; delete from t1
master-bin.000001 420 Xid 1 # COMMIT /* xid= */
master-bin.000001 447 Query 1 # use `test`; delete from t2
master-bin.000001 524 Xid 1 # COMMIT /* xid= */
master-bin.000001 551 Query 1 # use `test`; alter table t2 type=MyISAM
master-bin.000001 640 Table_map 1 # test.t1
master-bin.000001 679 Write_rows 1 #
master-bin.000001 713 Xid 1 # COMMIT /* xid= */
master-bin.000001 740 Table_map 1 # test.t2
master-bin.000001 779 Write_rows 1 #
master-bin.000001 813 Query 1 # use `test`; drop table t1,t2
master-bin.000001 892 Query 1 # use `test`; create table t0 (n int)
master-bin.000001 978 Table_map 1 # test.t0
master-bin.000001 1017 Write_rows 1 #
master-bin.000001 1051 Table_map 1 # test.t0
master-bin.000001 1090 Write_rows 1 #
master-bin.000001 1124 Query 1 # use `test`; create table t2 (n int) engine=innodb
do release_lock("lock1");
drop table t0,t2;
......@@ -21,6 +21,6 @@ innodb_concurrent : Results are not deterministic, Elliot will fix (BUG#3300)
subselect : Bug#15706
type_time : Bug#15805
#rpl000002 : Bug#15920 Temporary tables are not binlogged in SBR
ps_7ndb : Bug#15923 Core dump in RBR mode when executing test suite
#ps_7ndb : Bug#15923 Core dump in RBR mode when executing test suite
rpl_ddl : Bug#15963 SBR does not show "Definer" correctly
mysqlslap : Bug#16167
......@@ -40,7 +40,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
ha_rows deleted;
uint usable_index= MAX_KEY;
SELECT_LEX *select_lex= &thd->lex->select_lex;
bool ha_delete_row_bypassed= 0;
bool ha_delete_all_rows= 0;
DBUG_ENTER("mysql_delete");
if (open_and_lock_tables(thd, table_list))
......@@ -79,17 +79,20 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
!(table->triggers && table->triggers->has_delete_triggers()))
{
ha_rows const maybe_deleted= table->file->records;
/*
If all rows shall be deleted, we always log this statement-based
(see [binlog], below), so we set this flag and test it below.
*/
ha_delete_all_rows= 1;
if (!(error=table->file->delete_all_rows()))
{
error= -1; // ok
deleted= maybe_deleted;
ha_delete_row_bypassed= 1;
goto cleanup;
}
if (error != HA_ERR_WRONG_COMMAND)
{
table->file->print_error(error,MYF(0));
ha_delete_row_bypassed= 1;
error=0;
goto cleanup;
}
......@@ -200,6 +203,16 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
init_ftfuncs(thd, select_lex, 1);
thd->proc_info="updating";
will_batch= !table->file->start_bulk_delete();
/*
Save the thread options before clearing the OPTION_BIN_LOG,
effectively disabling the binary log (unless it was already
disabled, of course).
*/
ulonglong const saved_options= thd->options;
if (ha_delete_all_rows)
thd->options&= ~static_cast<ulonglong>(OPTION_BIN_LOG);
while (!(error=info.read_record(&info)) && !thd->killed &&
!thd->net.report_error)
{
......@@ -290,6 +303,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
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))
{
......@@ -299,14 +319,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
thd->clear_error();
/*
If 'handler::delete_all_rows()' was called, we replicate
statement-based; otherwise, 'ha_delete_row()' was used to
delete specific rows which we might log row-based.
[binlog]: If 'handler::delete_all_rows()' was called, we
replicate 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_row_bypassed ?
THD::STMT_QUERY_TYPE :
THD::ROW_QUERY_TYPE);
query_type(ha_delete_all_rows ?
THD::STMT_QUERY_TYPE :
THD::ROW_QUERY_TYPE);
int log_result= thd->binlog_query(query_type,
thd->query, thd->query_length,
transactional_table, FALSE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment