• unknown's avatar
    Bug #15355: Common natural join column not resolved in prepared statement nested · a7566db7
    unknown authored
      query
    Problem:
    There was a wrong context assigned to the columns that were added in insert_fields()
    when expanding a '*'. When this is done in a prepared statement it causes 
    fix_fields() to fail to find the table that these columns reference.
    Actually the right context is set in setup_natural_join_row_types() called at the 
    end of setup_tables(). However when executed in a context of a prepared statement
    setup_tables() resets the context, but setup_natural_join_row_types() was not
    setting it to the correct value assuming it has already done so.
    
    Solution:
    The top-most, left-most NATURAL/USING join must be set as a 
    first_name_resolution_table in context even when operating on prepared statements.
    
    
    mysql-test/r/join.result:
      testsuite for the bug
    mysql-test/t/join.test:
      testsuite for the bug
    sql/sql_base.cc:
      The context must be set even when executed as prepared statement.
    a7566db7
join.test 28.7 KB