2003-01-06 00:48:59 +01:00
|
|
|
# Initialise
|
|
|
|
--disable_warnings
|
2001-03-27 19:23:04 +02:00
|
|
|
drop table if exists t1;
|
2003-08-18 23:08:08 +02:00
|
|
|
drop database if exists mysqltest;
|
2004-12-31 11:04:35 +01:00
|
|
|
# If earlier test failed
|
|
|
|
drop database if exists client_test_db;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
|
|
|
|
2005-08-31 17:16:05 +02:00
|
|
|
--error 1051
|
2001-03-27 19:23:04 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1(n int);
|
|
|
|
insert into t1 values(1);
|
|
|
|
create temporary table t1( n int);
|
|
|
|
insert into t1 values(2);
|
2005-08-31 17:16:05 +02:00
|
|
|
--error 1050
|
2001-03-27 19:23:04 +02:00
|
|
|
create table t1(n int);
|
|
|
|
drop table t1;
|
|
|
|
select * from t1;
|
2001-06-22 00:48:18 +02:00
|
|
|
|
2001-12-22 14:13:31 +01:00
|
|
|
# now test for a bug in drop database - it is important that the name
|
|
|
|
# of the table is the same as the name of the database - in the original
|
|
|
|
# code this triggered a bug
|
|
|
|
create database mysqltest;
|
|
|
|
drop database if exists mysqltest;
|
|
|
|
create database mysqltest;
|
|
|
|
create table mysqltest.mysqltest (n int);
|
|
|
|
insert into mysqltest.mysqltest values (4);
|
|
|
|
select * from mysqltest.mysqltest;
|
2004-03-18 11:03:24 +01:00
|
|
|
--enable_info
|
2001-12-22 14:13:31 +01:00
|
|
|
drop database if exists mysqltest;
|
2004-03-18 11:03:24 +01:00
|
|
|
--disable_info
|
2001-12-22 14:13:31 +01:00
|
|
|
create database mysqltest;
|
2005-04-02 20:13:19 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# drop many tables - bug#3891
|
|
|
|
# we'll do it in mysqltest db, to be able to use longer table names
|
|
|
|
# (tableN instead on tN)
|
|
|
|
#
|
|
|
|
use mysqltest;
|
|
|
|
--error 1051
|
|
|
|
drop table table1, table2, table3, table4, table5, table6,
|
|
|
|
table7, table8, table9, table10, table11, table12, table13,
|
|
|
|
table14, table15, table16, table17, table18, table19, table20,
|
|
|
|
table21, table22, table23, table24, table25, table26, table27,
|
|
|
|
table28;
|
|
|
|
|
|
|
|
--error 1051
|
|
|
|
drop table table1, table2, table3, table4, table5, table6,
|
|
|
|
table7, table8, table9, table10, table11, table12, table13,
|
|
|
|
table14, table15, table16, table17, table18, table19, table20,
|
|
|
|
table21, table22, table23, table24, table25, table26, table27,
|
|
|
|
table28, table29, table30;
|
|
|
|
|
|
|
|
use test;
|
2001-12-22 14:13:31 +01:00
|
|
|
drop database mysqltest;
|
2001-06-22 00:48:18 +02:00
|
|
|
|
|
|
|
# test drop/create database and FLUSH TABLES WITH READ LOCK
|
2001-06-21 23:59:51 +02:00
|
|
|
flush tables with read lock;
|
2005-08-31 17:16:05 +02:00
|
|
|
--error 1209,1223
|
2001-12-22 14:13:31 +01:00
|
|
|
create database mysqltest;
|
2001-06-21 23:59:51 +02:00
|
|
|
unlock tables;
|
2001-12-22 14:13:31 +01:00
|
|
|
create database mysqltest;
|
2001-06-21 23:59:51 +02:00
|
|
|
show databases;
|
|
|
|
flush tables with read lock;
|
2005-08-31 17:16:05 +02:00
|
|
|
--error 1208,1223
|
2001-12-22 14:13:31 +01:00
|
|
|
drop database mysqltest;
|
2001-06-21 23:59:51 +02:00
|
|
|
unlock tables;
|
2001-12-22 14:13:31 +01:00
|
|
|
drop database mysqltest;
|
2001-06-21 23:59:51 +02:00
|
|
|
show databases;
|
2001-09-03 04:16:15 +02:00
|
|
|
--error 1008
|
2001-12-22 14:13:31 +01:00
|
|
|
drop database mysqltest;
|
2003-08-27 15:03:39 +02:00
|
|
|
|
|
|
|
# test create table and FLUSH TABLES WITH READ LOCK
|
|
|
|
drop table t1;
|
|
|
|
flush tables with read lock;
|
2005-08-31 17:16:05 +02:00
|
|
|
--error 1223
|
2003-08-27 15:03:39 +02:00
|
|
|
create table t1(n int);
|
|
|
|
unlock tables;
|
|
|
|
create table t1(n int);
|
|
|
|
show tables;
|
|
|
|
drop table t1;
|
2005-07-28 02:22:47 +02:00
|
|
|
|
|
|
|
# End of 4.1 tests
|
2006-08-21 10:18:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes
|
|
|
|
# server to crash". Crash (caused by failed assertion in 5.0 or by null
|
|
|
|
# pointer dereference in 5.1) happened when one ran SHOW OPEN TABLES
|
|
|
|
# while concurrently doing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE
|
|
|
|
# or any other command that takes name-lock) in other connection.
|
|
|
|
#
|
|
|
|
# Also includes test for similar bug#12212 "Crash that happens during
|
|
|
|
# removing of database name from cache" reappeared in 5.1 as bug#19403
|
|
|
|
# In its case crash happened when one concurrently executed DROP DATABASE
|
|
|
|
# and one of name-locking command.
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop database if exists mysqltest;
|
|
|
|
drop table if exists t1;
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (i int);
|
|
|
|
create database mysqltest;
|
2010-01-12 16:15:21 +01:00
|
|
|
lock tables t1 read;
|
2006-08-21 10:18:59 +02:00
|
|
|
connect (addconroot1, localhost, root,,);
|
|
|
|
--send drop table t1
|
|
|
|
connect (addconroot2, localhost, root,,);
|
|
|
|
# Server should not crash in any of the following statements
|
|
|
|
--disable_result_log
|
|
|
|
show open tables;
|
|
|
|
--enable_result_log
|
|
|
|
--send drop database mysqltest
|
|
|
|
connection default;
|
|
|
|
select 1;
|
|
|
|
unlock tables;
|
|
|
|
connection addconroot1;
|
|
|
|
--reap
|
|
|
|
connection addconroot2;
|
|
|
|
--reap
|
|
|
|
disconnect addconroot2;
|
2009-05-15 12:15:56 +02:00
|
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
connection addconroot1;
|
|
|
|
disconnect addconroot1;
|
|
|
|
--source include/wait_until_disconnected.inc
|
2006-08-21 10:18:59 +02:00
|
|
|
connection default;
|
|
|
|
|
Backport of:
------------------------------------------------------------
revno: 2476.784.3
committer: davi@moksha.local
timestamp: Tue 2007-10-02 21:27:31 -0300
message:
Bug#25858 Some DROP TABLE under LOCK TABLES can cause deadlocks
When a client (connection) holds a lock on a table and attempts to
drop (obtain a exclusive lock) on a second table that is already
held by a second client and the second client then attempts to
drop the table that is held by the first client, leads to a
circular wait deadlock. This scenario is very similar to trying to
drop (or rename) a table while holding read locks and are
correctly forbidden.
The solution is to allow a drop table operation to continue only
if the table being dropped is write (exclusively) locked, or if
the table is temporary, or if the client is not holding any
locks. Using this scheme prevents the creation of a circular
chain in which each client is waiting for one table that the
next client in the chain is holding.
This is incompatible change, as can be seen by number of tests
cases that needed to be fixed, but is consistent with respect to
behavior of the different scenarios in which the circular wait
might happen.
mysql-test/r/drop.result:
Test case result for Bug#25858
mysql-test/r/group_by.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/insert_notembedded.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table
mysql-test/r/lock.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/lock_multi.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/myisam.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/view.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/t/drop.test:
Add test case for Bug#25858
mysql-test/t/group_by.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/insert_notembedded.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/lock.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/lock_multi.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/myisam.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/query_cache_notembedded.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/view.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
sql/lock.cc:
When trying to obtain a name lock under lock tables, ensure that the table is properly exclusively locked and fail otherwise.
2009-11-20 20:51:12 +01:00
|
|
|
#
|
|
|
|
# Bug#25858 Some DROP TABLE under LOCK TABLES can cause deadlocks
|
|
|
|
#
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1,t2;
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (a int);
|
|
|
|
create table t2 (a int);
|
|
|
|
lock table t1 read;
|
|
|
|
--error ER_TABLE_NOT_LOCKED
|
|
|
|
drop table t2;
|
|
|
|
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
|
|
|
drop table t1;
|
|
|
|
unlock tables;
|
|
|
|
drop table t1,t2;
|
|
|
|
connect (addconroot, localhost, root,,);
|
|
|
|
connection default;
|
|
|
|
create table t1 (i int);
|
|
|
|
create table t2 (i int);
|
|
|
|
lock tables t1 read;
|
|
|
|
connection addconroot;
|
|
|
|
lock tables t2 read;
|
|
|
|
--error ER_TABLE_NOT_LOCKED
|
|
|
|
drop table t1;
|
|
|
|
connection default;
|
|
|
|
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
|
|
|
drop table t1,t2;
|
|
|
|
disconnect addconroot;
|
|
|
|
connection default;
|
|
|
|
unlock tables;
|
|
|
|
drop table t1,t2;
|
|
|
|
|
2006-08-21 10:18:59 +02:00
|
|
|
--echo End of 5.0 tests
|
2007-11-23 15:21:24 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#30152 MySQLD crash duing alter table causes DROP DATABASE to FAIL due to temp file
|
|
|
|
#
|
|
|
|
create database mysql_test;
|
|
|
|
create table mysql_test.t1(f1 int);
|
|
|
|
create table mysql_test.`#sql-347f_7` (f1 int);
|
|
|
|
create table mysql_test.`#sql-347f_8` (f1 int);
|
|
|
|
drop table mysql_test.`#sql-347f_8`;
|
2008-02-28 18:55:46 +01:00
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
|
|
copy_file $MYSQLD_DATADIR/mysql_test/t1.frm $MYSQLD_DATADIR/mysql_test/#sql-347f_6.frm;
|
2007-11-23 15:21:24 +01:00
|
|
|
drop database mysql_test;
|
|
|
|
|
2008-03-20 09:36:35 +01:00
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # --
|
|
|
|
--echo # -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not
|
|
|
|
--echo # -- exist.
|
|
|
|
--echo # --
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP DATABASE IF EXISTS mysql_test;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE DATABASE mysql_test;
|
|
|
|
|
2008-04-03 21:40:10 +02:00
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
2009-03-04 13:45:49 +01:00
|
|
|
|
|
|
|
--let $proc_frm = $MYSQLD_DATADIR/mysql/proc.frm
|
|
|
|
--let $proc_MYD = $MYSQLD_DATADIR/mysql/proc.MYD
|
|
|
|
--let $proc_MYI = $MYSQLD_DATADIR/mysql/proc.MYI
|
|
|
|
|
|
|
|
--let $copy_of_proc_frm = $MYSQLTEST_VARDIR/tmp/bug29958.copy.frm
|
|
|
|
--let $copy_of_proc_MYD = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYD
|
|
|
|
--let $copy_of_proc_MYI = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYI
|
|
|
|
|
|
|
|
--copy_file $proc_frm $copy_of_proc_frm
|
|
|
|
--copy_file $proc_MYD $copy_of_proc_MYD
|
|
|
|
--copy_file $proc_MYI $copy_of_proc_MYI
|
2008-03-20 09:36:35 +01:00
|
|
|
|
|
|
|
DROP TABLE mysql.proc;
|
|
|
|
|
|
|
|
DROP DATABASE mysql_test;
|
|
|
|
|
2009-03-04 13:45:49 +01:00
|
|
|
--copy_file $copy_of_proc_frm $proc_frm
|
|
|
|
--copy_file $copy_of_proc_MYD $proc_MYD
|
|
|
|
--copy_file $copy_of_proc_MYI $proc_MYI
|
|
|
|
|
|
|
|
--remove_file $copy_of_proc_frm
|
|
|
|
--remove_file $copy_of_proc_MYD
|
|
|
|
--remove_file $copy_of_proc_MYI
|
2008-03-20 09:36:35 +01:00
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # --
|
|
|
|
--echo # -- End of Bug#29958.
|
|
|
|
--echo # --
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
--echo
|
2008-03-12 17:40:12 +01:00
|
|
|
#
|
|
|
|
# Bug#26703: DROP DATABASE fails if database contains a #mysql50# table with backticks
|
|
|
|
#
|
|
|
|
create database mysqltestbug26703;
|
|
|
|
use mysqltestbug26703;
|
|
|
|
create table `#mysql50#abc``def` ( id int );
|
|
|
|
--error ER_WRONG_TABLE_NAME
|
|
|
|
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
|
|
|
|
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
|
2010-09-03 18:20:30 +02:00
|
|
|
create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234` (a int);
|
2008-03-12 17:40:12 +01:00
|
|
|
--error ER_WRONG_TABLE_NAME
|
2010-09-03 18:20:30 +02:00
|
|
|
create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345` (a int);
|
|
|
|
show tables;
|
2008-03-12 17:40:12 +01:00
|
|
|
use test;
|
|
|
|
drop database mysqltestbug26703;
|
|
|
|
|
2007-11-23 15:21:24 +01:00
|
|
|
--echo End of 5.1 tests
|
2009-10-22 20:22:53 +02:00
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # --
|
|
|
|
--echo # -- Bug#37431 (DROP TABLE does not report errors correctly).
|
|
|
|
--echo # --
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
--error ER_BAD_TABLE_ERROR
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
SHOW WARNINGS;
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # --
|
|
|
|
--echo # -- End of Bug#37431.
|
|
|
|
--echo # --
|
2010-06-07 17:27:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug#54282 Crash in MDL_context::upgrade_shared_lock_to_exclusive
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a INT);
|
|
|
|
LOCK TABLE t1 WRITE;
|
|
|
|
--error ER_NONUNIQ_TABLE
|
|
|
|
DROP TABLE t1, t1;
|
|
|
|
|
|
|
|
UNLOCK TABLES;
|
|
|
|
DROP TABLE t1;
|