List:Commits« Previous MessageNext Message »
From:Jørgen Løland Date:June 4 2008 8:48am
Subject:Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2627)
Bug#34758
View as plain text  
Recommitting the patch with a test case and correct branch name.

The code not related to the test case was approved by Chuck in this mail 
thread: "bzr commit into 6.0 branch (jorgen.loland:2626) Bug#34758"

Jorgen Loland wrote:
> #At file:///localhome/jl208045/mysql/mysql-6.0-backup-34758bzr/
> 
>  2627 Jorgen Loland	2008-06-04
>       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
>       - includes a test case that fails without the patch
> added:
>   mysql-test/r/backup_view_on_view.result
>   mysql-test/t/backup_view_on_view.test
> modified:
>   sql/backup/be_snapshot.cc
>   sql/backup/data_backup.cc
> 
> per-file comments:
>   mysql-test/r/backup_view_on_view.result
>     Expected result for test case
>   mysql-test/t/backup_view_on_view.test
>     Test case that fails without the patch
>   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.
> === added file 'mysql-test/r/backup_view_on_view.result'
> --- a/mysql-test/r/backup_view_on_view.result	1970-01-01 00:00:00 +0000
> +++ b/mysql-test/r/backup_view_on_view.result	2008-06-04 08:44:19 +0000
> @@ -0,0 +1,37 @@
> +SET GLOBAL debug="d,backup:d,backup_data";
> +DROP DATABASE IF EXISTS db1;
> +CREATE DATABASE db1;
> +CREATE TABLE db1.t1(a int) ENGINE=INNODB;
> +CREATE VIEW db1.v1 AS SELECT * FROM db1.t1;
> +CREATE VIEW db1.v2 AS SELECT * FROM db1.v1;
> +INSERT INTO db1.t1 VALUES (1),(2),(3),(5),(7),(11);
> +BACKUP DATABASE db1 TO 'test.bak';
> +backup_id
> +1
> +RESTORE FROM 'test.bak';
> +backup_id
> +2
> +SELECT * FROM db1.v2;
> +a
> +1
> +2
> +3
> +5
> +7
> +11
> +SELECT * FROM db1.v1;
> +a
> +1
> +2
> +3
> +5
> +7
> +11
> +SELECT * FROM db1.t1;
> +a
> +1
> +2
> +3
> +5
> +7
> +11
> 
> === added file 'mysql-test/t/backup_view_on_view.test'
> --- a/mysql-test/t/backup_view_on_view.test	1970-01-01 00:00:00 +0000
> +++ b/mysql-test/t/backup_view_on_view.test	2008-06-04 08:44:19 +0000
> @@ -0,0 +1,25 @@
> +# Test case for bug#34758
> +
> +# Setup the server to use the backup breakpoints
> +SET GLOBAL debug="d,backup:d,backup_data";
> +
> +--source include/have_innodb.inc
> +
> +--disable_warnings
> +DROP DATABASE IF EXISTS db1;
> +--enable_warnings
> +
> +CREATE DATABASE db1;
> +
> +CREATE TABLE db1.t1(a int) ENGINE=INNODB;
> +CREATE VIEW db1.v1 AS SELECT * FROM db1.t1;
> +CREATE VIEW db1.v2 AS SELECT * FROM db1.v1;
> +
> +INSERT INTO db1.t1 VALUES (1),(2),(3),(5),(7),(11);
> +
> +BACKUP DATABASE db1 TO 'test.bak';
> +RESTORE FROM 'test.bak';
> +
> +SELECT * FROM db1.v2;
> +SELECT * FROM db1.v1;
> +SELECT * FROM db1.t1;
> 
> === 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-04 08:44:19 +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-04 08:44:19 +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");
> 
> 


-- 
Jørgen Løland
Thread
bzr commit into mysql-6.0-backup branch (jorgen.loland:2627) Bug#34758Jorgen Loland4 Jun
  • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2627)Bug#34758Jørgen Løland4 Jun
  • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2627)Bug#34758Øystein Grøvlen4 Jun