• Jorgen Loland's avatar
    BUG#58456 - Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output · 47b774b2
    Jorgen Loland authored
                in opt_range.h
    
    In this bug, there are two alternative access plans: 
     * Index merge range access
     * Const ref access
    
    best_access_path() decided that the ref access was preferrable, 
    but make_join_select() still decided to point 
    SQL_SELECT::quick to the index merge because the table had 
    type==JT_CONST which was not handled. 
    
    At the same time the table's ref.key still referred to the 
    index the ref access would use indicating that ref access 
    should be used. In this state, different parts of the 
    optimizer code have different perceptions of which access path
    is in use (ref or range).
    
    test_if_skip_sort_order() was called to check if the ref access
    needed ordering, but test_if_skip_sort_order() got confused and
    requested the index merge to return records in sorted order. 
    Index merge cannot do this, and fired an ASSERT.
    
    The fix is to take join_tab->type==JT_CONST into concideration
    when make_join_select() decides whether or not to use the 
    range access method.
    
    mysql-test/r/join_outer_innodb.result:
      Add test for BUG#58456
    mysql-test/t/join_outer_innodb.test:
      Add test for BUG#58456
    47b774b2
sql_select.cc 566 KB