#At file:///localhome/jl208045/mysql/mysql-6.0-backup-34758bzr/
2626 Jorgen Loland 2008-06-03
Bug#34758 "Server crashes if database with views backed up using CS driver"
Cleanup lex before consecutive calls to open_and_lock_tables for backup and restore.
Fixed this bug and a similar, unreported bug in restore.
Detailed description:
- st_lex::cleanup_after_one_table_open() needs to be called between consecutive
calls to open_and_lock_tables to prevent processing of previously opened views.
- added cleanup_after_one_table_open before call to open_and_lock_tables in
do_backup.
- fixed a similar bug in restore by applying the same fix in do_restore
modified:
sql/backup/be_snapshot.cc
sql/backup/data_backup.cc
per-file comments:
sql/backup/be_snapshot.cc
Cleanup lex before calling open_and_lock_tables in do_backup.
sql/backup/data_backup.cc
Cleanup lex before calling open_and_lock_tables in do_restore.
=== modified file 'sql/backup/be_snapshot.cc'
--- a/sql/backup/be_snapshot.cc 2008-03-21 09:05:40 +0000
+++ b/sql/backup/be_snapshot.cc 2008-06-03 09:50:04 +0000
@@ -103,6 +103,10 @@ result_t Backup::get_data(Buffer &buf)
if (!tables_open && (locking_thd->lock_state == LOCK_ACQUIRED))
{
BACKUP_BREAKPOINT("backup_cs_open_tables");
+ // The lex needs to be cleaned up between consecutive calls to
+ // open_and_lock_tables. Otherwise, open_and_lock_tables will try to open
+ // previously opened views and crash.
+ locking_thd->m_thd->lex->cleanup_after_one_table_open();
open_and_lock_tables(locking_thd->m_thd, locking_thd->tables_in_backup);
tables_open= TRUE;
}
=== modified file 'sql/backup/data_backup.cc'
--- a/sql/backup/data_backup.cc 2008-05-05 15:03:24 +0000
+++ b/sql/backup/data_backup.cc 2008-06-03 09:50:04 +0000
@@ -1421,6 +1421,11 @@ int restore_table_data(THD*, Restore_inf
{
table_list->lock_type= TL_WRITE;
query_cache.invalidate_locked_for_write(table_list);
+
+ // The lex needs to be cleaned up between consecutive calls to
+ // open_and_lock_tables. Otherwise, open_and_lock_tables will try to open
+ // previously opened views and crash.
+ ::current_thd->lex->cleanup_after_one_table_open();
if (open_and_lock_tables(::current_thd, table_list))
{
info.m_ctx.fatal_error(ER_BACKUP_OPEN_TABLES, "restore");