diff options
author | Mattias Jonsson <mattias.jonsson@oracle.com> | 2010-12-01 22:47:40 +0100 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@oracle.com> | 2010-12-01 22:47:40 +0100 |
commit | 2737a722785589eca70f4e25eaaa0d8f594462df (patch) | |
tree | 12242bd3cd9a5751c589b93eb792f9924f9d0556 /sql/sql_partition_admin.cc | |
parent | 45e17739d441f418fc0727ac3cc10f17c17b341e (diff) | |
download | mariadb-git-2737a722785589eca70f4e25eaaa0d8f594462df.tar.gz |
Bug#58147: ALTER TABLE w/ TRUNCATE PARTITION fails
but the statement is written to binlog
TRUNCATE PARTITION was written to the binlog
even if it failed before calling any partition's
truncate function.
Solved by adding an argument to truncate_partition,
to flag if it should be written to the binlog or not.
It should be written to the binlog when a call to any
partitions truncate function is done.
mysql-test/r/partition_binlog.result:
New result file
mysql-test/t/partition_binlog.test:
New test file, including DROP PARTITION binlog test
sql/ha_partition.cc:
Added argument to avoid binlogging failed truncate_partition that
have not yet changed any data.
sql/ha_partition.h:
Added argument to avoid excessive binlogging
sql/sql_partition_admin.cc:
Avoid to binlog TRUNCATE PARTITION if it fails before
any partition has tried to truncate.
Diffstat (limited to 'sql/sql_partition_admin.cc')
-rw-r--r-- | sql/sql_partition_admin.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 8f6ab5803d7..716f57b15e8 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -110,6 +110,7 @@ bool Alter_table_truncate_partition_statement::execute(THD *thd) ha_partition *partition; ulong timeout= thd->variables.lock_wait_timeout; TABLE_LIST *first_table= thd->lex->select_lex.table_list.first; + bool to_binlog; DBUG_ENTER("Alter_table_truncate_partition_statement::execute"); /* @@ -161,16 +162,18 @@ bool Alter_table_truncate_partition_statement::execute(THD *thd) partition= (ha_partition *) first_table->table->file; /* Invoke the handler method responsible for truncating the partition. */ - if ((error= partition->truncate_partition(&thd->lex->alter_info))) + if ((error= partition->truncate_partition(&thd->lex->alter_info, + &to_binlog))) first_table->table->file->print_error(error, MYF(0)); /* All effects of a truncate operation are committed even if the operation fails. Thus, the query must be written to the binary - log. The only exception is a unimplemented truncate method. Also, - it is logged in statement format, regardless of the binlog format. + log. The exception is a unimplemented truncate method or failure + before any call to handler::truncate() is done. + Also, it is logged in statement format, regardless of the binlog format. */ - if (error != HA_ERR_WRONG_COMMAND) + if (error != HA_ERR_WRONG_COMMAND && to_binlog) error|= write_bin_log(thd, !error, thd->query(), thd->query_length()); /* |