|
| 1 | +--echo # continue previous transaction |
| 2 | +--echo # read_only was turned on in the middle of a transaction |
| 3 | +--echo # new update/insert statement will be blocked immediately |
| 4 | +update t1 set a = a + 1; |
| 5 | +# multiple table updates |
| 6 | +update t1, t2 set t1.a=t1.a+1, t2.a=t2.a*2; |
| 7 | +select 't1', a from t1; |
| 8 | +select 't2', a from t2; |
| 9 | + |
| 10 | +--echo # write transaction was rolled back at the end |
| 11 | +--error ER_DB_READ_ONLY |
| 12 | +commit; |
| 13 | + |
| 14 | +# insert/update rolled back |
| 15 | +select 't1', a from t1; |
| 16 | +select 't2', a from t2; |
| 17 | + |
| 18 | +--echo # write transaction with 'begin' |
| 19 | +begin; |
| 20 | +insert into t1 values (4), (5), (6); |
| 21 | +update t1 set a = a + 1; |
| 22 | +# creating a table DDL is failed immdiately |
| 23 | +--error ER_DB_READ_ONLY |
| 24 | +create table t3 (a int) engine=innodb; |
| 25 | +select a from t1; |
| 26 | +--error ER_DB_READ_ONLY |
| 27 | +commit; |
| 28 | + |
| 29 | +--echo # read-only transactions are ok |
| 30 | +begin; |
| 31 | +select count(*) from t1; |
| 32 | +select count(*) from t2; |
| 33 | +commit; |
| 34 | + |
| 35 | +--echo # transaction without 'begin' |
| 36 | +insert into t1 values (4), (5), (6); |
| 37 | +insert into t1 values (7), (8), (9); |
| 38 | +select a from t1; |
| 39 | +--error ER_DB_READ_ONLY |
| 40 | +commit; |
| 41 | +select a from t1; |
| 42 | + |
| 43 | +--echo # rolled-back transaction |
| 44 | +insert into t1 values (4), (5), (6); |
| 45 | +insert into t1 values (7), (8), (9); |
| 46 | +select a from t1; |
| 47 | +rollback; |
| 48 | +select a from t1; |
| 49 | + |
| 50 | +set autocommit = 1; |
| 51 | +--echo # multiple table updates (autocommit) |
| 52 | +--error ER_DB_READ_ONLY |
| 53 | +update t1, t2 set t1.a=t1.a+1, t2.a=t2.a*2; |
| 54 | +select 't1', a from t1; |
| 55 | +select 't2', a from t2; |
| 56 | +set autocommit = 0; |
| 57 | + |
| 58 | +# table update DDL is blocked |
| 59 | +--error ER_DB_READ_ONLY |
| 60 | +alter table t1 add key (a); |
| 61 | + |
| 62 | +# table update DDL is blocked |
| 63 | +--error ER_DB_READ_ONLY |
| 64 | +create index a on t1 (a); |
| 65 | + |
| 66 | +# drop table is not allowed |
| 67 | +--error ER_DB_READ_ONLY |
| 68 | +drop table t1; |
| 69 | + |
| 70 | +# drop database is not allowed |
| 71 | +--error ER_DB_READ_ONLY |
| 72 | +drop database test; |
| 73 | + |
| 74 | +--echo # |
| 75 | +--echo # OK to create temporary table |
| 76 | +--echo # |
| 77 | +create temporary table temp1 (a int); |
| 78 | +insert into temp1 select * from t1; |
| 79 | +update temp1 set a = a + 1; |
| 80 | +select * from temp1; |
| 81 | +drop temporary table temp1; |
| 82 | + |
| 83 | +--echo # |
| 84 | +--echo # OK to switch and write another database |
| 85 | +--echo # read_only scope is per database |
| 86 | +--echo # |
| 87 | +create database test2; |
| 88 | +use test2; |
| 89 | +show create database test2; |
| 90 | +create table t1 (a int) engine = innodb; |
| 91 | +insert into t1 values (0), (1), (2); |
| 92 | +update t1 set a = a + 1; |
| 93 | +select a from t1; |
| 94 | + |
| 95 | +--echo # |
| 96 | +--echo # cross-db/noncurrent-db transaction |
| 97 | +--echo # Transaction writing to test db from session of test2 db |
| 98 | +--echo # |
| 99 | +begin; |
| 100 | +insert into test.t1 values (4), (5), (6); |
| 101 | +update test.t1 set a = a + 1; |
| 102 | +select a from test.t1; |
| 103 | +--error ER_DB_READ_ONLY |
| 104 | +commit; |
| 105 | +select a from test.t1; |
| 106 | +select a from test2.t1; |
| 107 | + |
| 108 | +begin; |
| 109 | +insert into test.t1 values (4), (5), (6); |
| 110 | +update test.t1 set a = a + 1; |
| 111 | +select a from test.t1; |
| 112 | +update test2.t1 set a = a + 1; |
| 113 | +select a from test2.t1; |
| 114 | +--error ER_DB_READ_ONLY |
| 115 | +commit; |
| 116 | +select a from test.t1; |
| 117 | +select a from test2.t1; |
| 118 | + |
| 119 | +use test; |
| 120 | +drop database test2; |
0 commit comments