From 140cc614c944154282fce87064f5e3552406a14c Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Tue, 3 Mar 2009 21:34:18 +0100 Subject: Last slice of fix for Bug#42003 tests missing the disconnect of connections <> default + Fix for Bug#43114 wait_until_count_sessions too restrictive, random PB failures + Removal of a lot of other weaknesses found + modifications according to review --- mysql-test/include/wait_until_count_sessions.inc | 33 +- mysql-test/r/consistent_snapshot.result | 32 +- mysql-test/r/dirty_close.result | 10 +- mysql-test/r/flush_block_commit.result | 74 +- mysql-test/r/flush_block_commit_notembedded.result | 30 +- mysql-test/r/flush_read_lock_kill.result | 17 +- mysql-test/r/lock_multi.result | 8 +- mysql-test/r/mysqlbinlog.result | 16 +- mysql-test/r/read_only.result | 2 +- mysql-test/r/show_check.result | 6 +- mysql-test/r/skip_name_resolve.result | 6 +- mysql-test/r/sp-security.result | 16 +- mysql-test/r/view.result | 66 +- mysql-test/r/view_grant.result | 4 +- mysql-test/t/alter_table-big.test | 7 +- mysql-test/t/connect.test | 42 +- mysql-test/t/consistent_snapshot.test | 44 +- mysql-test/t/dirty_close.test | 21 +- mysql-test/t/flush_block_commit.test | 96 ++- mysql-test/t/flush_block_commit_notembedded.test | 47 +- mysql-test/t/flush_read_lock_kill.test | 35 +- mysql-test/t/init_connect.test | 10 +- mysql-test/t/lock_multi.test | 201 +++-- mysql-test/t/mysqlbinlog.test | 41 +- mysql-test/t/mysqltest.test | 25 +- mysql-test/t/read_only.test | 28 +- mysql-test/t/show_check.test | 73 +- mysql-test/t/skip_name_resolve.test | 9 +- mysql-test/t/sp-security.test | 59 +- mysql-test/t/sp_notembedded.test | 40 +- mysql-test/t/ssl-big.test | 28 +- mysql-test/t/ssl.test | 8 + mysql-test/t/ssl_compress.test | 10 + mysql-test/t/status.test | 7 + mysql-test/t/user_limits.test | 41 +- mysql-test/t/view.test | 837 ++++++++++++--------- mysql-test/t/view_grant.test | 196 ++--- mysql-test/t/wait_timeout.test | 5 +- mysql-test/t/xa.test | 28 +- 39 files changed, 1354 insertions(+), 904 deletions(-) diff --git a/mysql-test/include/wait_until_count_sessions.inc b/mysql-test/include/wait_until_count_sessions.inc index 41348bee129..6364ac95ada 100644 --- a/mysql-test/include/wait_until_count_sessions.inc +++ b/mysql-test/include/wait_until_count_sessions.inc @@ -2,14 +2,23 @@ # # SUMMARY # -# Waits until the passed number ($count_sessions) of concurrent sessions was -# observed via +# Waits until the passed number ($count_sessions) of concurrent sessions or +# a smaller number was observed via # SHOW STATUS LIKE 'Threads_connected' # or the operation times out. -# Note: Starting with 5.1 we could also use -# SELECT COUNT(*) FROM information_schema.processlist -# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this -# runs in all versions 5.0+ +# Note: +# 1. We wait for $current_sessions <= $count_sessions because in the use case +# with count_sessions.inc before and wait_until_count_sessions.inc after +# the core of the test it could happen that the disconnects of sessions +# belonging to the preceeding test are not finished. +# sessions at test begin($count_sessions) = m + n +# sessions of the previous test which will be soon disconnected = n (n >= 0) +# sessions at test end ($current sessions, assuming the test disconnects +# all additional sessions) = m +# 2. Starting with 5.1 we could also use +# SELECT COUNT(*) FROM information_schema.processlist +# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this +# runs in all versions 5.0+ # # # USAGE @@ -19,7 +28,7 @@ # # OR typical example of a test which uses more than one session # Such a test could harm successing tests if there is no server shutdown -# and start between.cw +# and start between. # # If the testing box is slow than the disconnect of sessions belonging to # the current test might happen when the successing test gets executed. @@ -79,7 +88,11 @@ # backup.test, grant3.test # # -# Created: 2009-01-14 mleich +# Created: +# 2009-01-14 mleich +# Modified: +# 2009-02-24 mleich Fix Bug#43114 wait_until_count_sessions too restrictive, +# random PB failures # let $wait_counter= 100; @@ -93,7 +106,7 @@ let $wait_timeout= 0; while ($wait_counter) { let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1); - let $success= `SELECT $current_sessions = $count_sessions`; + let $success= `SELECT $current_sessions <= $count_sessions`; if ($success) { let $wait_counter= 0; @@ -107,7 +120,7 @@ while ($wait_counter) if (!$success) { --echo # Timeout in wait_until_count_sessions.inc - --echo # Number of sessions expected: $count_sessions found: $current_sessions + --echo # Number of sessions expected: < $count_sessions found: $current_sessions SHOW PROCESSLIST; } diff --git a/mysql-test/r/consistent_snapshot.result b/mysql-test/r/consistent_snapshot.result index 90606abbe4e..694c996a58e 100644 --- a/mysql-test/r/consistent_snapshot.result +++ b/mysql-test/r/consistent_snapshot.result @@ -1,15 +1,23 @@ -drop table if exists t1; -create table t1 (a int) engine=innodb; -start transaction with consistent snapshot; -insert into t1 values(1); -select * from t1; +DROP TABLE IF EXISTS t1; +# Establish connection con1 (user=root) +# Establish connection con2 (user=root) +# Switch to connection con1 +CREATE TABLE t1 (a INT) ENGINE=innodb; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +# Switch to connection con2 +INSERT INTO t1 VALUES(1); +# Switch to connection con1 +SELECT * FROM t1; a -commit; -delete from t1; -start transaction; -insert into t1 values(1); -select * from t1; +COMMIT; +DELETE FROM t1; +START TRANSACTION; +# Switch to connection con2 +INSERT INTO t1 VALUES(1); +# Switch to connection con1 +SELECT * FROM t1; a 1 -commit; -drop table t1; +COMMIT; +# Switch to connection default + close connections con1 and con2 +DROP TABLE t1; diff --git a/mysql-test/r/dirty_close.result b/mysql-test/r/dirty_close.result index c4fc19a35f8..b49b72f1b95 100644 --- a/mysql-test/r/dirty_close.result +++ b/mysql-test/r/dirty_close.result @@ -1,9 +1,9 @@ -drop table if exists t1; -create table t1 (n int); -insert into t1 values (1),(2),(3); -select * from t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (n INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT * FROM t1; n 1 2 3 -drop table t1; +DROP TABLE t1; diff --git a/mysql-test/r/flush_block_commit.result b/mysql-test/r/flush_block_commit.result index d5b10868358..d2197beaaab 100644 --- a/mysql-test/r/flush_block_commit.result +++ b/mysql-test/r/flush_block_commit.result @@ -1,39 +1,57 @@ -drop table if exists t1; -create table t1 (a int) engine=innodb; -begin; -insert into t1 values(1); -flush tables with read lock; -select * from t1; +# Establish connection con1 (user=root) +# Establish connection con2 (user=root) +# Establish connection con3 (user=root) +# Switch to connection con1 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT) ENGINE=innodb; +BEGIN; +INSERT INTO t1 VALUES(1); +# Switch to connection con2 +FLUSH TABLES WITH READ LOCK; +SELECT * FROM t1; a -commit; -select * from t1; +# Switch to connection con1 +COMMIT; +# Switch to connection con2 +SELECT * FROM t1; a -unlock tables; -begin; -select * from t1 for update; +UNLOCK TABLES; +# Switch to connection con1 +# Switch to connection con1 +BEGIN; +SELECT * FROM t1 FOR UPDATE; a 1 -begin; -select * from t1 for update; -flush tables with read lock; -commit; +# Switch to connection con2 +BEGIN; +SELECT * FROM t1 FOR UPDATE; +# Switch to connection con3 +FLUSH TABLES WITH READ LOCK; +# Switch to connection con1 +COMMIT; +# Switch to connection con2 a 1 -unlock tables; -commit; -begin; -insert into t1 values(10); -flush tables with read lock; -commit; -unlock tables; -flush tables with read lock; -unlock tables; -begin; -select * from t1; +# Switch to connection con3 +UNLOCK TABLES; +# Switch to connection con2 +COMMIT; +# Switch to connection con1 +BEGIN; +INSERT INTO t1 VALUES(10); +FLUSH TABLES WITH READ LOCK; +COMMIT; +UNLOCK TABLES; +# Switch to connection con2 +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +BEGIN; +SELECT * FROM t1; a 1 10 -show create database test; +SHOW CREATE DATABASE test; Database Create Database test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */ -drop table t1; +DROP TABLE t1; +# Switch to connection default and close connections con1, con2, con3 diff --git a/mysql-test/r/flush_block_commit_notembedded.result b/mysql-test/r/flush_block_commit_notembedded.result index 599efeb3e2d..76c55e948dd 100644 --- a/mysql-test/r/flush_block_commit_notembedded.result +++ b/mysql-test/r/flush_block_commit_notembedded.result @@ -1,15 +1,23 @@ -create table t1 (a int) engine=innodb; -reset master; -set autocommit=0; -insert t1 values (1); -flush tables with read lock; -show master status; +# Establish connection con1 (user=root) +# Establish connection con2 (user=root) +# Switch to connection con1 +CREATE TABLE t1 (a INT) ENGINE=innodb; +RESET MASTER; +SET AUTOCOMMIT=0; +INSERT t1 VALUES (1); +# Switch to connection con2 +FLUSH TABLES WITH READ LOCK; +SHOW MASTER STATUS; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 98 -commit; -show master status; +# Switch to connection con1 +COMMIT; +# Switch to connection con2 +SHOW MASTER STATUS; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 98 -unlock tables; -drop table t1; -set autocommit=1; +UNLOCK TABLES; +# Switch to connection con1 +DROP TABLE t1; +SET AUTOCOMMIT=1; +# Switch to connection default and close connections con1 and con2 diff --git a/mysql-test/r/flush_read_lock_kill.result b/mysql-test/r/flush_read_lock_kill.result index 6703b6bd533..b16a8b114b3 100644 --- a/mysql-test/r/flush_read_lock_kill.result +++ b/mysql-test/r/flush_read_lock_kill.result @@ -1,9 +1,12 @@ -drop table if exists t1; -create table t1 (kill_id int); -insert into t1 values(connection_id()); -flush tables with read lock; -select ((@id := kill_id) - kill_id) from t1; +SET @old_concurrent_insert= @@global.concurrent_insert; +SET @@global.concurrent_insert= 0; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (kill_id INT); +INSERT INTO t1 VALUES(connection_id()); +FLUSH TABLES WITH READ LOCK; +SELECT ((@id := kill_id) - kill_id) FROM t1; ((@id := kill_id) - kill_id) 0 -kill connection @id; -drop table t1; +KILL CONNECTION @id; +DROP TABLE t1; +SET @@global.concurrent_insert= @old_concurrent_insert; diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index 0430d560a7a..d1b50a0080c 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -51,10 +51,10 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock UNLOCK TABLES; DROP DATABASE mysqltest_1; ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist -use mysql; +USE mysql; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; FLUSH TABLES; -use mysql; +USE mysql; SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; OPTIMIZE TABLES columns_priv, db, host, user; Table Op Msg_type Msg_text @@ -65,7 +65,7 @@ mysql.user optimize status OK UNLOCK TABLES; Select_priv N -use test; +USE test; use test; CREATE TABLE t1 (c1 int); LOCK TABLE t1 WRITE; @@ -93,7 +93,7 @@ create table t1 (a int); connection: locker lock tables t1 read; connection: writer -create table t2 like t1;; +create table t2 like t1; connection: default kill query ERROR 70100: Query execution was interrupted diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 4fd87861ded..83e1459b71a 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -349,17 +349,17 @@ DELIMITER ; ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; CREATE TABLE t1 (c1 CHAR(10)); -flush logs; +FLUSH LOGS; INSERT INTO t1 VALUES ('0123456789'); -flush logs; +FLUSH LOGS; DROP TABLE t1; # Query thread_id=REMOVED exec_time=REMOVED error_code=REMOVED -flush logs; -create table t1(a int); -insert into t1 values(connection_id()); -flush logs; -drop table t1; +FLUSH LOGS; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(connection_id()); +FLUSH LOGS; +DROP TABLE t1; 1 -drop table t1; +DROP TABLE t1; shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql End of 5.0 tests diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result index 1bf99a8ea07..4b405ddd71a 100644 --- a/mysql-test/r/read_only.result +++ b/mysql-test/r/read_only.result @@ -47,7 +47,7 @@ Note 1051 Unknown table 'ttt' drop table t1,t2; drop user test@localhost; # -# Bug #27440 read_only allows create and drop database +# Bug#27440 read_only allows create and drop database # drop database if exists mysqltest_db1; drop database if exists mysqltest_db2; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index ad3138e80ea..70e7a95fc5b 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -507,9 +507,9 @@ ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql drop table mysqltest.t1; drop database mysqltest; set names binary; -delete from mysql.user +delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; -delete from mysql.db +delete from mysql.db where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; flush privileges; CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY; @@ -916,7 +916,7 @@ def TRIGGERS DEFINER Definer 252 589815 14 N 17 0 33 Trigger Event Table Statement Timing Created sql_mode Definer t1_bi INSERT t1 SET @a = 1 BEFORE NULL root@localhost ---------------------------------------------------------------- -SELECT +SELECT TRIGGER_CATALOG, TRIGGER_SCHEMA, TRIGGER_NAME, diff --git a/mysql-test/r/skip_name_resolve.result b/mysql-test/r/skip_name_resolve.result index 8ef52e75238..47741fed250 100644 --- a/mysql-test/r/skip_name_resolve.result +++ b/mysql-test/r/skip_name_resolve.result @@ -5,10 +5,10 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255' GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255' REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255'; DROP USER mysqltest_1@'127.0.0.1/255.255.255.255'; -select user(); -user() +SELECT USER(); +USER() # -show processlist; +SHOW PROCESSLIST; Id User Host db Command Time State Info root test