1
## Bug#12713 (Error in a stored function called from a SELECT doesn't cause
6
## - $engine_type should be set
9
eval set storage_engine = $engine_type;
13
drop table if exists t1;
14
drop table if exists t2;
15
drop table if exists t3;
18
create table t1 (a int);
19
create table t2 (a int unique);
20
create table t3 (a int);
22
insert into t1 (a) values (1), (2);
23
insert into t3 (a) values (1), (2);
25
##============================================================================
28
## In each case, statement rollback is expected.
29
## for transactional engines, the rollback should be properly executed
30
## for non transactional engines, the rollback may cause warnings.
32
## The test pattern is as follows
34
## - statement with a side effect, that fails to insert N twice
35
## - a statement rollback is expected (expecting 1 row 1000+N only) in t2
36
## - a rollback is performed
37
## - expecting a clean table t2.
38
##============================================================================
40
insert into t2 (a) values (1001);
41
insert into t1 (a) values (1);
46
insert into t2 (a) values (1002);
51
insert into t2 (a) values (1003);
52
update t1 set a= a + 3;
57
insert into t2 (a) values (1004);
58
update t1, t3 set t1.a = 0, t3.a = 0 where (4 = 4) and (t1.a = t3.a);
63
insert into t2 (a) values (1005);
64
delete from t1 where (a = 5);
69
insert into t2 (a) values (1006);
70
delete from t1, t3 using t1, t3 where (6 = 6) ;
75
insert into t2 (a) values (1007);
76
replace t1 values (7);
81
insert into t2 (a) values (1008);
82
replace into t3 (a) select 8 from t1;
87
insert into t2 (a) values (1009);
93
insert into t2 (a) values (1010);
98
insert into t2 (a) values (1011);
105
insert into t2 (a) values (1013);
110
insert into t2 (a) values (1014);
116
insert into t2 (a) values (1015);
121
insert into t2 (a) values (1016);
126
insert into t2 (a) values (1017);
131
insert into t2 (a) values (1018);
136
insert into t2 (a) values (1019);
145
insert into t2 (a) values (1021);
150
insert into t2 (a) values (1022);
155
insert into t2 (a) values (1023);
160
--echo =======================================================================
161
--echo Testing select_to_file
162
--echo =======================================================================
164
insert into t2 (a) values (1025);
166
--replace_result $MYSQLTEST_VARDIR ..
167
eval select 25 into outfile "$MYSQLTEST_VARDIR/tmp/dml.out" from t1;
171
--remove_file $MYSQLTEST_VARDIR/tmp/dml.out
173
insert into t2 (a) values (1026);
174
--replace_result $MYSQLTEST_VARDIR ..
176
eval load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=26;
182
--echo =======================================================================
183
--echo Testing select_dumpvar
184
--echo =======================================================================
186
insert into t2 (a) values (1027);
192
--echo =======================================================================
194
--echo =======================================================================
196
set autocommit=default;
202
--echo # Bug#12713 Error in a stored function called from a SELECT doesn't
203
--echo # cause ROLLBACK of statem
205
--echo # Verify that two-phase commit is not issued for read-only
206
--echo # transactions.
208
--echo # Verify that two-phase commit is issued for read-write transactions,
209
--echo # even if the change is done inside a stored function called from
210
--echo # SELECT or SHOW statement.
214
drop table if exists t1;
215
drop table if exists t2;
216
drop table if exists t3;