~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/include/commit.inc

  • Committer: Prafulla Tekawade
  • Date: 2010-07-13 16:07:35 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100713160735-2fsdtrm3azayuyu1
This bug is simillar to mysql bug 36133
http://bugs.mysql.com/bug.php?id=36133

Taking changes from that fix.

  - The problem was that the range optimizer evaluated constant expressions, 
    and among them it would try to evaluate IN-subquery predicates slated for
    handling with materialization strategy. However, these predicates require
    that parent_join->setup_subquery_materialization() is invoked before one
    attempts to evaluate them.
  
  - Fixed by making the range optimizer not to evaluate expressions that have
    item->is_expensive() == TRUE (these are materialization subqueries and 
    stored function calls). This should also resolve the problem that EXPLAIN 
    may be too long. 
    This change cuts off some opportunities for range optimizer, but this is 
    the price we're willing to pay for separation of query optimization and
    execution. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
## Bug#12713 (Error in a stored function called from a SELECT doesn't cause
 
2
##    ROLLBACK of statem)
 
3
 
 
4
##
 
5
## Pre-Requisites :
 
6
## - $engine_type should be set
 
7
##
 
8
 
 
9
eval set storage_engine = $engine_type;
 
10
set autocommit=1;
 
11
 
 
12
--disable_warnings
 
13
drop table if exists t1;
 
14
drop table if exists t2;
 
15
drop table if exists t3;
 
16
--enable_warnings
 
17
 
 
18
create table t1 (a int);
 
19
create table t2 (a int unique);
 
20
create table t3 (a int);
 
21
 
 
22
insert into t1 (a) values (1), (2);
 
23
insert into t3 (a) values (1), (2);
 
24
 
 
25
##============================================================================
 
26
## Design notes
 
27
##
 
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.
 
31
##
 
32
## The test pattern is as follows
 
33
## - insert 1000+N
 
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
##============================================================================
 
39
 
 
40
insert into t2 (a) values (1001);
 
41
insert into t1 (a) values (1);
 
42
select * from t2;
 
43
rollback;
 
44
select * from t2;
 
45
 
 
46
insert into t2 (a) values (1002);
 
47
select * from t2;
 
48
rollback;
 
49
select * from t2;
 
50
 
 
51
insert into t2 (a) values (1003);
 
52
update t1 set a= a + 3;
 
53
select * from t2;
 
54
rollback;
 
55
select * from t2;
 
56
 
 
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);
 
59
select * from t2;
 
60
rollback;
 
61
select * from t2;
 
62
 
 
63
insert into t2 (a) values (1005);
 
64
delete from t1 where (a = 5);
 
65
select * from t2;
 
66
rollback;
 
67
select * from t2;
 
68
 
 
69
insert into t2 (a) values (1006);
 
70
delete from t1, t3 using t1, t3 where (6 = 6) ;
 
71
select * from t2;
 
72
rollback;
 
73
select * from t2;
 
74
 
 
75
insert into t2 (a) values (1007);
 
76
replace t1 values (7);
 
77
select * from t2;
 
78
rollback;
 
79
select * from t2;
 
80
 
 
81
insert into t2 (a) values (1008);
 
82
replace into t3 (a) select 8 from t1;
 
83
select * from t2;
 
84
rollback;
 
85
select * from t2;
 
86
 
 
87
insert into t2 (a) values (1009);
 
88
select 9 from t1 ;
 
89
select * from t2;
 
90
rollback;
 
91
select * from t2;
 
92
 
 
93
insert into t2 (a) values (1010);
 
94
select * from t2;
 
95
rollback;
 
96
select * from t2;
 
97
 
 
98
insert into t2 (a) values (1011);
 
99
select * from t2;
 
100
rollback;
 
101
select * from t2;
 
102
 
 
103
select * from t2;
 
104
 
 
105
insert into t2 (a) values (1013);
 
106
select * from t2;
 
107
rollback;
 
108
select * from t2;
 
109
 
 
110
insert into t2 (a) values (1014);
 
111
show open tables;
 
112
select * from t2;
 
113
rollback;
 
114
select * from t2;
 
115
 
 
116
insert into t2 (a) values (1015);
 
117
select * from t2;
 
118
rollback;
 
119
select * from t2;
 
120
 
 
121
insert into t2 (a) values (1016);
 
122
select * from t2;
 
123
rollback;
 
124
select * from t2;
 
125
 
 
126
insert into t2 (a) values (1017);
 
127
select * from t2;
 
128
rollback;
 
129
select * from t2;
 
130
 
 
131
insert into t2 (a) values (1018);
 
132
select * from t2;
 
133
rollback;
 
134
select * from t2;
 
135
 
 
136
insert into t2 (a) values (1019);
 
137
select * from t2;
 
138
rollback;
 
139
select * from t2;
 
140
 
 
141
select * from t2;
 
142
rollback;
 
143
select * from t2;
 
144
 
 
145
insert into t2 (a) values (1021);
 
146
select * from t2;
 
147
rollback;
 
148
select * from t2;
 
149
 
 
150
insert into t2 (a) values (1022);
 
151
select * from t2;
 
152
rollback;
 
153
select * from t2;
 
154
 
 
155
insert into t2 (a) values (1023);
 
156
select * from t2;
 
157
rollback;
 
158
select * from t2;
 
159
 
 
160
--echo =======================================================================
 
161
--echo Testing select_to_file
 
162
--echo =======================================================================
 
163
 
 
164
insert into t2 (a) values (1025);
 
165
 
 
166
--replace_result $MYSQLTEST_VARDIR ..
 
167
eval select 25 into outfile "$MYSQLTEST_VARDIR/tmp/dml.out" from t1;
 
168
select * from t2;
 
169
rollback;
 
170
select * from t2;
 
171
--remove_file $MYSQLTEST_VARDIR/tmp/dml.out
 
172
 
 
173
insert into t2 (a) values (1026);
 
174
--replace_result $MYSQLTEST_VARDIR ..
 
175
--error 1366
 
176
eval load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=26;
 
177
 
 
178
select * from t2;
 
179
rollback;
 
180
select * from t2;
 
181
 
 
182
--echo =======================================================================
 
183
--echo Testing select_dumpvar
 
184
--echo =======================================================================
 
185
 
 
186
insert into t2 (a) values (1027);
 
187
select 27 into @foo;
 
188
select * from t2;
 
189
rollback;
 
190
select * from t2;
 
191
 
 
192
--echo =======================================================================
 
193
--echo Cleanup
 
194
--echo =======================================================================
 
195
 
 
196
set autocommit=default;
 
197
 
 
198
drop table t1;
 
199
drop table t2;
 
200
drop table t3;
 
201
--echo #
 
202
--echo # Bug#12713 Error in a stored function called from a SELECT doesn't
 
203
--echo # cause ROLLBACK of statem
 
204
--echo #
 
205
--echo # Verify that two-phase commit is not issued for read-only
 
206
--echo # transactions.
 
207
--echo #
 
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.
 
211
--echo #
 
212
set autocommit=0;
 
213
--disable_warnings
 
214
drop table if exists t1;
 
215
drop table if exists t2;
 
216
drop table if exists t3;
 
217
--enable_warnings