diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2010-10-31 22:00:15 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2010-10-31 22:00:15 +0300 |
commit | d9a8dd22b2e88e9ef0844c32fa442ed6d3f8bc56 (patch) | |
tree | 69e114f52d8a9ee8f5569569b27ad0ba9554973c | |
parent | 8e4c627ef8bff737e072fde733ee39351c17f70b (diff) | |
download | mariadb-git-d9a8dd22b2e88e9ef0844c32fa442ed6d3f8bc56.tar.gz |
DS-MRR/CPK improvements: correct buffer exhaustion handling
-rw-r--r-- | sql/multi_range_read.cc | 25 | ||||
-rw-r--r-- | sql/multi_range_read.h | 12 |
2 files changed, 25 insertions, 12 deletions
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index a968cf2da52..c9f3785b231 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -484,7 +484,7 @@ int Mrr_ordered_index_reader::refill_buffer() scanning_key_val_iter= FALSE; index_scan_eof= FALSE; - DBUG_RETURN(0); + DBUG_RETURN((no_more_keys && key_buffer->is_empty())? HA_ERR_END_OF_FILE:0); } @@ -521,8 +521,11 @@ int Mrr_ordered_rndpos_reader::init(handler *h_arg, //rowid_buff_elem_size= h->ref_length; //if (!(mode & HA_MRR_NO_ASSOCIATION)) // rowid_buff_elem_size += sizeof(char*); - - return index_reader->refill_buffer(); + + int res= index_reader->refill_buffer(); + if (res && res!=HA_ERR_END_OF_FILE) + return res; + return 0; } @@ -561,7 +564,7 @@ int Mrr_ordered_rndpos_reader::refill_buffer() last_identical_rowid= NULL; if (index_reader->eof()) - DBUG_RETURN(0); + DBUG_RETURN(HA_ERR_END_OF_FILE); while (rowid_buffer->can_write()) { @@ -584,9 +587,9 @@ int Mrr_ordered_rndpos_reader::refill_buffer() rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)h); rowid_buffer->setup_reading(&rowid, h->ref_length, - is_mrr_assoc? (uchar**)&rowids_range_id: NULL, + is_mrr_assoc? (uchar**)&rowids_range_id: NULL, sizeof(void*)); - DBUG_RETURN(0); + DBUG_RETURN((rowid_buffer->is_empty() && res) ? HA_ERR_END_OF_FILE : 0); } @@ -632,8 +635,9 @@ int Mrr_ordered_rndpos_reader::get_next(char **range_info) /* First, finish off the sorted keys we have */ if (!index_reader->eof()) { - if ((res= refill_buffer())) - return res; /* for fatal errors */ + res= refill_buffer(); + if (res && res != HA_ERR_END_OF_FILE) + return res; } if (rowid_buffer->is_empty()) @@ -821,8 +825,9 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, goto error; } } - - if (strategy->refill_buffer()) + + res= strategy->refill_buffer(); + if (res && res != HA_ERR_END_OF_FILE) goto error; /* diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index a7748a32b6b..b4f2a699dc5 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -126,8 +126,16 @@ public: index tuple or a table record. Getting HA_ERR_END_OF_FILE from get_next() means that the source should be - re-filled. if eof() returns true after refill attempt, then the end of + re-filled. + + Was: + if eof() returns true after refill attempt, then the end of stream has been reached and get_next() must not be called anymore. + + Now: + if refill_buffer() returns HA_ERR_END_OF_FILE that means the stream is + really exhausted. + */ class Mrr_reader @@ -168,7 +176,7 @@ public: void *seq_init_param, uint n_ranges, uint mode, Buffer_manager *buf_manager_arg); int get_next(char **range_info); - int refill_buffer() { return 0; } + int refill_buffer() { return HA_ERR_END_OF_FILE; } bool eof() { return test(res); } uchar *get_rowid_ptr() { return h->ref; } bool skip_record(char *range_id, uchar *rowid) |