Commit cb164640 authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #801536.

Ensured valid calculations of the estimates stored in JOIN_TAB::used_fieldlength.
parent 77f8874c
...@@ -6492,7 +6492,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, ...@@ -6492,7 +6492,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
void JOIN_TAB::calc_used_field_length(bool max_fl) void JOIN_TAB::calc_used_field_length(bool max_fl)
{ {
uint null_fields,blobs,fields,rec_length; uint null_fields,blobs,fields;
ulong rec_length;
Field **f_ptr,*field; Field **f_ptr,*field;
uint uneven_bit_fields; uint uneven_bit_fields;
MY_BITMAP *read_set= table->read_set; MY_BITMAP *read_set= table->read_set;
...@@ -6523,9 +6524,11 @@ void JOIN_TAB::calc_used_field_length(bool max_fl) ...@@ -6523,9 +6524,11 @@ void JOIN_TAB::calc_used_field_length(bool max_fl)
// TODO: to improve this estimate for max expected length // TODO: to improve this estimate for max expected length
if (blobs) if (blobs)
{ {
uint blob_length=(uint) (table->file->stats.mean_rec_length- ulong blob_length= table->file->stats.mean_rec_length;
(table->s->reclength-rec_length)); if (ULONG_MAX - rec_length > blob_length)
rec_length+=(uint) max(sizeof(void*) * blobs, blob_length); rec_length+= blob_length;
else
rec_length= ULONG_MAX;
} }
max_used_fieldlength= rec_length; max_used_fieldlength= rec_length;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment