1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-28 13:01:41 +03:00
Ole John Aske 221ce9223d Fix for bug#59308: Incorrect result for SELECT DISTINCT <col>... ORDER BY <col> DESC.
Also fix bug#59110: Memory leak of QUICK_SELECT_I allocated memory.
Includes Jørgen Lølands review comments.
      
Root cause of these bugs are that test_if_skip_sort_order() decided to
revert the 'skip_sort_order' descision (and use filesort) after the
query plan has been updated to reflect a 'skip' of the sort order.
      
This might happen in 'check_reverse_order:' if we have a 
select->quick which could not be made descending by appending 
a QUICK_SELECT_DESC. ().
      
The original 'save_quick' was then restored after the QEP has been modified,
which caused:
      
  - An incorrect 'precomputed_group_by= TRUE' may have been set, 
    and not reverted, as part of the already modifified QEP (Bug#59308)
  - A 'select->quick' might have been created which we fail to delete (bug#59110).
      
This fix is a refactorication of test_if_skip_sort_order() where all logic
related to modification of QEP (controlled by argument 'bool no_changes'), is
moved to the end of test_if_skip_sort_order(), and done after *all* 'test_if_skip'
checks has been performed - including the 'check_reverse_order:' checks.
      
The refactorication above contains now intentional changes to the logic which 
has been moved to the end of the function.
      
Furthermore, a smaller part of the fix address the handling of the 
select->quick objects which may already exists when we call 
'test_if_skip_sort_order()' (save_quick) -and
new select->quick's created during test_if_skip_sort_order():
      
  - Before new select->quick may be created by calling ::test_quick_select(), we
    set 'select->quick= 0' to avoid that ::test_quick_select() prematurely
    delete the save_quick's. (After this call we may have both a 'save_quick' 
    and 'select->quick')
      
  - All returns from ::test_if_skip_sort_order() where we may have both a
    'save_quick' and a 'select->quick' has been changed to goto's to the
    exit points 'skiped_sort_order:' or 'need_filesort:' where we
    decide which of the QUICK_SELECT's to keep, and delete the other.
2011-02-07 10:36:21 +01:00
..
2009-02-09 22:00:15 +01:00
2010-02-25 23:13:11 +04:00
2009-02-09 22:00:15 +01:00
2011-01-25 12:14:28 +05:30
2010-03-09 16:09:32 +01:00
2009-09-29 17:38:40 +02:00
2010-12-14 12:33:03 +03:00
2010-12-21 15:30:07 +03:00
2009-02-06 18:25:08 +01:00
2011-02-02 20:13:11 +02:00
2009-05-06 15:00:14 +05:30
2009-09-02 18:58:17 +02:00
2009-10-20 11:00:07 -07:00
2010-12-14 12:33:03 +03:00
2010-01-29 16:54:27 +02:00
2009-02-03 14:45:17 +01:00
2009-08-12 12:03:05 +02:00
2011-01-26 16:50:21 +01:00
2010-10-15 20:13:35 +05:00
2010-01-15 10:51:39 +02:00
2009-07-03 10:19:32 +02:00
2009-11-27 18:10:28 +02:00
2009-12-23 17:44:03 +04:00
2009-06-10 11:58:36 +03:00
2009-02-19 18:24:25 -05:00
2011-02-02 19:05:28 +02:00
2010-12-14 12:33:03 +03:00