mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
A fix and a test case for Bug#24918 drop table and lock / inconsistent
between perm and temp tables. Review fixes. The original bug report complains that if we locked a temporary table with LOCK TABLES statement, we would not leave LOCK TABLES mode when this temporary table is dropped. Additionally, the bug was escalated when it was discovered than when a temporary transactional table that was previously locked with LOCK TABLES statement was dropped, futher actions with this table, such as UNLOCK TABLES, would lead to a crash. The problem originates from incomplete support of transactional temporary tables. When we added calls to handler::store_lock()/handler::external_lock() to operations that work with such tables, we only covered the normal server code flow and did not cover LOCK TABLES mode. In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without matching ::external_lock(UNLOCK), e.g. when a transactional temporary table was dropped. Additionally, this table would be left in the list of LOCKed TABLES. The patch aims to address this inadequacy. Now, whenever an instance of 'handler' is destroyed, we assert that it was priorly external_lock(UNLOCK)-ed. All the places that violate this assert were fixed. This patch introduces no changes in behavior -- the discrepancy in behavior will be fixed when we start calling ::store_lock()/::external_lock() for all tables, regardless whether they are transactional or not, temporary or not.
This commit is contained in:
@ -754,4 +754,38 @@ create table t1 (a int) engine=innodb;
|
||||
alter table t1 alter a set default 1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
--echo
|
||||
--echo Bug#24918 drop table and lock / inconsistent between
|
||||
--echo perm and temp tables
|
||||
--echo
|
||||
--echo Check transactional tables under LOCK TABLES
|
||||
--echo
|
||||
--disable_warnings
|
||||
drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp,
|
||||
t24918_access;
|
||||
--enable_warnings
|
||||
create table t24918_access (id int);
|
||||
create table t24918 (id int) engine=myisam;
|
||||
create temporary table t24918_tmp (id int) engine=myisam;
|
||||
create table t24918_trans (id int) engine=innodb;
|
||||
create temporary table t24918_trans_tmp (id int) engine=innodb;
|
||||
|
||||
lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write;
|
||||
drop table t24918;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
select * from t24918_access;
|
||||
drop table t24918_trans;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
select * from t24918_access;
|
||||
drop table t24918_trans_tmp;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
select * from t24918_access;
|
||||
drop table t24918_tmp;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
select * from t24918_access;
|
||||
unlock tables;
|
||||
|
||||
drop table t24918_access;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user