diff options
author | Mattias Jonsson <mattias.jonsson@oracle.com> | 2010-12-03 10:33:29 +0100 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@oracle.com> | 2010-12-03 10:33:29 +0100 |
commit | a998586d45f197fcf39b215c24c214142786d1fc (patch) | |
tree | 71faa78703f912c7baac07e52ee212b2f30b9b4e /sql | |
parent | 3ffab566196fb596e91eb9260d791d8578401b16 (diff) | |
parent | 2737a722785589eca70f4e25eaaa0d8f594462df (diff) | |
download | mariadb-git-a998586d45f197fcf39b215c24c214142786d1fc.tar.gz |
merge of bug#58147, including rename of the new argument,
to_binlog -> binlog_stmt.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.cc | 7 | ||||
-rw-r--r-- | sql/ha_partition.h | 2 | ||||
-rw-r--r-- | sql/sql_partition_admin.cc | 11 |
3 files changed, 14 insertions, 6 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index f4e240e5cc1..4e0fb7c804a 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3428,7 +3428,7 @@ int ha_partition::truncate() ALTER TABLE t TRUNCATE PARTITION ... */ -int ha_partition::truncate_partition(Alter_info *alter_info) +int ha_partition::truncate_partition(Alter_info *alter_info, bool *binlog_stmt) { int error= 0; List_iterator<partition_element> part_it(m_part_info->partitions); @@ -3440,6 +3440,9 @@ int ha_partition::truncate_partition(Alter_info *alter_info) PART_ADMIN); DBUG_ENTER("ha_partition::truncate_partition"); + /* Only binlog when it starts any call to the partitions handlers */ + *binlog_stmt= false; + /* TRUNCATE also means resetting auto_increment. Hence, reset it so that it will be initialized again at the next use. @@ -3453,6 +3456,8 @@ int ha_partition::truncate_partition(Alter_info *alter_info) (!(alter_info->flags & ALTER_ALL_PARTITION))) DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); + *binlog_stmt= true; + do { partition_element *part_elem= part_it++; diff --git a/sql/ha_partition.h b/sql/ha_partition.h index f1abc0cefe2..57456ddf8ae 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -362,7 +362,7 @@ public: @remark This method is a partitioning-specific hook and thus not a member of the general SE API. */ - int truncate_partition(Alter_info *); + int truncate_partition(Alter_info *, bool *binlog_stmt); virtual bool is_fatal_error(int error, uint flags) { diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 8f6ab5803d7..cadfc587c1c 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 binlog_stmt; 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, + &binlog_stmt))) 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 && binlog_stmt) error|= write_bin_log(thd, !error, thd->query(), thd->query_length()); /* |