• unknown's avatar
    Fix LP BUG#680943 · 1b3336dc
    unknown authored
    Analysis:
    The problem lies in filesort.cc:find_all_keys().
    
    When find_all_keys() is called for the outer query, it resets all
    of the tree sets of fields - [read,write,vcol]_set and recomputes
    them with respect to sorting.
    
    However, in the loop for each current record the procedure calls
    select->skip_record(thd), which evaluates the where clause, which
    in turns evaluates the subquery. The JOIN evaluation of the
    subquery eventually calls Field_long::val_int to evaluate the field
    alias1.f1. The assertion condition
      "bitmap_is_set(table->read_set, field_index)"
    fails, because the outer query changed the read_set of table "alias1".
    
    Solution:
    Restore the original read_set of the table before calling
    SQL_SELECT::skip_record, then revert back to the read_set used in
    find_all_keys.
    1b3336dc
subselect4.result 22.4 KB