summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2010-12-01 22:47:40 +0100
committerMattias Jonsson <mattias.jonsson@oracle.com>2010-12-01 22:47:40 +0100
commit2737a722785589eca70f4e25eaaa0d8f594462df (patch)
tree12242bd3cd9a5751c589b93eb792f9924f9d0556 /sql/ha_partition.cc
parent45e17739d441f418fc0727ac3cc10f17c17b341e (diff)
downloadmariadb-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/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index f4e240e5cc1..be9c4c13ff4 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 *to_binlog)
{
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 */
+ *to_binlog= 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);
+ *to_binlog= true;
+
do
{
partition_element *part_elem= part_it++;