Merge lp:~stewart/drizzle/bug720552 into lp:drizzle/7.0

Proposed by Stewart Smith
Status: Merged
Approved by: Brian Aker
Approved revision: 2183
Merged at revision: 2183
Proposed branch: lp:~stewart/drizzle/bug720552
Merge into: lp:drizzle/7.0
Diff against target: 343 lines (+232/-1)
6 files modified
drizzled/optimizer/sum.cc (+10/-0)
plugin/storage_engine_api_tester/cursor_states.cc (+27/-0)
plugin/storage_engine_api_tester/engine_states.cc (+1/-0)
plugin/storage_engine_api_tester/storage_engine_api_tester.cc (+146/-1)
plugin/storage_engine_api_tester/tests/r/min_index_scan_error.result (+35/-0)
plugin/storage_engine_api_tester/tests/t/min_index_scan_error.test (+13/-0)
To merge this branch: bzr merge lp:~stewart/drizzle/bug720552
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+50104@code.launchpad.net

Description of the change

introduces a test for and fixes one of the places where we weren't handling errors correctly for doStartTableScan().

The test increases what storage_engine_api_tester covers to include index operations and properly support ::info() and ::extra(). This should also be useful in future tests of SE API.

http://hudson.drizzle.org/view/Drizzle-param/job/drizzle-param/747/

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/optimizer/sum.cc'
2--- drizzled/optimizer/sum.cc 2011-02-12 22:27:36 +0000
3+++ drizzled/optimizer/sum.cc 2011-02-17 08:09:59 +0000
4@@ -266,6 +266,16 @@
5 break;
6 }
7 error= table->cursor->startIndexScan(static_cast<uint32_t>(ref.key), 1);
8+ if (error)
9+ {
10+ if (table->key_read)
11+ {
12+ table->key_read= 0;
13+ table->cursor->extra(HA_EXTRA_NO_KEYREAD);
14+ }
15+ table->print_error(error, MYF(0));
16+ return error;
17+ }
18
19 if (! ref.key_length)
20 {
21
22=== modified file 'plugin/storage_engine_api_tester/cursor_states.cc'
23--- plugin/storage_engine_api_tester/cursor_states.cc 2010-12-01 11:16:06 +0000
24+++ plugin/storage_engine_api_tester/cursor_states.cc 2011-02-17 08:09:59 +0000
25@@ -42,6 +42,10 @@
26 states.insert(state_pair("::reset()", "::doOpen()"));
27 states.insert(state_pair("::doEndTableScan()", "::reset()"));
28 states.insert(state_pair("locked", "::reset()"));
29+ states.insert(state_pair("locked", "::scan_time()"));
30+ states.insert(state_pair("::scan_time()", "locked"));
31+ states.insert(state_pair("::scan_time()", "::scan_time()"));
32+
33
34 // we can always set a new lock
35 states.insert(state_pair("::store_lock()", "::store_lock()"));
36@@ -58,6 +62,7 @@
37 states.insert(state_pair("locked", "::doStartTableScan()"));
38 states.insert(state_pair("::doStartTableScan()", "::rnd_next()"));
39 states.insert(state_pair("::doStartTableScan()", "::rnd_pos()"));
40+
41 states.insert(state_pair("::rnd_pos()", "::rnd_pos()"));
42 states.insert(state_pair("::rnd_pos()", "::doUpdateRecord()"));
43
44@@ -66,6 +71,7 @@
45
46 states.insert(state_pair("::rnd_next()", "::doEndTableScan()"));
47 states.insert(state_pair("::rnd_next()", "::rnd_next()"));
48+
49 states.insert(state_pair("::doEndTableScan()", "::close()"));
50 states.insert(state_pair("::doEndTableScan()", "::doStartTableScan()"));
51
52@@ -86,4 +92,25 @@
53
54 states.insert(state_pair("::doUpdateRecord()", "::doEndTableScan()"));
55 states.insert(state_pair("::doUpdateRecord()", "::rnd_next()"));
56+
57+ states.insert(state_pair("locked", "::doStartIndexScan()"));
58+ states.insert(state_pair("::doStartIndexScan()", "::doEndIndexScan()"));
59+ states.insert(state_pair("::doEndIndexScan()", "locked"));
60+
61+ states.insert(state_pair("::doStartIndexScan()", "::index_first()"));
62+ states.insert(state_pair("::doStartIndexScan()", "::index_last()"));
63+ states.insert(state_pair("::doStartIndexScan()", "::index_next()"));
64+ states.insert(state_pair("::doStartIndexScan()", "::index_prev()"));
65+ states.insert(state_pair("::index_first()", "::doStartIndexScan()"));
66+ states.insert(state_pair("::index_last()", "::doStartIndexScan()"));
67+ states.insert(state_pair("::index_next()", "::doStartIndexScan()"));
68+ states.insert(state_pair("::index_prev()", "::doStartIndexScan()"));
69+ states.insert(state_pair("::doStartIndexScan()", "::doStartIndexScan() ERROR"));
70+ states.insert(state_pair("::doStartIndexScan() ERROR", "locked"));
71+
72+ states.insert(state_pair("::doStartIndexScan()", "::index_read()"));
73+ states.insert(state_pair("::doStartIndexScan()", "::index_read_idx_map()"));
74+ states.insert(state_pair("::index_read()", "::doStartIndexScan()"));
75+ states.insert(state_pair("::index_read_idx_map()", "::doStartIndexScan()"));
76+
77 }
78
79=== modified file 'plugin/storage_engine_api_tester/engine_states.cc'
80--- plugin/storage_engine_api_tester/engine_states.cc 2011-02-11 05:04:11 +0000
81+++ plugin/storage_engine_api_tester/engine_states.cc 2011-02-17 08:09:59 +0000
82@@ -45,6 +45,7 @@
83 states.insert(state_pair("::max_supported_key_part_length()", "::max_supported_key_part_length()"));
84 states.insert(state_pair("::max_supported_key_part_length()", "::doCreateTable()"));
85
86+ states.insert(state_pair("::max_supported_key_parts()", "::max_supported_key_parts()"));
87 states.insert(state_pair("::max_supported_key_parts()", "::max_supported_keys()"));
88
89 // what the
90
91=== modified file 'plugin/storage_engine_api_tester/storage_engine_api_tester.cc'
92--- plugin/storage_engine_api_tester/storage_engine_api_tester.cc 2011-02-11 23:30:04 +0000
93+++ plugin/storage_engine_api_tester/storage_engine_api_tester.cc 2011-02-17 08:09:59 +0000
94@@ -53,13 +53,17 @@
95 -------------------------------
96
97 IF you add a new error injection, document it here!
98+ You test via error_injected variable.
99
100 Conflicting error inject numbers will lead to tears
101 (not Borsch, Vodka and Tears - that's quite nice).
102
103+ 0 - DISABLED
104+
105 1 - doInsertRecord(): every 2nd row, LOCK_WAIT_TIMEOUT.
106 2 - doInsertRecord(): every 2nd row, DEADLOCK.
107 3 - rnd_next(): every 2nd row, LOCK_WAIT_TIMEOUT
108+ 4 - doStartIndexScan returns an error.
109 */
110 static uint32_t error_injected= 0;
111
112@@ -178,6 +182,29 @@
113 int doStartTableScan(bool scan) { CURSOR_NEW_STATE("::doStartTableScan()"); return realCursor->doStartTableScan(scan); }
114 int doEndTableScan() { CURSOR_NEW_STATE("::doEndTableScan()"); return realCursor->doEndTableScan(); }
115
116+ const char *index_type(uint32_t key_number);
117+
118+ int doStartIndexScan(uint32_t, bool);
119+ int index_read(unsigned char *buf, const unsigned char *key_ptr,
120+ uint32_t key_len, drizzled::ha_rkey_function find_flag);
121+ int index_read_idx_map(unsigned char * buf,
122+ uint32_t index,
123+ const unsigned char * key,
124+ drizzled::key_part_map keypart_map,
125+ drizzled::ha_rkey_function find_flag);
126+
127+ int index_next(unsigned char * buf);
128+ int doEndIndexScan();
129+ int index_prev(unsigned char * buf);
130+ int index_first(unsigned char * buf);
131+ int index_last(unsigned char * buf);
132+
133+ bool primary_key_is_clustered()
134+ {
135+ return realCursor->primary_key_is_clustered();
136+ }
137+
138+
139 int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);
140
141 THR_LOCK_DATA **store_lock(Session *,
142@@ -212,6 +239,18 @@
143 return realCursor->doUpdateRecord(old_row, new_row);
144 }
145
146+ double scan_time()
147+ {
148+ CURSOR_NEW_STATE("::scan_time()");
149+ CURSOR_NEW_STATE("locked");
150+ return realCursor->scan_time();
151+ }
152+
153+ int extra(enum ha_extra_function operation)
154+ {
155+ return realCursor->extra(operation);
156+ }
157+
158 private:
159 string cursor_state;
160 void CURSOR_NEW_STATE(const string &new_state);
161@@ -257,10 +296,106 @@
162
163 int SEAPITesterCursor::info(uint32_t flag)
164 {
165+ int r;
166 CURSOR_NEW_STATE("::info()");
167 CURSOR_NEW_STATE("locked");
168
169- return realCursor->info(flag);
170+ r= realCursor->info(flag);
171+
172+ if (flag & (HA_STATUS_VARIABLE|HA_STATUS_AUTO|HA_STATUS_CONST))
173+ {
174+ stats= realCursor->stats;
175+ }
176+
177+ if (flag & HA_STATUS_ERRKEY)
178+ errkey= realCursor->errkey;
179+
180+ return r;
181+}
182+
183+const char * SEAPITesterCursor::index_type(uint32_t key_number)
184+{
185+ CURSOR_NEW_STATE("::index_type()");
186+ return realCursor->index_type(key_number);
187+}
188+
189+int SEAPITesterCursor::doStartIndexScan(uint32_t keynr, bool scan)
190+{
191+ int r;
192+ CURSOR_NEW_STATE("::doStartIndexScan()");
193+
194+ if (error_injected == 4)
195+ {
196+ CURSOR_NEW_STATE("::doStartIndexScan() ERROR");
197+ CURSOR_NEW_STATE("locked");
198+ return HA_ERR_LOCK_DEADLOCK;
199+ }
200+
201+ r= realCursor->doStartIndexScan(keynr, scan);
202+
203+ active_index= realCursor->get_index();
204+
205+ return r;
206+}
207+
208+int SEAPITesterCursor::index_read(unsigned char *buf,
209+ const unsigned char *key_ptr,
210+ uint32_t key_len,
211+ drizzled::ha_rkey_function find_flag)
212+{
213+ CURSOR_NEW_STATE("::index_read()");
214+ CURSOR_NEW_STATE("::doStartIndexScan()");
215+ return realCursor->index_read(buf, key_ptr, key_len, find_flag);
216+}
217+
218+int SEAPITesterCursor::index_read_idx_map(unsigned char * buf,
219+ uint32_t index,
220+ const unsigned char * key,
221+ drizzled::key_part_map keypart_map,
222+ drizzled::ha_rkey_function find_flag)
223+{
224+ CURSOR_NEW_STATE("::index_read_idx_map()");
225+ CURSOR_NEW_STATE("locked");
226+ return realCursor->index_read_idx_map(buf, index, key, keypart_map, find_flag);
227+}
228+
229+int SEAPITesterCursor::index_next(unsigned char * buf)
230+{
231+ CURSOR_NEW_STATE("::index_next()");
232+ CURSOR_NEW_STATE("::doStartIndexScan()");
233+ return realCursor->index_next(buf);
234+}
235+
236+int SEAPITesterCursor::doEndIndexScan()
237+{
238+ CURSOR_NEW_STATE("::doEndIndexScan()");
239+ CURSOR_NEW_STATE("locked");
240+ int r= realCursor->doEndIndexScan();
241+
242+ active_index= realCursor->get_index();
243+
244+ return r;
245+}
246+
247+int SEAPITesterCursor::index_prev(unsigned char * buf)
248+{
249+ CURSOR_NEW_STATE("::index_prev()");
250+ CURSOR_NEW_STATE("::doStartIndexScan()");
251+ return realCursor->index_prev(buf);
252+}
253+
254+int SEAPITesterCursor::index_first(unsigned char * buf)
255+{
256+ CURSOR_NEW_STATE("::index_first()");
257+ CURSOR_NEW_STATE("::doStartIndexScan()");
258+ return realCursor->index_first(buf);
259+}
260+
261+int SEAPITesterCursor::index_last(unsigned char * buf)
262+{
263+ CURSOR_NEW_STATE("::index_last()");
264+ CURSOR_NEW_STATE("::doStartIndexScan()");
265+ return realCursor->index_last(buf);
266 }
267
268 int SEAPITesterCursor::external_lock(Session *session, int lock_type)
269@@ -437,6 +572,16 @@
270 return getRealEngine()->max_supported_key_part_length();
271 }
272
273+ /* just copied from innobase... */
274+ uint32_t index_flags(enum ha_key_alg) const
275+ {
276+ return (HA_READ_NEXT |
277+ HA_READ_PREV |
278+ HA_READ_RANGE |
279+ HA_READ_ORDER |
280+ HA_KEYREAD_ONLY);
281+ }
282+
283 };
284
285 bool SEAPITester::doDoesTableExist(Session &session, const identifier::Table &identifier)
286
287=== added file 'plugin/storage_engine_api_tester/tests/r/min_index_scan_error.result'
288--- plugin/storage_engine_api_tester/tests/r/min_index_scan_error.result 1970-01-01 00:00:00 +0000
289+++ plugin/storage_engine_api_tester/tests/r/min_index_scan_error.result 2011-02-17 08:09:59 +0000
290@@ -0,0 +1,35 @@
291+create table t1 (a int primary key auto_increment, b int, index(b)) engine=storage_engine_api_tester;
292+show create table t1;
293+Table Create Table
294+t1 CREATE TABLE `t1` (
295+ `a` INT NOT NULL AUTO_INCREMENT,
296+ `b` INT DEFAULT NULL,
297+ PRIMARY KEY (`a`),
298+ KEY `b` (`b`)
299+) ENGINE=STORAGE_ENGINE_API_TESTER COLLATE = utf8_general_ci
300+insert into t1 (b) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
301+insert into t1 (b) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
302+explain select min(b) from t1;
303+id select_type table type possible_keys key key_len ref rows Extra
304+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
305+SELECT seapitester_error_inject(4);
306+seapitester_error_inject(4)
307+4
308+select seapitester_clear_engine_state_history();
309+seapitester_clear_engine_state_history()
310+0
311+select min(b) from t1;
312+Got one of the listed errors
313+select * from data_dictionary.seapitester_engine_state_history;
314+STATE
315+START STATEMENT
316+END STATEMENT
317+ROLLBACK
318+::SEAPITester()
319+select seapitester_clear_engine_state_history();
320+seapitester_clear_engine_state_history()
321+0
322+SELECT seapitester_error_inject(0);
323+seapitester_error_inject(0)
324+0
325+drop table t1;
326
327=== added file 'plugin/storage_engine_api_tester/tests/t/min_index_scan_error.test'
328--- plugin/storage_engine_api_tester/tests/t/min_index_scan_error.test 1970-01-01 00:00:00 +0000
329+++ plugin/storage_engine_api_tester/tests/t/min_index_scan_error.test 2011-02-17 08:09:59 +0000
330@@ -0,0 +1,13 @@
331+create table t1 (a int primary key auto_increment, b int, index(b)) engine=storage_engine_api_tester;
332+show create table t1;
333+insert into t1 (b) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
334+insert into t1 (b) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
335+explain select min(b) from t1;
336+SELECT seapitester_error_inject(4);
337+select seapitester_clear_engine_state_history();
338+--error ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
339+select min(b) from t1;
340+select * from data_dictionary.seapitester_engine_state_history;
341+select seapitester_clear_engine_state_history();
342+SELECT seapitester_error_inject(0);
343+drop table t1;

Subscribers

People subscribed via source and target branches