Merge lp:~stewart/drizzle/bug588251-startScan-unused-result into lp:drizzle/7.0

Proposed by Stewart Smith
Status: Merged
Merged at revision: 2067
Proposed branch: lp:~stewart/drizzle/bug588251-startScan-unused-result
Merge into: lp:drizzle/7.0
Diff against target: 362 lines (+83/-40)
13 files modified
drizzled/cursor.cc (+6/-3)
drizzled/cursor.h (+2/-2)
drizzled/filesort.cc (+4/-2)
drizzled/item/subselect.cc (+6/-1)
drizzled/optimizer/quick_index_merge_select.cc (+5/-1)
drizzled/records.cc (+20/-9)
drizzled/records.h (+5/-5)
drizzled/sql_delete.cc (+7/-1)
drizzled/sql_select.cc (+8/-3)
drizzled/sql_update.cc (+10/-3)
drizzled/statement/alter_table.cc (+7/-1)
plugin/haildb/haildb_engine.cc (+3/-8)
plugin/haildb/haildb_engine.h (+0/-1)
To merge this branch: bzr merge lp:~stewart/drizzle/bug588251-startScan-unused-result
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+45248@code.launchpad.net

Description of the change

make sure we're checking some return codes from the engines.

seems to be building okay (would have thought the warn_unused_result would die on Solaris) http://hudson.drizzle.org/view/Drizzle-param/job/drizzle-param/697/

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/cursor.cc'
2--- drizzled/cursor.cc 2010-12-20 16:56:48 +0000
3+++ drizzled/cursor.cc 2011-01-05 14:51:09 +0000
4@@ -278,9 +278,12 @@
5 if (stats.deleted < 10 || primary_key >= MAX_KEY ||
6 !(getTable()->index_flags(primary_key) & HA_READ_ORDER))
7 {
8- (void) startTableScan(1);
9- while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
10- (void) endTableScan();
11+ error= startTableScan(1);
12+ if (error == 0)
13+ {
14+ while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
15+ (void) endTableScan();
16+ }
17 }
18 else
19 {
20
21=== modified file 'drizzled/cursor.h'
22--- drizzled/cursor.h 2010-12-24 07:15:43 +0000
23+++ drizzled/cursor.h 2011-01-05 14:51:09 +0000
24@@ -234,7 +234,7 @@
25 int ha_open(const TableIdentifier &identifier, int mode, int test_if_locked);
26 int startIndexScan(uint32_t idx, bool sorted);
27 int endIndexScan();
28- int startTableScan(bool scan);
29+ int startTableScan(bool scan) __attribute__ ((warn_unused_result));
30 int endTableScan();
31 int ha_reset();
32
33@@ -535,7 +535,7 @@
34 if rnd_init allocates the cursor, second call should position it
35 to the start of the table, no need to deallocate and allocate it again
36 */
37- virtual int doStartTableScan(bool scan)= 0;
38+ virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;
39 virtual int doEndTableScan() { return 0; }
40 virtual int doInsertRecord(unsigned char *)
41 {
42
43=== modified file 'drizzled/filesort.cc'
44--- drizzled/filesort.cc 2010-12-26 17:38:28 +0000
45+++ drizzled/filesort.cc 2011-01-05 14:51:09 +0000
46@@ -564,7 +564,8 @@
47 if (! indexfile && ! quick_select)
48 {
49 next_pos=(unsigned char*) 0; /* Find records in sequence */
50- file->startTableScan(1);
51+ if (file->startTableScan(1))
52+ return(HA_POS_ERROR);
53 file->extra_opt(HA_EXTRA_CACHE, getSession().variables.read_buff_size);
54 }
55
56@@ -574,7 +575,8 @@
57 if (select->quick->reset())
58 return(HA_POS_ERROR);
59
60- read_record_info.init_read_record(&getSession(), select->quick->head, select, 1, 1);
61+ if (read_record_info.init_read_record(&getSession(), select->quick->head, select, 1, 1))
62+ return(HA_POS_ERROR);
63 }
64
65 /* Remember original bitmaps */
66
67=== modified file 'drizzled/item/subselect.cc'
68--- drizzled/item/subselect.cc 2010-12-25 01:27:46 +0000
69+++ drizzled/item/subselect.cc 2011-01-05 14:51:09 +0000
70@@ -2290,7 +2290,12 @@
71 if (table->cursor->inited)
72 table->cursor->endIndexScan();
73
74- table->cursor->startTableScan(1);
75+ if ((error= table->cursor->startTableScan(1)))
76+ {
77+ table->print_error(error, MYF(0));
78+ return 1;
79+ }
80+
81 table->cursor->extra_opt(HA_EXTRA_CACHE,
82 current_session->variables.read_buff_size);
83 table->null_row= 0;
84
85=== modified file 'drizzled/optimizer/quick_index_merge_select.cc'
86--- drizzled/optimizer/quick_index_merge_select.cc 2010-12-18 04:43:40 +0000
87+++ drizzled/optimizer/quick_index_merge_select.cc 2011-01-05 14:51:09 +0000
88@@ -177,7 +177,11 @@
89 /* index_merge currently doesn't support "using index" at all */
90 cursor->extra(HA_EXTRA_NO_KEYREAD);
91 /* start table scan */
92- read_record.init_read_record(session, head, (optimizer::SqlSelect*) 0, 1, 1);
93+ if ((result= read_record.init_read_record(session, head, (optimizer::SqlSelect*) 0, 1, 1)))
94+ {
95+ head->print_error(result, MYF(0));
96+ return 0;
97+ }
98 return result;
99 }
100
101
102=== modified file 'drizzled/records.cc'
103--- drizzled/records.cc 2010-11-08 20:00:45 +0000
104+++ drizzled/records.cc 2011-01-05 14:51:09 +0000
105@@ -67,13 +67,14 @@
106 }
107
108
109-void ReadRecord::init_read_record(Session *session_arg,
110- Table *table_arg,
111- optimizer::SqlSelect *select_arg,
112- int use_record_cache,
113- bool print_error_arg)
114+int ReadRecord::init_read_record(Session *session_arg,
115+ Table *table_arg,
116+ optimizer::SqlSelect *select_arg,
117+ int use_record_cache,
118+ bool print_error_arg)
119 {
120 internal::IO_CACHE *tempfile;
121+ int error= 0;
122
123 session= session_arg;
124 table= table_arg;
125@@ -114,7 +115,11 @@
126 io_cache->reinit_io_cache(internal::READ_CACHE,0L,0,0);
127 ref_pos=table->cursor->ref;
128 if (!table->cursor->inited)
129- table->cursor->startTableScan(0);
130+ {
131+ error= table->cursor->startTableScan(0);
132+ if (error != 0)
133+ return error;
134+ }
135
136 /*
137 table->sort.addon_field is checked because if we use addon fields,
138@@ -146,7 +151,10 @@
139 }
140 else if (table->sort.record_pointers)
141 {
142- table->cursor->startTableScan(0);
143+ error= table->cursor->startTableScan(0);
144+ if (error != 0)
145+ return error;
146+
147 cache_pos=table->sort.record_pointers;
148 cache_end= cache_pos+ table->sort.found_records * ref_length;
149 read_record= (table->sort.addon_field ? rr_unpack_from_buffer : rr_from_pointers);
150@@ -154,7 +162,10 @@
151 else
152 {
153 read_record= rr_sequential;
154- table->cursor->startTableScan(1);
155+ error= table->cursor->startTableScan(1);
156+ if (error != 0)
157+ return error;
158+
159 /* We can use record cache if we don't update dynamic length tables */
160 if (!table->no_cache &&
161 (use_record_cache > 0 ||
162@@ -165,7 +176,7 @@
163 }
164 }
165
166- return;
167+ return 0;
168 } /* init_read_record */
169
170
171
172=== modified file 'drizzled/records.h'
173--- drizzled/records.h 2010-12-18 04:43:40 +0000
174+++ drizzled/records.h 2011-01-05 14:51:09 +0000
175@@ -181,11 +181,11 @@
176 This is the most basic access method of a table using rnd_init,
177 rnd_next and rnd_end. No indexes are used.
178 */
179- void init_read_record(Session *session,
180- Table *reg_form,
181- optimizer::SqlSelect *select,
182- int use_record_cache,
183- bool print_errors);
184+ int init_read_record(Session *session,
185+ Table *reg_form,
186+ optimizer::SqlSelect *select,
187+ int use_record_cache,
188+ bool print_errors) __attribute__ ((warn_unused_result));
189
190 void end_read_record();
191
192
193=== modified file 'drizzled/sql_delete.cc'
194--- drizzled/sql_delete.cc 2010-12-24 07:15:43 +0000
195+++ drizzled/sql_delete.cc 2011-01-05 14:51:09 +0000
196@@ -241,7 +241,13 @@
197
198 if (usable_index==MAX_KEY)
199 {
200- info.init_read_record(session,table,select,1,1);
201+ if ((error= info.init_read_record(session,table,select,1,1)))
202+ {
203+ table->print_error(error, MYF(0));
204+ delete select;
205+ free_underlaid_joins(session, select_lex);
206+ return true;
207+ }
208 }
209 else
210 {
211
212=== modified file 'drizzled/sql_select.cc'
213--- drizzled/sql_select.cc 2010-12-24 07:15:43 +0000
214+++ drizzled/sql_select.cc 2011-01-05 14:51:09 +0000
215@@ -3728,7 +3728,8 @@
216 if (tab->select && tab->select->quick && tab->select->quick->reset())
217 return 1;
218
219- tab->read_record.init_read_record(tab->join->session, tab->table, tab->select, 1, true);
220+ if (tab->read_record.init_read_record(tab->join->session, tab->table, tab->select, 1, true))
221+ return 1;
222
223 return (*tab->read_record.read_record)(&tab->read_record);
224 }
225@@ -5099,7 +5100,9 @@
226 org_record=(char*) (record=table->getInsertRecord())+offset;
227 new_record=(char*) table->getUpdateRecord()+offset;
228
229- cursor->startTableScan(1);
230+ if ((error= cursor->startTableScan(1)))
231+ goto err;
232+
233 error=cursor->rnd_next(record);
234 for (;;)
235 {
236@@ -5216,7 +5219,9 @@
237 return(1);
238 }
239
240- cursor->startTableScan(1);
241+ if ((error= cursor->startTableScan(1)))
242+ goto err;
243+
244 key_pos= &key_buffer[0];
245 for (;;)
246 {
247
248=== modified file 'drizzled/sql_update.cc'
249--- drizzled/sql_update.cc 2010-12-24 07:15:43 +0000
250+++ drizzled/sql_update.cc 2011-01-05 14:51:09 +0000
251@@ -136,7 +136,7 @@
252 bool using_limit= limit != HA_POS_ERROR;
253 bool used_key_is_modified;
254 bool transactional_table;
255- int error;
256+ int error= 0;
257 uint used_index= MAX_KEY, dup_key_found;
258 bool need_sort= true;
259 ha_rows updated, found;
260@@ -363,7 +363,8 @@
261
262 if (used_index == MAX_KEY || (select && select->quick))
263 {
264- info.init_read_record(session, table, select, 0, true);
265+ if ((error= info.init_read_record(session, table, select, 0, true)))
266+ goto err;
267 }
268 else
269 {
270@@ -433,7 +434,10 @@
271 if (select && select->quick && select->quick->reset())
272 goto err;
273 table->cursor->try_semi_consistent_read(1);
274- info.init_read_record(session, table, select, 0, true);
275+ if ((error= info.init_read_record(session, table, select, 0, true)))
276+ {
277+ goto err;
278+ }
279
280 updated= found= 0;
281 /*
282@@ -580,6 +584,9 @@
283 return ((error >= 0 || session->is_error()) ? 1 : 0);
284
285 err:
286+ if (error != 0)
287+ table->print_error(error,MYF(0));
288+
289 delete select;
290 free_underlaid_joins(session, select_lex);
291 if (table->key_read)
292
293=== modified file 'drizzled/statement/alter_table.cc'
294--- drizzled/statement/alter_table.cc 2010-12-24 07:15:43 +0000
295+++ drizzled/statement/alter_table.cc 2011-01-05 14:51:09 +0000
296@@ -1522,7 +1522,13 @@
297
298 /* Tell handler that we have values for all columns in the to table */
299 to->use_all_columns();
300- info.init_read_record(session, from, (optimizer::SqlSelect *) 0, 1, true);
301+ error= info.init_read_record(session, from, (optimizer::SqlSelect *) 0, 1, true);
302+ if (error)
303+ {
304+ to->print_error(errno, MYF(0));
305+ goto err;
306+ }
307+
308 if (ignore)
309 to->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
310 session->row_count= 0;
311
312=== modified file 'plugin/haildb/haildb_engine.cc'
313--- plugin/haildb/haildb_engine.cc 2010-12-30 18:10:25 +0000
314+++ plugin/haildb/haildb_engine.cc 2011-01-05 14:51:09 +0000
315@@ -2212,14 +2212,13 @@
316 err= ib_cursor_first(cursor);
317 if (err != DB_SUCCESS && err != DB_END_OF_INDEX)
318 {
319- previous_error= ib_err_t_to_drizzle_error(err);
320- err= ib_cursor_reset(cursor);
321- return previous_error;
322+ int reset_err= ib_cursor_reset(cursor);
323+ assert(reset_err == DB_SUCCESS);
324+ return ib_err_t_to_drizzle_error(err);
325 }
326
327 advance_cursor= false;
328
329- previous_error= 0;
330 return(0);
331 }
332
333@@ -2315,9 +2314,6 @@
334 ib_err_t err;
335 int ret;
336
337- if (previous_error)
338- return previous_error;
339-
340 if (advance_cursor)
341 {
342 err= ib_cursor_next(cursor);
343@@ -2343,7 +2339,6 @@
344 err= ib_cursor_reset(cursor);
345 assert(err == DB_SUCCESS);
346 in_table_scan= false;
347- previous_error= 0;
348 return ib_err_t_to_drizzle_error(err);
349 }
350
351
352=== modified file 'plugin/haildb/haildb_engine.h'
353--- plugin/haildb/haildb_engine.h 2010-12-13 06:37:07 +0000
354+++ plugin/haildb/haildb_engine.h 2011-01-05 14:51:09 +0000
355@@ -122,7 +122,6 @@
356 ib_tpl_t tuple;
357 bool advance_cursor;
358 ib_lck_mode_t ib_lock_mode;
359- int previous_error;
360 bool cursor_is_sec_index;
361
362 bool write_can_replace;

Subscribers

People subscribed via source and target branches