diff options
-rw-r--r-- | mysql-test/suite/sql_sequence/lock.result | 5 | ||||
-rw-r--r-- | mysql-test/suite/sql_sequence/lock.test | 13 | ||||
-rw-r--r-- | sql/sql_truncate.cc | 7 |
3 files changed, 22 insertions, 3 deletions
diff --git a/mysql-test/suite/sql_sequence/lock.result b/mysql-test/suite/sql_sequence/lock.result index 92c75ff8188..e92bdbffcf9 100644 --- a/mysql-test/suite/sql_sequence/lock.result +++ b/mysql-test/suite/sql_sequence/lock.result @@ -32,3 +32,8 @@ CREATE SEQUENCE seq2; LOCK TABLE seq1 WRITE, seq2 WRITE; INSERT INTO seq1 VALUES (1, 1, 100000, 1, 1, 100, 1, 1); DROP SEQUENCE seq1, seq2; +CREATE OR REPLACE SEQUENCE s1 ENGINE=MyISAM; +LOCK TABLE s1 WRITE; +TRUNCATE TABLE s1; +ERROR HY000: Storage engine SEQUENCE of the table `test`.`s1` doesn't have this option +DROP SEQUENCE s1; diff --git a/mysql-test/suite/sql_sequence/lock.test b/mysql-test/suite/sql_sequence/lock.test index 730404abf38..1cb6aa6fb54 100644 --- a/mysql-test/suite/sql_sequence/lock.test +++ b/mysql-test/suite/sql_sequence/lock.test @@ -39,7 +39,6 @@ DROP SEQUENCE s1; unlock tables; DROP SEQUENCE s1; - # # MDEV-15106 Unexpected ER_WRONG_INSERT_INTO_SEQUENCE upon INSERT with # multiple locks on sequences @@ -51,3 +50,15 @@ LOCK TABLE seq1 WRITE, seq2 WRITE; INSERT INTO seq1 VALUES (1, 1, 100000, 1, 1, 100, 1, 1); DROP SEQUENCE seq1, seq2; +# +# MDEV-15970 +# Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failure and/or +# ER_KEY_NOT_FOUND upon TRUNCATE sequence under lock +# + +CREATE OR REPLACE SEQUENCE s1 ENGINE=MyISAM; +LOCK TABLE s1 WRITE; +--error ER_ILLEGAL_HA +TRUNCATE TABLE s1; +# Cleanup +DROP SEQUENCE s1; diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 13084b08e87..cf91d6d2189 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -302,7 +302,7 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, table_ref->table_name.str, FALSE))) DBUG_RETURN(TRUE); - *hton_can_recreate= ha_check_storage_engine_flag(table->s->db_type(), + *hton_can_recreate= ha_check_storage_engine_flag(table->file->ht, HTON_CAN_RECREATE); table_ref->mdl_request.ticket= table->mdl_ticket; } @@ -428,7 +428,10 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) error= dd_recreate_table(thd, table_ref->db.str, table_ref->table_name.str); if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd, false)) - thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); + { + thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); + error=1; + } /* No need to binlog a failed truncate-by-recreate. */ binlog_stmt= !error; |