summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/innodb.result1
-rw-r--r--mysql-test/t/innodb.test1
-rw-r--r--sql/sql_delete.cc8
3 files changed, 8 insertions, 2 deletions
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index c282ec68c78..f00679801f8 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -821,6 +821,7 @@ truncate table t1;
Can't execute the given command because you have active locked tables or an active transaction
commit;
truncate table t1;
+truncate table t1;
select * from t1;
a
insert into t1 values(1),(2);
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 34eabcc22df..2c8002ea841 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -528,6 +528,7 @@ insert into t1 values(1),(2);
truncate table t1;
commit;
truncate table t1;
+truncate table t1;
select * from t1;
insert into t1 values(1),(2);
delete from t1;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 475df34dc4f..166a0e130e3 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -590,8 +590,12 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
{
/* Probably InnoDB table */
table_list->lock_type= TL_WRITE;
- DBUG_RETURN(mysql_delete(thd, table_list, (COND*) 0, (ORDER*) 0,
- HA_POS_ERROR, 0));
+ ulong save_options= thd->options;
+ thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
+ int res= mysql_delete(thd, table_list, (COND*) 0, (ORDER*) 0,
+ HA_POS_ERROR, 0);
+ thd->options= save_options;
+ DBUG_RETURN(res);
}
if (lock_and_wait_for_table_name(thd, table_list))
DBUG_RETURN(-1);