1DROP TABLE IF EXISTS t1 ;
2# READ_ONLY does nothing to SUPER users
3# so we use a non-SUPER one:
4GRANT CREATE, SELECT, DROP ON *.* TO test@localhost;
5connect  con1,localhost,test,,test;
6connection default;
7SET GLOBAL READ_ONLY=1;
8connection con1;
9CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB;
10# Test INSERTS with autocommit being off and on.
11BEGIN;
12INSERT INTO t1 VALUES (10);
13COMMIT;
14INSERT INTO t1 VALUES (20);
15# Test UPDATES with autocommit being off and on.
16BEGIN;
17UPDATE t1 SET a=30 WHERE a=10;
18COMMIT;
19UPDATE t1 SET a=40 WHERE a=20;
20connection default;
21SET GLOBAL READ_ONLY=0;
22# Test scenario where global read_only is enabled in the middle of transaction.
23# Test INSERT operations on temporary tables, INSERTs should be successful even
24# when global read_only is enabled.
25connection con1;
26BEGIN;
27INSERT INTO t1 VALUES(50);
28connection default;
29SET GLOBAL READ_ONLY=1;
30connection con1;
31SELECT @@GLOBAL.READ_ONLY;
32@@GLOBAL.READ_ONLY
331
34COMMIT;
35connection default;
36SET GLOBAL READ_ONLY=0;
37# Test UPDATE operations on temporary tables, UPDATEs should be successful even
38# when global read_only is enabled.
39connection con1;
40BEGIN;
41UPDATE t1 SET a=60 WHERE a=50;
42connection default;
43SET GLOBAL READ_ONLY=1;
44connection con1;
45SELECT @@GLOBAL.READ_ONLY;
46@@GLOBAL.READ_ONLY
471
48COMMIT;
49SELECT * FROM t1;
50a
5130
5240
5360
54# Clean up
55connection default;
56SET GLOBAL READ_ONLY=0;
57disconnect con1;
58DROP USER test@localhost;
59