#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-48506/mysql-pe/ based on revid:joro@stripped
3719 Alfranio Correia 2009-11-27 [merge]
Merge mysql-5.1-bugteam --> mysql-pe
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-26 14:02:26 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result 2009-11-27 14:06:40 +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%';
+Tables_in_test (bug48506%)
+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-10-26 14:02:26 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test 2009-11-27 14:06:40 +0000
@@ -285,4 +285,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%';
+
+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-11-20 13:50:24 +0000
+++ b/sql/sql_table.cc 2009-11-27 14:06:40 +0000
@@ -5276,32 +5276,41 @@ bool mysql_create_like_table(THD* thd, T
String query(buf, sizeof(buf), system_charset_info);
query.length(0); // Have to zero it since constructor doesn't
Open_table_context ot_ctx_unused(thd);
+
/*
- Here we open the destination table, on which we already have
- exclusive metadata lock. This is needed for store_create_info()
- to work. The table will be closed by close_thread_table() at
- the end of this branch.
+ The condition avoids a crash as described in BUG#48506. Other
+ binlogging problems related to CREATE TABLE IF NOT EXISTS LIKE
+ when the existing object is a view will be solved by BUG 47442.
*/
- if (open_table(thd, table, thd->mem_root, &ot_ctx_unused,
+ if (!table->view)
+ {
+ /*
+ Here we open the destination table, on which we already have
+ exclusive metadata lock. This is needed for store_create_info()
+ to work. The table will be closed by close_thread_table() at
+ the end of this branch.
+ */
+ if (open_table(thd, table, thd->mem_root, &ot_ctx_unused,
MYSQL_OPEN_REOPEN))
- goto err;
-
- int result __attribute__((unused))=
- 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());
+ goto err;
- DBUG_ASSERT(thd->open_tables == table->table);
- pthread_mutex_lock(&LOCK_open);
- /*
- When opening the table, we ignored the locked tables
- (MYSQL_OPEN_GET_NEW_TABLE). Now we can close the table without
- risking to close some locked table.
- */
- close_thread_table(thd, &thd->open_tables);
- pthread_mutex_unlock(&LOCK_open);
+ int result __attribute__((unused))=
+ 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(thd->open_tables == table->table);
+ pthread_mutex_lock(&LOCK_open);
+ /*
+ When opening the table, we ignored the locked tables
+ (MYSQL_OPEN_GET_NEW_TABLE). Now we can close the table without
+ risking to close some locked table.
+ */
+ close_thread_table(thd, &thd->open_tables);
+ pthread_mutex_unlock(&LOCK_open);
+ }
}
else // Case 1
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
Attachment: [text/bzr-bundle]
| Thread |
|---|
| • bzr commit into mysql-pe branch (alfranio.correia:3719) | Alfranio Correia | 27 Nov |