• unknown's avatar
    Bug#17204 "second CALL to procedure crashes Server" · 128c3942
    unknown authored
    Bug#18282 "INFORMATION_SCHEMA.TABLES provides inconsistent info about invalid views"
    This bug caused crashes or resulted in wrong data being returned
    when one tried to obtain information from I_S tables about views
    using stored functions.
    
    It was caused by the fact that we were using LEX representing
    statement which were doing select from I_S tables as active LEX
    when contents of I_S table were built. So state of this LEX both
    affected and was affected by open_tables() calls which happened
    during this process. This resulted in wrong behavior and in
    violations of some of invariants which caused crashes.
    
    This fix tries to solve this problem by properly saving/resetting
    and restoring part of LEX which affects and is affected by the
    process of opening tables and views in get_all_tables() routine.
    To simplify things we separated this part of LEX in a new class
    and made LEX its descendant.
    
    
    mysql-test/r/information_schema_db.result:
      test case
    mysql-test/t/information_schema_db.test:
      test case
    sql/sql_lex.cc:
      To simplify saving/resetting and restoring part of LEX which
      affects and is affected by the process of opening tables and
      views we moved it to new class Query_tables_list and made LEX
      descendant of this class. Also introduced two LEX methods 
      which can be used to save and reset or to restore this state.
    sql/sql_lex.h:
      To simplify saving/resetting and restoring part of LEX which
      affects and is affected by the process of opening tables and
      views we moved it to new class Query_tables_list and made LEX
      descendant of this class. Also introduced two LEX methods 
      which can be used to save and reset or to restore this state.
    sql/sql_show.cc:
      Now in get_all_tables() routine we properly save/reset and
      restore part of LEX (statement table list and information
      about routines used) which affects and is affected by the
      process of opening tables and views.
    sql/sql_table.cc:
      Now we clean-up LEX after opening table (view) in two stages.
      In the first stage we call LEX::cleanup_after_one_table_open()
      to clean-up selects lists and derived tables state. In the
      second stage which happens after close_thread_tables() is
      invoked we call Query_tables_list::reset_query_tables_list(FALSE)
      to rollback changes in Query_tables_list.
    128c3942
sql_table.cc 127 KB