|
| 1 | +# ==== Purpose ==== |
| 2 | +# |
| 3 | +# Check that DMLs are allowed on temporary tables, when server is in read only |
| 4 | +# mode and binary log is enabled with binlog-format being stmt/mixed mode. |
| 5 | +# |
| 6 | +# ==== Implementation ==== |
| 7 | +# |
| 8 | +# Start the server with binary log being enabled. Mark the server as read only. |
| 9 | +# Create a non-SUPER user and let the user to create a temporary table and |
| 10 | +# perform DML operations on that temporary table. DMLs should not be blocked |
| 11 | +# with a 'server read-only mode' error. |
| 12 | +# |
| 13 | +# ==== References ==== |
| 14 | +# |
| 15 | +# Bug#12818255: READ-ONLY OPTION DOES NOT ALLOW INSERTS/UPDATES ON TEMPORARY |
| 16 | +# TABLES |
| 17 | +# Bug#14294223: CHANGES NOT ALLOWED TO TEMPORARY TABLES ON READ-ONLY SERVERS |
| 18 | +############################################################################### |
| 19 | +--source include/have_log_bin.inc |
| 20 | +--disable_warnings |
| 21 | +DROP TABLE IF EXISTS t1 ; |
| 22 | +--enable_warnings |
| 23 | + |
| 24 | +--enable_connect_log |
| 25 | +--echo # READ_ONLY does nothing to SUPER users |
| 26 | +--echo # so we use a non-SUPER one: |
| 27 | +GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; |
| 28 | + |
| 29 | +connect (con1,localhost,test,,test); |
| 30 | + |
| 31 | +connection default; |
| 32 | +SET GLOBAL READ_ONLY=1; |
| 33 | + |
| 34 | +connection con1; |
| 35 | +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB; |
| 36 | + |
| 37 | +--echo # Test INSERTS with autocommit being off and on. |
| 38 | +BEGIN; |
| 39 | +INSERT INTO t1 VALUES (10); |
| 40 | +COMMIT; |
| 41 | +INSERT INTO t1 VALUES (20); |
| 42 | + |
| 43 | +--echo # Test UPDATES with autocommit being off and on. |
| 44 | +BEGIN; |
| 45 | +UPDATE t1 SET a=30 WHERE a=10; |
| 46 | +COMMIT; |
| 47 | +UPDATE t1 SET a=40 WHERE a=20; |
| 48 | + |
| 49 | +connection default; |
| 50 | +SET GLOBAL READ_ONLY=0; |
| 51 | + |
| 52 | +--echo # Test scenario where global read_only is enabled in the middle of transaction. |
| 53 | +--echo # Test INSERT operations on temporary tables, INSERTs should be successful even |
| 54 | +--echo # when global read_only is enabled. |
| 55 | +connection con1; |
| 56 | +BEGIN; |
| 57 | +INSERT INTO t1 VALUES(50); |
| 58 | + |
| 59 | +connection default; |
| 60 | +SET GLOBAL READ_ONLY=1; |
| 61 | + |
| 62 | +connection con1; |
| 63 | +SELECT @@GLOBAL.READ_ONLY; |
| 64 | +COMMIT; |
| 65 | + |
| 66 | +connection default; |
| 67 | +SET GLOBAL READ_ONLY=0; |
| 68 | + |
| 69 | +--echo # Test UPDATE operations on temporary tables, UPDATEs should be successful even |
| 70 | +--echo # when global read_only is enabled. |
| 71 | +connection con1; |
| 72 | +BEGIN; |
| 73 | +UPDATE t1 SET a=60 WHERE a=50; |
| 74 | + |
| 75 | +connection default; |
| 76 | +SET GLOBAL READ_ONLY=1; |
| 77 | + |
| 78 | +connection con1; |
| 79 | +SELECT @@GLOBAL.READ_ONLY; |
| 80 | +COMMIT; |
| 81 | + |
| 82 | +SELECT * FROM t1; |
| 83 | + |
| 84 | +--echo # Clean up |
| 85 | +connection default; |
| 86 | +SET GLOBAL READ_ONLY=0; |
| 87 | + |
| 88 | +disconnect con1; |
| 89 | +DROP USER test@localhost; |
| 90 | +--disable_connect_log |
0 commit comments