• unknown's avatar
    A fix and a test case for Bug#19399 "res 'Lost Connection' when · 8995277a
    unknown authored
    dropping/creating tables".
    
    The bug could lead to a crash when multi-delete statements were
    prepared and used with temporary tables.
    
    The bug was caused by lack of clean-up of multi-delete tables before
    re-execution of a prepared statement. In a statement like
    DELETE t1 FROM t1, t2 WHERE ... the first table list (t1) is
    moved to lex->auxilliary_table_list and excluded from lex->query_tables
    or select_lex->tables. Thus it was unaccessible to reinit_stmt_before_use
    and not cleaned up before re-execution of a prepared statement. 
    
    
    mysql-test/r/ps.result:
      Updated test results (Bug#19399)
    mysql-test/t/ps.test:
      A test case for Bug#19399 "Stored Procedures 'Lost Connection' when 
      dropping/creating tables": test that multi-delete
      tables are cleaned up properly before re-execution.
    sql/sql_lex.cc:
      Always initialize auxilliary_table_list when we initialize the lex:
      this way we don't have to check that lex->sql_command equals to
      SQLCOM_DELETE_MULTI whenever we need to access auxilliary_table_list.
      In particular, in reinit_stmt_before_use we can simply check that
      auxilliary_table_list is not NULL and clean it up if the check returns
      a true value.
    sql/sql_prepare.cc:
      Move the one table clean-up functionality to a method of st_table_list.
      Clean up auxiliary_table_list if it's not empty.
    sql/table.cc:
      Implement st_table_list::reinit_before_use().
    sql/table.h:
      Declare st_table_list::reinit_before_use().
    8995277a
ps.result 26.6 KB