diff options
-rw-r--r-- | mysql-test/suite/maria/truncate.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/maria/truncate.test | 13 | ||||
-rw-r--r-- | sql/sql_truncate.cc | 1 | ||||
-rw-r--r-- | storage/maria/ha_maria.cc | 3 |
4 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/suite/maria/truncate.result b/mysql-test/suite/maria/truncate.result index 467e0f915dd..a9adcb9ae87 100644 --- a/mysql-test/suite/maria/truncate.result +++ b/mysql-test/suite/maria/truncate.result @@ -35,3 +35,15 @@ select count(*) from t1; count(*) 0 drop table t1,t2; +CREATE TEMPORARY TABLE t1 ( i int) ENGINE=aria; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 +TRUNCATE TABLE t1; +INSERT INTO t1 (i) VALUES (1); +lock table t1 write; +truncate table t1; +unlock tables; +drop table t1; diff --git a/mysql-test/suite/maria/truncate.test b/mysql-test/suite/maria/truncate.test index 3d6e70d9db6..11d42dc3879 100644 --- a/mysql-test/suite/maria/truncate.test +++ b/mysql-test/suite/maria/truncate.test @@ -45,3 +45,16 @@ select * from t1; truncate t1; select count(*) from t1; drop table t1,t2; + +# +# MDEV-3890 +# Server crash inserting record on a temporary table after truncating it +# +CREATE TEMPORARY TABLE t1 ( i int) ENGINE=aria; +SHOW CREATE TABLE t1; +TRUNCATE TABLE t1; +INSERT INTO t1 (i) VALUES (1); +lock table t1 write; +truncate table t1; +unlock tables; +drop table t1; diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 979dde30ceb..4b77344c042 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -263,6 +263,7 @@ static bool recreate_temporary_table(THD *thd, TABLE *table) DBUG_ENTER("recreate_temporary_table"); memset(&create_info, 0, sizeof(create_info)); + create_info.options|= HA_LEX_CREATE_TMP_TABLE; table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 1278d951a16..31b903871ce 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3042,7 +3042,10 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ha_create_info->transactional != HA_CHOICE_NO); if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE) + { create_flags|= HA_CREATE_TMP_TABLE; + create_info.transactional= 0; + } if (ha_create_info->options & HA_CREATE_KEEP_FILES) create_flags|= HA_CREATE_KEEP_FILES; if (options & HA_OPTION_PACK_RECORD) |