Fix for MDEV-4219 A simple select query returns random data (upstream bug#68473)

In the case of loose scan used as input for order by, end_send()
didn't detect correctly that a loose scan was used, and didn't copy
the non-aggregated fields from the temp table used for ORDER BY.
  
The fix uses the fact that the quick select used for sorting is
attached to JOIN::pre_sort_join_tab instead of JOIN::join_tab.
This commit is contained in:
unknown 2013-07-17 16:42:13 +03:00
commit 66ec79fc87
4 changed files with 101 additions and 2 deletions

View file

@ -17404,7 +17404,13 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (!end_of_records)
{
if (join->table_count &&
join->join_tab->is_using_loose_index_scan())
(join->join_tab->is_using_loose_index_scan() ||
/*
When order by used a loose scan as its input, the quick select may
be attached to pre_sort_join_tab.
*/
(join->pre_sort_join_tab &&
join->pre_sort_join_tab->is_using_loose_index_scan())))
{
/* Copy non-aggregated fields when loose index scan is used. */
copy_fields(&join->tmp_table_param);