summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2008-04-08 10:20:58 +0500
committerunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2008-04-08 10:20:58 +0500
commit9fd89afca04400812a8fec6b1802bf60518bd2ac (patch)
tree26ae6d2fe47544933c13ab27096db0b064cf0088 /mysql-test
parentccd31e9dd4ef9ac3266690231626237d13d53e17 (diff)
downloadmariadb-git-9fd89afca04400812a8fec6b1802bf60518bd2ac.tar.gz
Fix for bug #35732: read-only blocks SELECT statements in InnoDB
Problem: SELECTs prohibited for a transactional SE in autocommit mode if read_only is set. Fix: allow them. mysql-test/r/read_only_innodb.result: Fix for bug #35732: read-only blocks SELECT statements in InnoDB - test result. mysql-test/t/read_only_innodb.test: Fix for bug #35732: read-only blocks SELECT statements in InnoDB - test case. sql/handler.cc: Fix for bug #35732: read-only blocks SELECT statements in InnoDB - in autocommit mode thd->transaction.all list is empty thus is_real_trans set to TRUE for any SELECTs, so using it in the "read_only" check is insufficient. ha_check_and_coalesce_trx_read_only() changed to return number of engines with read-write changes. This value is used in the "read-only" check and checks for GLOBAL READ LOCK. sql/lock.cc: Fix for bug #35732: read-only blocks SELECT statements in InnoDB - added assert(protect_against_global_read_lock) before decreasing, in order to catch (uint) 0 - 1 situation due to wrong wait_if_global_read_lock()/start_waiting_global_read_lock() call sequence.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/read_only_innodb.result30
-rw-r--r--mysql-test/t/read_only_innodb.test42
2 files changed, 72 insertions, 0 deletions
diff --git a/mysql-test/r/read_only_innodb.result b/mysql-test/r/read_only_innodb.result
index d028e3cc207..690de085bf9 100644
--- a/mysql-test/r/read_only_innodb.result
+++ b/mysql-test/r/read_only_innodb.result
@@ -16,3 +16,33 @@ ERROR HY000: The MySQL server is running with the --read-only option so it canno
set global read_only=0;
drop table table_11733 ;
drop user test@localhost;
+GRANT CREATE, SELECT, DROP ON *.* TO test@localhost;
+CREATE TABLE t1(a INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES (0), (1);
+SET GLOBAL read_only=1;
+SELECT * FROM t1;
+a
+0
+1
+BEGIN;
+SELECT * FROM t1;
+a
+0
+1
+COMMIT;
+SET GLOBAL read_only=0;
+FLUSH TABLES WITH READ LOCK;
+SELECT * FROM t1;
+a
+0
+1
+BEGIN;
+SELECT * FROM t1;
+a
+0
+1
+COMMIT;
+UNLOCK TABLES;
+DROP TABLE t1;
+DROP USER test@localhost;
+echo End of 5.1 tests
diff --git a/mysql-test/t/read_only_innodb.test b/mysql-test/t/read_only_innodb.test
index 76d9748aa60..f8c25fdee1d 100644
--- a/mysql-test/t/read_only_innodb.test
+++ b/mysql-test/t/read_only_innodb.test
@@ -41,3 +41,45 @@ set global read_only=0;
drop table table_11733 ;
drop user test@localhost;
+disconnect con1;
+
+#
+# Bug #35732: read-only blocks SELECT statements in InnoDB
+#
+# Test 1: read only mode
+GRANT CREATE, SELECT, DROP ON *.* TO test@localhost;
+connect(con1, localhost, test, , test);
+
+connection default;
+CREATE TABLE t1(a INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES (0), (1);
+SET GLOBAL read_only=1;
+
+connection con1;
+SELECT * FROM t1;
+BEGIN;
+SELECT * FROM t1;
+COMMIT;
+
+connection default;
+SET GLOBAL read_only=0;
+
+#
+# Test 2: global read lock
+#
+FLUSH TABLES WITH READ LOCK;
+
+connection con1;
+SELECT * FROM t1;
+BEGIN;
+SELECT * FROM t1;
+COMMIT;
+
+connection default;
+UNLOCK TABLES;
+DROP TABLE t1;
+DROP USER test@localhost;
+
+disconnect con1;
+
+--echo echo End of 5.1 tests