Skip to content
  • Roy Lyseng's avatar
    055c521e
    Bug#20949117: Remove obsolete code from UNION processing · 055c521e
    Roy Lyseng authored
    After the last refactoring work in preparation and optimization,
    there are some unused code blocks in sql_union.cc.
    This bug fix eliminates those code blocks completely and performs
    some simple additional refactoring.
    
    - Added an interface st_select_lex_unit::is_simple() that wraps
      testing for !(is_union() || fake_select_lex)
    
    - Cleaned up global_parameters() a bit: Only ORDER BY/LIMIT/OFFSET
      should be accessed through it, otherwise use fake_select_lex.
    
    - Initialization of JOIN::do_send_rows was moved from optimization to
      execution, since it is used only in the latter.
    
    - st_select_lex_unit::prepare() has mostly cosmetic changes and improved
      comments. Call to set_current_select() eliminated for error case.
    
    - Deleted unused function Query_result::reset_offset_limit_cnt
    
    - st_select_lex_unit::optimize() had an unused code block started with
      if (sl == global_parameters() && is_union()).
      It was unused because global_parameters() always return the "fake" object
      for a UNION query. Besides, with the introduction of
      Query_result_union_direct, LIMIT/OFFSET handling is correct without
      adjusting offset_limit_cnt and select_limit_cnt.
    
    - An equivalent code block is removed from st_select_lex_unit::execute().
      Variable rows_at_start was found to be redundant.
      Calls to set_current_select() were removed in error case.
      offset_limit_cnt did not need to be assigned here, since it is done
      in set_limit().
      Call info(HA_STATUS_VARIABLE) was moved to a more logical place
      (used to get row count from temporary table used by UNION).
      add_rows was never assigned so it could be removed:
      sl->join->calc_found_rows is never true for a query block that is
      part of a UNION (either braces=true or m_select_limit=HA_POS_ERROR,
      see JOIN::optimize()), search for comment "Calculate found rows if".
      join->examined_rows is reset in JOIN::exec() so assignment is deleted.
    
    - Added more extensive tests for LIMIT and OFFSET to limit.test
    
    (cherry picked from commit b50c7dc66c6c894772d5da463cd08b9cd9ebd154)
    
    Conflicts:
    	sql/query_result.h
    	sql/sql_union.cc
    055c521e
    Bug#20949117: Remove obsolete code from UNION processing
    Roy Lyseng authored
    After the last refactoring work in preparation and optimization,
    there are some unused code blocks in sql_union.cc.
    This bug fix eliminates those code blocks completely and performs
    some simple additional refactoring.
    
    - Added an interface st_select_lex_unit::is_simple() that wraps
      testing for !(is_union() || fake_select_lex)
    
    - Cleaned up global_parameters() a bit: Only ORDER BY/LIMIT/OFFSET
      should be accessed through it, otherwise use fake_select_lex.
    
    - Initialization of JOIN::do_send_rows was moved from optimization to
      execution, since it is used only in the latter.
    
    - st_select_lex_unit::prepare() has mostly cosmetic changes and improved
      comments. Call to set_current_select() eliminated for error case.
    
    - Deleted unused function Query_result::reset_offset_limit_cnt
    
    - st_select_lex_unit::optimize() had an unused code block started with
      if (sl == global_parameters() && is_union()).
      It was unused because global_parameters() always return the "fake" object
      for a UNION query. Besides, with the introduction of
      Query_result_union_direct, LIMIT/OFFSET handling is correct without
      adjusting offset_limit_cnt and select_limit_cnt.
    
    - An equivalent code block is removed from st_select_lex_unit::execute().
      Variable rows_at_start was found to be redundant.
      Calls to set_current_select() were removed in error case.
      offset_limit_cnt did not need to be assigned here, since it is done
      in set_limit().
      Call info(HA_STATUS_VARIABLE) was moved to a more logical place
      (used to get row count from temporary table used by UNION).
      add_rows was never assigned so it could be removed:
      sl->join->calc_found_rows is never true for a query block that is
      part of a UNION (either braces=true or m_select_limit=HA_POS_ERROR,
      see JOIN::optimize()), search for comment "Calculate found rows if".
      join->examined_rows is reset in JOIN::exec() so assignment is deleted.
    
    - Added more extensive tests for LIMIT and OFFSET to limit.test
    
    (cherry picked from commit b50c7dc66c6c894772d5da463cd08b9cd9ebd154)
    
    Conflicts:
    	sql/query_result.h
    	sql/sql_union.cc
Loading