Skip to content
  • Roy Lyseng's avatar
    482aa251
    Bug#16317443: Re-execute procedure, crash in Item_field::fix_outer_field · 482aa251
    Roy Lyseng authored
    Bug#16317363: Re-execute procedure, crash in mark_select_range_as_dependent
    
    This problem here is that we reach ::fix_outer_field when we should not,
    which happens because cached_table->select_lex of an Item_field no longer
    matches the select_lex of the name resolution context. It is also important
    to notice that this happens for a merged view, regular table fields are
    not affected.
    
    The mismatch is caused by 2 problems:
    
    1. is a lacking update of TABLE_LIST::select_lex in
       convert_subquery_to_semijoin(). This code:
    
        for (TABLE_LIST *emb= tl->embedding;
             emb && emb->select_lex == old_sl;
             emb= emb->embedding)
          emb->select_lex= parent_join->select_lex;
    
       updates the select_lex of all leaf tables and embedding join nests,
       however it is necessary that all join nests have a correct select_lex
       pointer for this to work, so the fix is to add an assignment to
       ::select_lex in st_select_lex::nest_last_join().
    
    2. is a lacking update of TABLE_LIST::select_lex when a view is merged
       into a query. It is solved quite elegantly by replacing the pointer
       in repoint_contexts_of_join_nests().
    
    We have also taken the opportunity to replace the static function
    alloc_join_nest() with a more general function TABLE_LIST::new_join_nest(),
    which assigns values to all important join nest fields.
    
    sql/sql_optimizer.cc
      In convert_subquery_to_semijoin(), remember to set select_lex
      pointer when creating new join nests.
      Function alloc_join_nest() is replaced with TABLE_LIST::new_join_nest().
    
    sql/sql_parse.cc
      In st_select_lex::nest_last_join(), set select_lex pointer.
    
    sql/sql_view.cc
      In repoint_contexts_of_join_nests(), update select_lex pointer of
      embedded join nests to point to the select_lex of the outer query.
    
    sql/table.cc
      Added function TABLE_LIST::new_join_nest().
    
    sql/table.h
      Added function TABLE_LIST::new_join_nest().
    482aa251
    Bug#16317443: Re-execute procedure, crash in Item_field::fix_outer_field
    Roy Lyseng authored
    Bug#16317363: Re-execute procedure, crash in mark_select_range_as_dependent
    
    This problem here is that we reach ::fix_outer_field when we should not,
    which happens because cached_table->select_lex of an Item_field no longer
    matches the select_lex of the name resolution context. It is also important
    to notice that this happens for a merged view, regular table fields are
    not affected.
    
    The mismatch is caused by 2 problems:
    
    1. is a lacking update of TABLE_LIST::select_lex in
       convert_subquery_to_semijoin(). This code:
    
        for (TABLE_LIST *emb= tl->embedding;
             emb && emb->select_lex == old_sl;
             emb= emb->embedding)
          emb->select_lex= parent_join->select_lex;
    
       updates the select_lex of all leaf tables and embedding join nests,
       however it is necessary that all join nests have a correct select_lex
       pointer for this to work, so the fix is to add an assignment to
       ::select_lex in st_select_lex::nest_last_join().
    
    2. is a lacking update of TABLE_LIST::select_lex when a view is merged
       into a query. It is solved quite elegantly by replacing the pointer
       in repoint_contexts_of_join_nests().
    
    We have also taken the opportunity to replace the static function
    alloc_join_nest() with a more general function TABLE_LIST::new_join_nest(),
    which assigns values to all important join nest fields.
    
    sql/sql_optimizer.cc
      In convert_subquery_to_semijoin(), remember to set select_lex
      pointer when creating new join nests.
      Function alloc_join_nest() is replaced with TABLE_LIST::new_join_nest().
    
    sql/sql_parse.cc
      In st_select_lex::nest_last_join(), set select_lex pointer.
    
    sql/sql_view.cc
      In repoint_contexts_of_join_nests(), update select_lex pointer of
      embedded join nests to point to the select_lex of the outer query.
    
    sql/table.cc
      Added function TABLE_LIST::new_join_nest().
    
    sql/table.h
      Added function TABLE_LIST::new_join_nest().
Loading