oceanbase
303 строки · 8.3 Кб
1--disable_query_log
2set @@session.explicit_defaults_for_timestamp=off;
3--enable_query_log
4# owner: luofan.zp
5# owner group: SQL3
6# description: OUR GOAL: Make all this simple and effective!
7# init status (autocommit=1, not_trx)
8show variables like 'autocommit';
9
10--echo case 1: (autocommit=1, not_trx) // start transaction
11connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
12connection conn1;
13show variables like 'autocommit';
14--disable_warnings
15drop table if exists t1;
16--enable_warnings
17create table t1 (c1 int primary key, c2 int);
18start transaction;
19insert into t1 values (1, 2);
20select * from t1 where c1 = 1 for update;
21commit;
22select * from t1;
23disconnect conn1;
24
25--echo case 2: (autocommit=1, not_trx) // commit
26connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
27connection conn1;
28show variables like 'autocommit';
29--disable_warnings
30drop table if exists t1;
31--enable_warnings
32create table t1 (c1 int primary key, c2 int);
33commit;
34select * from t1;
35disconnect conn1;
36
37--echo case 3: (autocommit=1, not_trx) // autocommit=1
38connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
39connection conn1;
40show variables like 'autocommit';
41--disable_warnings
42drop table if exists t1;
43--enable_warnings
44create table t1 (c1 int primary key, c2 int);
45set autocommit=1;
46show variables like 'autocommit';
47start transaction;
48insert into t1 values (1, 2);
49select * from t1 where c1 = 1 for update;
50commit;
51select * from t1;
52disconnect conn1;
53
54--echo case 4: (autocommit=1, not_trx) // autocommit=0
55connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
56connection conn1;
57show variables like 'autocommit';
58--disable_warnings
59drop table if exists t1;
60--enable_warnings
61create table t1 (c1 int primary key, c2 int);
62set autocommit=0;
63show variables like 'autocommit';
64insert into t1 values (1, 2);
65select * from t1 where c1 = 1 for update;
66commit;
67select * from t1;
68show variables like 'autocommit';
69disconnect conn1;
70
71--echo case 5: (autocommit=1, in_trx) // start transaction
72connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
73connection conn1;
74show variables like 'autocommit';
75--disable_warnings
76drop table if exists t1;
77--enable_warnings
78create table t1 (c1 int primary key, c2 int);
79start transaction;
80# (autocommit=1, in_trx)
81start transaction;
82insert into t1 values (1, 2);
83select * from t1 where c1 = 1 for update;
84commit;
85select * from t1;
86disconnect conn1;
87
88--echo case 6: (autocommit=1, in_trx) // commit
89connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
90connection conn1;
91show variables like 'autocommit';
92--disable_warnings
93drop table if exists t1;
94--enable_warnings
95create table t1 (c1 int primary key, c2 int);
96start transaction;
97# (autocommit=1, in_trx)
98insert into t1 values (1, 2);
99select * from t1 where c1 = 1 for update;
100commit;
101select * from t1;
102start transaction;
103show variables like 'autocommit';
104disconnect conn1;
105
106--echo case 7: (autocommit=1, in_trx) // set autocommit=1
107connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
108connection conn1;
109show variables like 'autocommit';
110--disable_warnings
111drop table if exists t1;
112--enable_warnings
113create table t1 (c1 int primary key, c2 int);
114start transaction;
115# (autocommit=1, in_trx)
116set autocommit=1;
117show variables like 'autocommit';
118insert into t1 values (1, 2);
119select * from t1 where c1 = 1 for update;
120commit;
121select * from t1;
122disconnect conn1;
123
124--echo case 8: (autocommit=1, in_trx) // set autocommit=0
125connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
126connection conn1;
127show variables like 'autocommit';
128--disable_warnings
129drop table if exists t1;
130--enable_warnings
131create table t1 (c1 int primary key, c2 int);
132start transaction;
133# (autocommit=1, in_trx)
134set autocommit=0;
135show variables like 'autocommit';
136insert into t1 values (1, 2);
137select * from t1 where c1 = 1 for update;
138commit;
139select * from t1;
140show variables like 'autocommit';
141disconnect conn1;
142
143--echo case 9: (autocommit=0, not_trx) // start transaction
144connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
145connection conn1;
146show variables like 'autocommit';
147--disable_warnings
148drop table if exists t1;
149--enable_warnings
150create table t1 (c1 int primary key, c2 int);
151set autocommit=0;
152show variables like 'autocommit';
153# (autocommit=0, not_trx)
154start transaction;
155start transaction;
156insert into t1 values (1, 2);
157select * from t1 where c1 = 1 for update;
158commit;
159select * from t1;
160show variables like 'autocommit';
161disconnect conn1;
162
163
164--echo case 10: (autocommit=0, not_trx) // commit
165connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
166connection conn1;
167show variables like 'autocommit';
168--disable_warnings
169drop table if exists t1;
170--enable_warnings
171create table t1 (c1 int primary key, c2 int);
172set autocommit=0;
173show variables like 'autocommit';
174# (autocommit=0, not_trx)
175insert into t1 values (1, 2);
176select * from t1 where c1 = 1 for update;
177commit;
178insert into t1 values (2, 3);
179select * from t1 where c1 = 2 for update;
180rollback;
181select * from t1;
182show variables like 'autocommit';
183disconnect conn1;
184
185--echo case 11: (autocommit=0, not_trx) // set autocommit=1
186connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
187connection conn1;
188show variables like 'autocommit';
189--disable_warnings
190drop table if exists t1;
191--enable_warnings
192create table t1 (c1 int primary key, c2 int);
193set autocommit=0;
194show variables like 'autocommit';
195# (autocommit=0, not_trx)
196set autocommit=1;
197show variables like 'autocommit';
198commit;
199rollback;
200select * from t1;
201show variables like 'autocommit';
202disconnect conn1;
203
204--echo case 12: (autocommit=0, not_trx) // commit
205connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
206connection conn1;
207show variables like 'autocommit';
208--disable_warnings
209drop table if exists t1;
210--enable_warnings
211create table t1 (c1 int primary key, c2 int);
212set autocommit=0;
213show variables like 'autocommit';
214# (autocommit=0, not_trx)
215set autocommit=0;
216show variables like 'autocommit';
217insert into t1 values (1, 2);
218select * from t1 where c1 = 1 for update;
219commit;
220insert into t1 values (2, 3);
221select * from t1 where c1 = 2 for update;
222commit;
223select * from t1;
224show variables like 'autocommit';
225disconnect conn1;
226
227--echo case 13: (autocommit=0, in_trx) // start transaction
228connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
229connection conn1;
230show variables like 'autocommit';
231--disable_warnings
232drop table if exists t1;
233--enable_warnings
234create table t1 (c1 int primary key, c2 int);
235set autocommit=0;
236start transaction;
237show variables like 'autocommit';
238# (autocommit=0, in_trx)
239start transaction;
240commit;
241show variables like 'autocommit';
242disconnect conn1;
243
244--echo case 14: (autocommit=0, in_trx) // commit
245connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
246connection conn1;
247show variables like 'autocommit';
248--disable_warnings
249drop table if exists t1;
250--enable_warnings
251create table t1 (c1 int primary key, c2 int);
252set autocommit=0;
253start transaction;
254show variables like 'autocommit';
255# (autocommit=0, in_trx)
256insert into t1 values (1, 2);
257select * from t1 where c1 = 1 for update;
258commit;
259select * from t1;
260show variables like 'autocommit';
261disconnect conn1;
262
263--echo case 15: (autocommit=0, in_trx) // set autocommit=1
264connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
265connection conn1;
266show variables like 'autocommit';
267--disable_warnings
268drop table if exists t1;
269--enable_warnings
270create table t1 (c1 int primary key, c2 int);
271set autocommit=0;
272start transaction;
273show variables like 'autocommit';
274# (autocommit=0, in_trx)
275insert into t1 values (1, 2);
276select * from t1 where c1 = 1 for update;
277set autocommit=1;
278select * from t1;
279show variables like 'autocommit';
280# are we in (autocommit=1, not_trx) ?
281commit;
282disconnect conn1;
283
284--echo case 16: (autocommit=0, in_trx) // set autocommit=0
285connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
286connection conn1;
287show variables like 'autocommit';
288--disable_warnings
289drop table if exists t1;
290--enable_warnings
291create table t1 (c1 int primary key, c2 int);
292set autocommit=0;
293start transaction;
294show variables like 'autocommit';
295# (autocommit=0, in_trx)
296set autocommit=0;
297insert into t1 values (1, 2);
298select * from t1 where c1 = 1 for update;
299commit;
300select * from t1;
301show variables like 'autocommit';
302commit;
303disconnect conn1;
304
305