1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
|
set global innodb_file_per_table = off;
use test;
create temporary table t1
(a int, b char(100), c char(100)) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
2000
begin;
call populate_t1();
rollback;
select count(*) from t1;
count(*)
2000
truncate table t1;
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
2000
delete from t1 where a < 500;
select count(*) from t1;
count(*)
1501
update t1 set b = 'innodb' where b = 'a';
update t1 set c = 'mysql' where c = 'b' and a < 1000;
begin;
update t1 set c = 'sqldb' where c = 'mysql' and a < 1000;
select count(*) from t1 where c = 'sqldb';
count(*)
500
rollback;
drop procedure populate_t1;
drop table t1;
create table t1
(a int, b char(100), c char(100)) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
2000
begin;
call populate_t1();
rollback;
select count(*) from t1;
count(*)
2000
truncate table t1;
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
2000
delete from t1 where a < 500;
select count(*) from t1;
count(*)
1501
update t1 set b = 'innodb' where b = 'a';
update t1 set c = 'mysql' where c = 'b' and a < 1000;
begin;
update t1 set c = 'sqldb' where c = 'mysql' and a < 1000;
select count(*) from t1 where c = 'sqldb';
count(*)
500
rollback;
drop procedure populate_t1;
drop table t1;
use test;
create temporary table t1
(a int, b char(100), c char(100)) engine = innodb;
create table t2
(a int, b char(100), c char(100)) engine = innodb;
create procedure populate_t1_t2()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t1 values (i, 'a', 'b');
insert into t2 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t1_t2_small()
begin
declare i int default 1;
while (i <= 200) DO
insert into t1 values (i, 'a', 'b');
insert into t2 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
begin;
call populate_t1_t2();
commit;
select count(*) from t1;
count(*)
2000
select count(*) from t2;
count(*)
2000
begin;
delete from t1 where a <= 100;
delete from t2 where a > 1900;
select count(*) from t1;
count(*)
1900
select count(*) from t2;
count(*)
1900
commit;
begin;
update t1 set b = 'innodb' where b = 'a' and a <= 1000;
update t2 set b = 'myisam' where c = 'b' and a > 1000;
commit;
delete from t1 where b = 'a';
delete from t2 where c = 'myisam';
select count(*) from t1;
count(*)
900
select count(*) from t2;
count(*)
1900
insert into t1 values (1000000, 'mysql', 'db');
begin;
call populate_t1_t2_small();
select count(*) from t1;
count(*)
1101
select count(*) from t2;
count(*)
2100
rollback;
select count(*) from t1;
count(*)
901
select count(*) from t2;
count(*)
1900
drop table t2;
drop table t1;
drop procedure populate_t1_t2;
drop procedure populate_t1_t2_small;
# The use of temporary tables in XA transactions is only permitted when
# xa_detach_on_prepare is OFF.
SET @saved_xa_detach_on_prepare = @@SESSION.xa_detach_on_prepare;
SET SESSION xa_detach_on_prepare = OFF;
create temporary table t1 (i int) engine=innodb;
create table t2 (i int) engine=innodb;
insert into t1 values (1);
insert into t2 values (101);
select * from t1;
i
1
select * from t2;
i
101
xa start 'tx1';
insert into t1 values (2), (3);
insert into t2 values (202), (303);
select * from t1;
i
1
2
3
select * from t2;
i
101
202
303
xa end 'tx1';
xa prepare 'tx1';
xa commit 'tx1';
select * from t1;
i
1
2
3
select * from t2;
i
101
202
303
xa start 'tx1';
insert into t1 values (2), (3);
insert into t2 values (202), (303);
select * from t1;
i
1
2
3
2
3
select * from t2;
i
101
202
303
202
303
xa end 'tx1';
xa prepare 'tx1';
xa rollback 'tx1';
select * from t1;
i
1
2
3
select * from t2;
i
101
202
303
xa start 'tx1';
insert into t1 values (2), (3);
select * from t1;
i
1
2
3
2
3
xa end 'tx1';
xa prepare 'tx1';
xa commit 'tx1';
select * from t1;
i
1
2
3
2
3
drop table t1;
drop table t2;
SET SESSION xa_detach_on_prepare = @saved_xa_detach_on_prepare;
set global innodb_file_per_table=default;
|