Hi Libing
Patch approved.
Please, just address Jasonh's comments.
Cheers.
Li-Bing.Song@stripped wrote:
> #At file:///home/anders/work/bzrwork/mysql-5.1-bugteam/ based on
> revid:kristofer.pettersson@stripped
>
> 3191 Li-Bing.Song@stripped 2009-11-27
> BUG# 48506 crash in CREATE TABLE IF NOT EXISTS <existing_view> LIKE
> <tmp_tbl> with RBL
>
> When binlogging the statement, server always handle the
> existing object as a table, even though it is a view.
> However view is most different with table in code level.
> Thus, it is crashed.
>
> Now, we just binlog nothing if the existing object is a view in RBR.
>
> However we are still discussing following problems:
> whether it should be binlogged or not ?
> if we decide to binlogged it, what should be binlogged ? the
> existing view or like table ?
> Bug#47442 is a same bug on 'CREATE TABLE IF NOT EXISTS
> <existing_view> SELECT' statement. all problems will have be decided
> when the patch for bug#47442 is commited. if we decides to binlog
> something, 'CREATE TABLE ... LIKE' will have the same behavior.
>
> modified:
> mysql-test/suite/rpl/r/rpl_row_create_table.result
> mysql-test/suite/rpl/t/rpl_row_create_table.test
> sql/sql_table.cc
> === modified file 'mysql-test/suite/rpl/r/rpl_row_create_table.result'
> --- a/mysql-test/suite/rpl/r/rpl_row_create_table.result 2009-10-06 00:54:00 +0000
> +++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result 2009-11-27 09:11:36 +0000
> @@ -476,4 +476,30 @@ master-bin.000001 # Table_map # # table_
> master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
> master-bin.000001 # Query # # COMMIT
> DROP DATABASE mysqltest1;
> +stop slave;
> +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
> +reset master;
> +reset slave;
> +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
> +start slave;
> +CREATE TEMPORARY TABLE t7(c1 INT);
> +CREATE TABLE t5(c1 INT);
> +CREATE TABLE t4(c1 INT);
> +CREATE VIEW bug48506_t1 AS SELECT 1;
> +CREATE VIEW bug48506_t2 AS SELECT * FROM t4;
> +CREATE VIEW bug48506_t3 AS SELECT t5.c1 AS A, t4.c1 AS B FROM t5, t4;
> +CREATE TABLE bug48506_t4(c1 INT);
> +DROP VIEW bug48506_t1, bug48506_t2, bug48506_t3;
> +DROP TABLE bug48506_t4;
> +CREATE TABLE IF NOT EXISTS bug48506_t1 LIKE t7;
> +CREATE TABLE IF NOT EXISTS bug48506_t2 LIKE t7;
> +CREATE TABLE IF NOT EXISTS bug48506_t3 LIKE t7;
> +CREATE TABLE IF NOT EXISTS bug48506_t4 LIKE t7;
> +SHOW TABLES LIKE 'bug48506\_t_';
> +Tables_in_test (bug48506\_t_)
> +bug48506_t4
> +DROP VIEW IF EXISTS bug48506_t1, bug48506_t2, bug48506_t3;
> +DROP TEMPORARY TABLES t7;
> +DROP TABLES t4, t5;
> +DROP TABLES IF EXISTS bug48506_t4;
> end of the tests
>
> === modified file 'mysql-test/suite/rpl/t/rpl_row_create_table.test'
> --- a/mysql-test/suite/rpl/t/rpl_row_create_table.test 2009-01-23 12:22:05 +0000
> +++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test 2009-11-27 09:11:36 +0000
> @@ -292,4 +292,40 @@ connection master;
> DROP DATABASE mysqltest1;
> sync_slave_with_master;
>
> +#
> +# BUG#48506: crash in CREATE TABLE <existing_view> IF NOT EXISTS LIKE
> +# <tmp_tbl> with RBL
> +#
> +
> +source include/master-slave-reset.inc;
> +
> +connection master;
> +CREATE TEMPORARY TABLE t7(c1 INT);
> +CREATE TABLE t5(c1 INT);
> +CREATE TABLE t4(c1 INT);
> +CREATE VIEW bug48506_t1 AS SELECT 1;
> +CREATE VIEW bug48506_t2 AS SELECT * FROM t4;
> +CREATE VIEW bug48506_t3 AS SELECT t5.c1 AS A, t4.c1 AS B FROM t5, t4;
> +CREATE TABLE bug48506_t4(c1 INT);
> +--disable_warnings
> +sync_slave_with_master;
> +DROP VIEW bug48506_t1, bug48506_t2, bug48506_t3;
> +DROP TABLE bug48506_t4;
> +
> +connection master;
> +CREATE TABLE IF NOT EXISTS bug48506_t1 LIKE t7;
> +CREATE TABLE IF NOT EXISTS bug48506_t2 LIKE t7;
> +CREATE TABLE IF NOT EXISTS bug48506_t3 LIKE t7;
> +CREATE TABLE IF NOT EXISTS bug48506_t4 LIKE t7;
> +--enable_warnings
> +sync_slave_with_master;
> +
> +SHOW TABLES LIKE 'bug48506\_t_';
> +
> +connection master;
> +DROP VIEW IF EXISTS bug48506_t1, bug48506_t2, bug48506_t3;
> +DROP TEMPORARY TABLES t7;
> +DROP TABLES t4, t5;
> +DROP TABLES IF EXISTS bug48506_t4;
> +source include/master-slave-end.inc;
> --echo end of the tests
>
> === modified file 'sql/sql_table.cc'
> --- a/sql/sql_table.cc 2009-10-27 09:53:16 +0000
> +++ b/sql/sql_table.cc 2009-11-27 09:11:36 +0000
> @@ -5418,13 +5418,28 @@ binlog:
> goto err;
> }
> VOID(pthread_mutex_unlock(&LOCK_open));
> + /*
> + BUG# 48506 crash in CREATE TABLE IF NOT EXISTS <existing_view> LIKE
> + <tmp_tbl> with RBL
> + Now, we just binlog nothing if the existing object is a view in RBR.
> + However we are still discussing following problems:
> + whether it should be binlogged or not ?
> + if we decide to binlogged it, what should be binlogged ? the
> + existing view or like table ?
> + Bug#47442 is a same bug on 'CREATE TABLE IF NOT EXISTS
> + <existing_view> SELECT' statement. all problems will have be
> decided
> + when the patch for bug#47442 is commited. if we decides to binlog
> + something, 'CREATE TABLE ... LIKE' will have the same behavior.
> + */
> + if (!table->view)
> + {
> + IF_DBUG(int result=)
> + store_create_info(thd, table, &query,
> + create_info, FALSE /* show_database */);
>
> - IF_DBUG(int result=)
> - store_create_info(thd, table, &query,
> - create_info, FALSE /* show_database */);
> -
> - DBUG_ASSERT(result == 0); // store_create_info() always return 0
> - write_bin_log(thd, TRUE, query.ptr(), query.length());
> + DBUG_ASSERT(result == 0); // store_create_info() always return 0
> + write_bin_log(thd, TRUE, query.ptr(), query.length());
> + }
> }
> else // Case 1
> write_bin_log(thd, TRUE, thd->query(), thd->query_length());
>
>
>
> ------------------------------------------------------------------------
>
>