Commit d9e84341 authored by Horst Hunger's avatar Horst Hunger

Reviewed fix for bug#40882: Replaced "sleep 1" by wait_condition, added...

Reviewed fix for bug#40882: Replaced "sleep 1" by wait_condition, added save/restore start values and closed open sessions. When trying to use "wait_for_query_to_succeed" a type has been fixed, also in "rename.test": Added session count and check and replaced error numbers.
parent 5d2a707d
# #
# Run a query over and over until it suceeds ot timeout occurs # Run a query over and over until it succeeds ot timeout occurs
# #
...@@ -17,7 +17,7 @@ while ($mysql_errno) ...@@ -17,7 +17,7 @@ while ($mysql_errno)
if (!$counter) if (!$counter)
{ {
die("Waited too long for query to suceed"); --die "Waited too long for query to succeed";
} }
} }
enable_abort_on_error; enable_abort_on_error;
......
set @start_read_only= @@global.read_only;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
grant CREATE, SELECT, DROP on *.* to test@localhost; grant CREATE, SELECT, DROP on *.* to test@localhost;
connect (con1,localhost,test,,test);
connection default;
set global read_only=0; set global read_only=0;
connection con1;
create table t1 (a int); create table t1 (a int);
insert into t1 values(1); insert into t1 values(1);
create table t2 select * from t1; create table t2 select * from t1;
connection default;
set global read_only=1; set global read_only=1;
create table t3 (a int); create table t3 (a int);
drop table t3; drop table t3;
connection con1;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
1 1
...@@ -39,13 +45,18 @@ delete t1 from t1,t3 where t1.a=t3.a; ...@@ -39,13 +45,18 @@ delete t1 from t1,t3 where t1.a=t3.a;
drop table t1; drop table t1;
insert into t1 values(1); insert into t1 values(1);
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
connection default;
set global read_only=0; set global read_only=0;
lock table t1 write; lock table t1 write;
connection con1;
lock table t2 write; lock table t2 write;
connection default;
set global read_only=1; set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables ; unlock tables ;
send set global read_only=1;
set global read_only=1; set global read_only=1;
connection con1;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
0 0
...@@ -53,13 +64,20 @@ unlock tables ; ...@@ -53,13 +64,20 @@ unlock tables ;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
1 1
connection default;
reap;
connection default;
set global read_only=0; set global read_only=0;
lock table t1 read; lock table t1 read;
connection con1;
lock table t2 read; lock table t2 read;
connection default;
set global read_only=1; set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables ; unlock tables ;
send set global read_only=1;
set global read_only=1; set global read_only=1;
connection con1;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
0 0
...@@ -67,24 +85,35 @@ unlock tables ; ...@@ -67,24 +85,35 @@ unlock tables ;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
1 1
connection default;
reap;
connection default;
set global read_only=0; set global read_only=0;
BEGIN; BEGIN;
connection con1;
BEGIN; BEGIN;
connection default;
set global read_only=1; set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
ROLLBACK; ROLLBACK;
set global read_only=1; set global read_only=1;
connection con1;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
1 1
ROLLBACK; ROLLBACK;
connection default;
set global read_only=0; set global read_only=0;
flush tables with read lock; flush tables with read lock;
set global read_only=1; set global read_only=1;
unlock tables; unlock tables;
connect (root2,localhost,root,,test);
connection default;
set global read_only=0; set global read_only=0;
flush tables with read lock; flush tables with read lock;
connection root2;
set global read_only=1; set global read_only=1;
connection default;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
1 1
...@@ -94,6 +123,7 @@ ERROR 42S02: Unknown table 'ttt' ...@@ -94,6 +123,7 @@ ERROR 42S02: Unknown table 'ttt'
drop temporary table if exists ttt; drop temporary table if exists ttt;
Warnings: Warnings:
Note 1051 Unknown table 'ttt' Note 1051 Unknown table 'ttt'
connection default;
set global read_only=0; set global read_only=0;
drop table t1,t2; drop table t1,t2;
drop user test@localhost; drop user test@localhost;
...@@ -112,16 +142,20 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`; ...@@ -112,16 +142,20 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
create database mysqltest_db1; create database mysqltest_db1;
grant all on mysqltest_db1.* to `mysqltest_u1`@`%`; grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
flush privileges; flush privileges;
connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,MASTER_MYPORT,);
connection con_bug27440;
create database mysqltest_db2; create database mysqltest_db2;
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
show databases like '%mysqltest_db2%'; show databases like '%mysqltest_db2%';
Database (%mysqltest_db2%) Database (%mysqltest_db2%)
drop database mysqltest_db1; drop database mysqltest_db1;
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
disconnect con_bug27440;
connection default;
delete from mysql.user where User like 'mysqltest_%'; delete from mysql.user where User like 'mysqltest_%';
delete from mysql.db where User like 'mysqltest_%'; delete from mysql.db where User like 'mysqltest_%';
delete from mysql.tables_priv where User like 'mysqltest_%'; delete from mysql.tables_priv where User like 'mysqltest_%';
delete from mysql.columns_priv where User like 'mysqltest_%'; delete from mysql.columns_priv where User like 'mysqltest_%';
flush privileges; flush privileges;
drop database mysqltest_db1; drop database mysqltest_db1;
set global read_only=0; set global read_only= @start_read_only;
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
# check that it blocks updates unless they are only on temporary tables. # check that it blocks updates unless they are only on temporary tables.
# should work with embedded server after mysqltest is fixed # should work with embedded server after mysqltest is fixed
-- source include/not_embedded.inc --source include/not_embedded.inc
--source include/count_sessions.inc
set @start_read_only= @@global.read_only;
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
...@@ -13,12 +16,15 @@ DROP TABLE IF EXISTS t1,t2,t3; ...@@ -13,12 +16,15 @@ DROP TABLE IF EXISTS t1,t2,t3;
grant CREATE, SELECT, DROP on *.* to test@localhost; grant CREATE, SELECT, DROP on *.* to test@localhost;
--echo connect (con1,localhost,test,,test);
connect (con1,localhost,test,,test); connect (con1,localhost,test,,test);
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
--echo connection con1;
connection con1; connection con1;
create table t1 (a int); create table t1 (a int);
...@@ -27,6 +33,7 @@ insert into t1 values(1); ...@@ -27,6 +33,7 @@ insert into t1 values(1);
create table t2 select * from t1; create table t2 select * from t1;
--echo connection default;
connection default; connection default;
set global read_only=1; set global read_only=1;
...@@ -36,28 +43,29 @@ set global read_only=1; ...@@ -36,28 +43,29 @@ set global read_only=1;
create table t3 (a int); create table t3 (a int);
drop table t3; drop table t3;
--echo connection con1;
connection con1; connection con1;
select @@global.read_only; select @@global.read_only;
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
create table t3 (a int); create table t3 (a int);
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
insert into t1 values(1); insert into t1 values(1);
# if a statement, after parse stage, looks like it will update a # if a statement, after parse stage, looks like it will update a
# non-temp table, it will be rejected, even if at execution it would # non-temp table, it will be rejected, even if at execution it would
# have turned out that 0 rows would be updated # have turned out that 0 rows would be updated
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
update t1 set a=1 where 1=0; update t1 set a=1 where 1=0;
# multi-update is special (see sql_parse.cc) so we test it # multi-update is special (see sql_parse.cc) so we test it
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
update t1,t2 set t1.a=t2.a+1 where t1.a=t2.a; update t1,t2 set t1.a=t2.a+1 where t1.a=t2.a;
# check multi-delete to be sure # check multi-delete to be sure
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
delete t1,t2 from t1,t2 where t1.a=t2.a; delete t1,t2 from t1,t2 where t1.a=t2.a;
# With temp tables updates should be accepted: # With temp tables updates should be accepted:
...@@ -71,7 +79,7 @@ insert into t3 values(1); ...@@ -71,7 +79,7 @@ insert into t3 values(1);
insert into t4 select * from t3; insert into t4 select * from t3;
# a non-temp table updated: # a non-temp table updated:
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a; update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
# no non-temp table updated (just swapped): # no non-temp table updated (just swapped):
...@@ -79,7 +87,7 @@ update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a; ...@@ -79,7 +87,7 @@ update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;
update t4,t3 set t4.a=t3.a+1 where t4.a=t3.a; update t4,t3 set t4.a=t3.a+1 where t4.a=t3.a;
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
delete t1 from t1,t3 where t1.a=t3.a; delete t1 from t1,t3 where t1.a=t3.a;
delete t3 from t1,t3 where t1.a=t3.a; delete t3 from t1,t3 where t1.a=t3.a;
...@@ -98,7 +106,7 @@ delete t1 from t1,t3 where t1.a=t3.a; ...@@ -98,7 +106,7 @@ delete t1 from t1,t3 where t1.a=t3.a;
drop table t1; drop table t1;
--error 1290 --error ER_OPTION_PREVENTS_STATEMENT
insert into t1 values(1); insert into t1 values(1);
# #
...@@ -109,77 +117,96 @@ insert into t1 values(1); ...@@ -109,77 +117,96 @@ insert into t1 values(1);
# - is an error in the same connection # - is an error in the same connection
# - is ok in a different connection # - is ok in a different connection
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
lock table t1 write; lock table t1 write;
--echo connection con1;
connection con1; connection con1;
lock table t2 write; lock table t2 write;
--echo connection default;
connection default; connection default;
--error ER_LOCK_OR_ACTIVE_TRANSACTION --error ER_LOCK_OR_ACTIVE_TRANSACTION
set global read_only=1; set global read_only=1;
unlock tables ; unlock tables ;
# The following call blocks until con1 releases the write lock. # The following call blocks until con1 releases the write lock.
# Blocking is expected. # Blocking is expected.
--echo send set global read_only=1;
send set global read_only=1; send set global read_only=1;
--echo connection con1;
connection con1; connection con1;
--sleep 1
select @@global.read_only; select @@global.read_only;
unlock tables ; unlock tables ;
--sleep 1 let $wait_condition= SELECT @@global.read_only= 1;
--source include/wait_condition.inc
select @@global.read_only; select @@global.read_only;
--echo connection default;
connection default; connection default;
--echo reap;
reap; reap;
# LOCK TABLE ... READ / READ_ONLY # LOCK TABLE ... READ / READ_ONLY
# - is an error in the same connection # - is an error in the same connection
# - is ok in a different connection # - is ok in a different connection
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
lock table t1 read; lock table t1 read;
--echo connection con1;
connection con1; connection con1;
lock table t2 read; lock table t2 read;
--echo connection default;
connection default; connection default;
--error ER_LOCK_OR_ACTIVE_TRANSACTION --error ER_LOCK_OR_ACTIVE_TRANSACTION
set global read_only=1; set global read_only=1;
unlock tables ; unlock tables ;
# The following call blocks until con1 releases the read lock. # The following call blocks until con1 releases the read lock.
# Blocking is a limitation, and could be improved. # Blocking is a limitation, and could be improved.
--echo send set global read_only=1;
send set global read_only=1; send set global read_only=1;
--echo connection con1;
connection con1; connection con1;
--sleep 1
select @@global.read_only; select @@global.read_only;
unlock tables ; unlock tables ;
--sleep 1 let $wait_condition= SELECT @@global.read_only= 1;
--source include/wait_condition.inc
select @@global.read_only; select @@global.read_only;
--echo connection default;
connection default; connection default;
--echo reap;
reap; reap;
# pending transaction / READ_ONLY # pending transaction / READ_ONLY
# - is an error in the same connection # - is an error in the same connection
# - is ok in a different connection # - is ok in a different connection
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
BEGIN; BEGIN;
--echo connection con1;
connection con1; connection con1;
BEGIN; BEGIN;
--echo connection default;
connection default; connection default;
--error ER_LOCK_OR_ACTIVE_TRANSACTION --error ER_LOCK_OR_ACTIVE_TRANSACTION
set global read_only=1; set global read_only=1;
ROLLBACK; ROLLBACK;
set global read_only=1; set global read_only=1;
--echo connection con1;
connection con1; connection con1;
select @@global.read_only; select @@global.read_only;
ROLLBACK; ROLLBACK;
...@@ -188,21 +215,26 @@ ROLLBACK; ...@@ -188,21 +215,26 @@ ROLLBACK;
# - in the same SUPER connection # - in the same SUPER connection
# - in another SUPER connection # - in another SUPER connection
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
flush tables with read lock; flush tables with read lock;
set global read_only=1; set global read_only=1;
unlock tables; unlock tables;
--echo connect (root2,localhost,root,,test);
connect (root2,localhost,root,,test); connect (root2,localhost,root,,test);
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
flush tables with read lock; flush tables with read lock;
--echo connection root2;
connection root2; connection root2;
set global read_only=1; set global read_only=1;
--echo connection default;
connection default; connection default;
select @@global.read_only; select @@global.read_only;
unlock tables; unlock tables;
...@@ -221,6 +253,7 @@ drop temporary table if exists ttt; ...@@ -221,6 +253,7 @@ drop temporary table if exists ttt;
# #
# Cleanup # Cleanup
# #
--echo connection default;
connection default; connection default;
set global read_only=0; set global read_only=0;
drop table t1,t2; drop table t1,t2;
...@@ -244,14 +277,18 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`; ...@@ -244,14 +277,18 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
create database mysqltest_db1; create database mysqltest_db1;
grant all on mysqltest_db1.* to `mysqltest_u1`@`%`; grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
flush privileges; flush privileges;
--echo connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,MASTER_MYPORT,);
connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,); connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,);
--echo connection con_bug27440;
connection con_bug27440; connection con_bug27440;
--error ER_OPTION_PREVENTS_STATEMENT --error ER_OPTION_PREVENTS_STATEMENT
create database mysqltest_db2; create database mysqltest_db2;
show databases like '%mysqltest_db2%'; show databases like '%mysqltest_db2%';
--error ER_OPTION_PREVENTS_STATEMENT --error ER_OPTION_PREVENTS_STATEMENT
drop database mysqltest_db1; drop database mysqltest_db1;
--echo disconnect con_bug27440;
disconnect con_bug27440; disconnect con_bug27440;
--echo connection default;
connection default; connection default;
delete from mysql.user where User like 'mysqltest_%'; delete from mysql.user where User like 'mysqltest_%';
delete from mysql.db where User like 'mysqltest_%'; delete from mysql.db where User like 'mysqltest_%';
...@@ -259,4 +296,8 @@ delete from mysql.tables_priv where User like 'mysqltest_%'; ...@@ -259,4 +296,8 @@ delete from mysql.tables_priv where User like 'mysqltest_%';
delete from mysql.columns_priv where User like 'mysqltest_%'; delete from mysql.columns_priv where User like 'mysqltest_%';
flush privileges; flush privileges;
drop database mysqltest_db1; drop database mysqltest_db1;
set global read_only=0; set global read_only= @start_read_only;
disconnect con1;
disconnect root2;
--source include/wait_until_count_sessions.inc
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# Test of rename table # Test of rename table
# #
--source include/count_sessions.inc
--disable_warnings --disable_warnings
drop table if exists t0,t1,t2,t3,t4; drop table if exists t0,t1,t2,t3,t4;
# Clear up from other tests (to ensure that SHOW TABLES below is right) # Clear up from other tests (to ensure that SHOW TABLES below is right)
...@@ -19,16 +21,16 @@ rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1; ...@@ -19,16 +21,16 @@ rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
select * from t1; select * from t1;
# The following should give errors # The following should give errors
--error 1050,1050 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t1 to t2; rename table t1 to t2;
--error 1050,1050 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t1 to t1; rename table t1 to t1;
--error 1050,1050 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2; rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2;
show tables like "t_"; show tables like "t_";
--error 1050,1050 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1; rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1;
--error 1017,1017 --error ER_FILE_NOT_FOUND,ER_FILE_NOT_FOUND
rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1; rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
select * from t1; select * from t1;
...@@ -63,7 +65,7 @@ connection con2; ...@@ -63,7 +65,7 @@ connection con2;
# Wait for the the tables to be renamed # Wait for the the tables to be renamed
# i.e the query below succeds # i.e the query below succeds
let $query= select * from t2, t4; let $query= select * from t2, t4;
source include/wait_for_query_to_suceed.inc; source include/wait_for_query_to_succeed.inc;
show tables; show tables;
...@@ -83,13 +85,15 @@ connection default; ...@@ -83,13 +85,15 @@ connection default;
create table t1(f1 int); create table t1(f1 int);
create view v1 as select * from t1; create view v1 as select * from t1;
alter table v1 rename to v2; alter table v1 rename to v2;
--error 1146 --error ER_NO_SUCH_TABLE
alter table v1 rename to v2; alter table v1 rename to v2;
rename table v2 to v1; rename table v2 to v1;
--error 1050 --error ER_TABLE_EXISTS_ERROR
rename table v2 to v1; rename table v2 to v1;
drop view v1; drop view v1;
drop table t1; drop table t1;
--echo End of 5.0 tests --echo End of 5.0 tests
--source include/wait_until_count_sessions.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment