~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/xa.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# WL#1756
 
3
#
 
4
-- source include/have_innodb.inc
 
5
 
 
6
# Save the initial number of concurrent sessions
 
7
--source include/count_sessions.inc
 
8
 
 
9
--disable_warnings
 
10
drop table if exists t1, t2;
 
11
--enable_warnings
 
12
create table t1 (a int) engine=innodb;
 
13
xa start 'test1';
 
14
insert t1 values (10);
 
15
xa end 'test1';
 
16
xa prepare 'test1';
 
17
xa rollback 'test1';
 
18
select * from t1;
 
19
 
 
20
xa start 'test2';
 
21
--error ER_XAER_RMFAIL
 
22
xa start 'test-bad';
 
23
insert t1 values (20);
 
24
--error ER_XAER_RMFAIL
 
25
xa prepare 'test2';
 
26
xa end 'test2';
 
27
xa prepare 'test2';
 
28
xa commit 'test2';
 
29
select * from t1;
 
30
 
 
31
xa start 'testa','testb';
 
32
insert t1 values (30);
 
33
 
 
34
--error ER_XAER_RMFAIL
 
35
commit;
 
36
 
 
37
xa end 'testa','testb';
 
38
 
 
39
--error ER_XAER_RMFAIL
 
40
begin;
 
41
--error ER_XAER_RMFAIL
 
42
create table t2 (a int);
 
43
 
 
44
connect (con1,localhost,root,,);
 
45
connection con1;
 
46
 
 
47
--error ER_XAER_DUPID
 
48
xa start 'testa','testb';
 
49
--error ER_XAER_DUPID
 
50
xa start 'testa','testb', 123;
 
51
 
 
52
#        gtrid [ , bqual [ , formatID ] ]
 
53
xa start 0x7465737462, 0x2030405060, 0xb;
 
54
insert t1 values (40);
 
55
xa end 'testb',' 0@P`',11;
 
56
xa prepare 'testb',0x2030405060,11;
 
57
 
 
58
--error ER_XAER_RMFAIL
 
59
start transaction;
 
60
 
 
61
xa recover;
 
62
 
 
63
# uncomment the line below when binlog will be able to prepare
 
64
#disconnect con1;
 
65
connection default;
 
66
 
 
67
xa prepare 'testa','testb';
 
68
 
 
69
xa recover;
 
70
 
 
71
--error ER_XAER_NOTA
 
72
xa commit 'testb',0x2030405060,11;
 
73
xa rollback 'testa','testb';
 
74
 
 
75
--error ER_PARSE_ERROR
 
76
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
 
77
 
 
78
select * from t1;
 
79
drop table t1;
 
80
 
 
81
disconnect con1;
 
82
 
 
83
#
 
84
# Bug#28323: Server crashed in xid cache operations
 
85
#
 
86
 
 
87
--disable_warnings
 
88
drop table if exists t1;
 
89
--enable_warnings
 
90
 
 
91
create table t1(a int, b int, c varchar(20), primary key(a)) engine = innodb;
 
92
insert into t1 values(1, 1, 'a');
 
93
insert into t1 values(2, 2, 'b');
 
94
 
 
95
connect (con1,localhost,root,,);
 
96
connect (con2,localhost,root,,);
 
97
 
 
98
--connection con1
 
99
xa start 'a','b';
 
100
update t1 set c = 'aa' where a = 1;
 
101
--connection con2
 
102
xa start 'a','c';
 
103
update t1 set c = 'bb' where a = 2;
 
104
--connection con1
 
105
--send update t1 set c = 'bb' where a = 2
 
106
--connection con2
 
107
--sleep 1
 
108
--error ER_LOCK_DEADLOCK
 
109
update t1 set c = 'aa' where a = 1;
 
110
select count(*) from t1;
 
111
--error ER_XA_RBDEADLOCK
 
112
xa end 'a','c';
 
113
xa rollback 'a','c';
 
114
--disconnect con2
 
115
 
 
116
connect (con3,localhost,root,,);
 
117
--connection con3
 
118
xa start 'a','c';
 
119
 
 
120
--disconnect con1
 
121
--disconnect con3
 
122
--connection default
 
123
drop table t1;
 
124
 
 
125
--echo End of 5.0 tests
 
126
 
 
127
#
 
128
# Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null()
 
129
#
 
130
 
 
131
xa start 'a';
 
132
xa end 'a';
 
133
xa rollback 'a';
 
134
xa start 'a';
 
135
xa end 'a';
 
136
xa rollback 'a';
 
137
 
 
138
#
 
139
# Bug#45548: XA transaction without access to InnoDB tables crashes the server
 
140
#
 
141
 
 
142
xa start 'a';
 
143
xa end 'a';
 
144
xa prepare 'a';
 
145
xa commit 'a';
 
146
 
 
147
xa start 'a';
 
148
xa end 'a';
 
149
xa prepare 'a';
 
150
xa commit 'a';
 
151
 
 
152
#
 
153
# BUG#43171 - Assertion failed: thd->transaction.xid_state.xid.is_null()
 
154
#
 
155
CREATE TABLE t1(a INT, KEY(a)) ENGINE=InnoDB;
 
156
INSERT INTO t1 VALUES(1),(2);
 
157
connect(con1,localhost,root,,);
 
158
 
 
159
# Part 1: Prepare to test XA START after regular transaction deadlock
 
160
BEGIN;
 
161
UPDATE t1 SET a=3 WHERE a=1;
 
162
 
 
163
connection default;
 
164
BEGIN;
 
165
UPDATE t1 SET a=4 WHERE a=2;
 
166
 
 
167
connection con1;
 
168
let $conn_id= `SELECT CONNECTION_ID()`;
 
169
SEND UPDATE t1 SET a=5 WHERE a=2;
 
170
 
 
171
connection default;
 
172
let $wait_timeout= 2;
 
173
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
 
174
WHERE ID=$conn_id AND STATE='Searching rows for update';
 
175
--source include/wait_condition.inc
 
176
 
 
177
--error ER_LOCK_DEADLOCK
 
178
UPDATE t1 SET a=5 WHERE a=1;
 
179
ROLLBACK;
 
180
 
 
181
# Part 2: Prepare to test XA START after XA transaction deadlock
 
182
connection con1;
 
183
REAP;
 
184
ROLLBACK;
 
185
BEGIN;
 
186
UPDATE t1 SET a=3 WHERE a=1;
 
187
 
 
188
connection default;
 
189
XA START 'xid1';
 
190
UPDATE t1 SET a=4 WHERE a=2;
 
191
 
 
192
connection con1;
 
193
SEND UPDATE t1 SET a=5 WHERE a=2;
 
194
 
 
195
connection default;
 
196
let $wait_timeout= 2;
 
197
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
 
198
WHERE ID=$conn_id AND STATE='Searching rows for update';
 
199
--source include/wait_condition.inc
 
200
 
 
201
--error ER_LOCK_DEADLOCK
 
202
UPDATE t1 SET a=5 WHERE a=1;
 
203
--error ER_XA_RBDEADLOCK
 
204
XA END 'xid1';
 
205
XA ROLLBACK 'xid1';
 
206
 
 
207
XA START 'xid1';
 
208
XA END 'xid1';
 
209
XA ROLLBACK 'xid1';
 
210
 
 
211
disconnect con1;
 
212
DROP TABLE t1;
 
213
 
 
214
# Wait till all disconnects are completed
 
215
--source include/wait_until_count_sessions.inc
 
216