summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/table.cc3
2 files changed, 7 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 46e1a912250..5075673dcc2 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8125,9 +8125,11 @@ best_extension_by_limited_search(JOIN *join,
best_access_path(join, s, remaining_tables, idx, disable_jbuf,
record_count, join->positions + idx, &loose_scan_pos);
- /* Compute the cost of extending the plan with 's' */
-
- current_record_count= record_count * position->records_read;
+ /* Compute the cost of extending the plan with 's', avoid overflow */
+ if (position->records_read < DBL_MAX / record_count)
+ current_record_count= record_count * position->records_read;
+ else
+ current_record_count= DBL_MAX;
current_read_time=read_time + position->read_time +
current_record_count / (double) TIME_FOR_COMPARE;
diff --git a/sql/table.cc b/sql/table.cc
index 352c6c77691..dd924fa6647 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5720,7 +5720,8 @@ Item *Field_iterator_table::create_item(THD *thd)
Item_field *item= new (thd->mem_root) Item_field(thd, &select->context, *ptr);
if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
- !thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
+ !thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS &&
+ select->join)
{
select->join->non_agg_fields.push_back(item);
item->marker= select->cur_pos_in_select_list;