• Jorgen Loland's avatar
    BUG#11766234: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW) · 4185869e
    Jorgen Loland authored
                  FAILS IN SET_FIELD_ITERATOR
    
    (Former 59299)
    
    When a PROCEDURE does a natural join, resolving of which columns are
    used in the join is done only once; consecutive CALLs to the procedure
    will reuse this information:
    
    CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1;
    CALL proc();   <- natural join columns resolved here
    CALL proc();   <- reuse resolved NJ columns from first CALL
    
    The second CALL knows that it can reuse the resolved NJ columns because
    the first CALL sets st_select_lex::first_natural_join_processing=false.
    The problem in this bug was that the table the view v1 depends on 
    changed between CREATE PROCEDURE and the first CALL: 
    
    CREATE PROCEDURE...
    ALTER TABLE t2 CHANGE COLUMN a b CHAR;
    CALL proc();   <- error when resolving natural join columns
    CALL proc();   <- tries to reuse from first CALL => crash
    
    The fix for this bug is to set first_natural_join_processing= FALSE iff
    the natural join columns resolving was successful.
    
    
    mysql-test/r/sp.result:
      Add test for bug 11766234
    mysql-test/t/sp.test:
      Add test for bug 11766234
    sql/sql_base.cc:
      Set first_natural_join_processing= FALSE iff the natural join columns resolving was successful.
    4185869e
sp.result 176 KB