diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-07-08 20:43:57 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-07-08 20:43:57 +0530 |
commit | 7148b846738412517bf4998128ba66a277721630 (patch) | |
tree | 1f8fd175dbd5a25da4d96a0a623f867becb2e805 /sql/filesort.cc | |
parent | 9701759b3d9ea9fd9bee640ce27171bdd51b7e78 (diff) | |
download | mariadb-git-7148b846738412517bf4998128ba66a277721630.tar.gz |
MDEV-13694: Wrong result upon GROUP BY with orderby_uses_equalities=on
For the case when the SJM scan table is the first table in the join order,
then if we want to do the sorting on the SJM scan table, then we need to
make sure that we unpack the values to base table fields in two cases:
1) Reading the SJM table and writing the sort-keys inside the sort-buffer
2) Reading the sorted data from the sort file
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r-- | sql/filesort.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index f5d57a36685..03af9c7b49a 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -251,6 +251,9 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort, param.init_for_filesort(sort_len, table, max_rows, filesort->sort_positions); + param.set_all_read_bits= filesort->set_all_read_bits; + param.unpack= filesort->unpack; + sort->addon_fields= param.addon_fields; sort->sort_keys= param.sort_keys; @@ -883,6 +886,8 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, goto err; } + if (param->set_all_read_bits) + sort_form->column_bitmaps_set(save_read_set, save_write_set); DEBUG_SYNC(thd, "after_index_merge_phase1"); for (;;) @@ -890,7 +895,11 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, if (quick_select) error= select->quick->get_next(); else /* Not quick-select */ + { error= file->ha_rnd_next(sort_form->record[0]); + if (param->unpack) + param->unpack(sort_form); + } if (unlikely(error)) break; file->position(sort_form->record[0]); |