summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 22464ec9675..df03a0d30e7 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2973,6 +2973,7 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
THD_STAGE_INFO(thd, stage_sorting_for_group);
if (ordered_index_usage != ordered_index_group_by &&
+ !only_const_tables() &&
(join_tab + const_tables)->type != JT_CONST && // Don't sort 1 row
!implicit_grouping &&
add_sorting_to_table(join_tab + const_tables, group_list))
@@ -3006,6 +3007,7 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
THD_STAGE_INFO(thd, stage_sorting_for_order);
if (ordered_index_usage != ordered_index_order_by &&
+ !only_const_tables() &&
add_sorting_to_table(join_tab + const_tables, order))
goto err;
order= NULL;