1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

BUG#6883: Added tests for create/drop temporary table, UNLOCK TABLES

If a create table can not do implicit commit, the stmt now fails
CREATE/DROP TEMPORARY TABLE is now flushed to binlog
This commit is contained in:
lars@mysql.com
2005-06-01 15:52:32 +02:00
parent 54bf811ada
commit 2b3c8b9dc5
4 changed files with 1018 additions and 637 deletions

View File

@ -21,7 +21,9 @@ eval SELECT CONCAT('######## ','$my_stmt',' ########') as "";
--enable_query_log --enable_query_log
### Predict the number of the current log ###############################################################
# Predict the number of the current log
###############################################################
# Disable the logging of the log number computation. # Disable the logging of the log number computation.
--disable_query_log --disable_query_log
# $_log_num_n should contain the number of the current binlog in numeric style. # $_log_num_n should contain the number of the current binlog in numeric style.
@ -38,7 +40,9 @@ let $_log_num_s= `select @aux`;
# eval SELECT '$log_num' ; # eval SELECT '$log_num' ;
--enable_query_log --enable_query_log
# INSERT + command to be tested + ROLLBACK ###############################################################
# INSERT
###############################################################
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
@ -49,6 +53,7 @@ eval INSERT INTO t1 SET f1= $MAX + 1;
# results before DDL(to be tested) # results before DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
sync_slave_with_master; sync_slave_with_master;
@ -59,8 +64,12 @@ SELECT '-------- switch to slave --------' as "";
# results before DDL(to be tested) # results before DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
###############################################################
# command to be tested
###############################################################
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
@ -71,6 +80,7 @@ let $my_stmt= ERROR: YOU FORGOT TO FILL IN THE STATEMENT;
# results after DDL(to be tested) # results after DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
sync_slave_with_master; sync_slave_with_master;
@ -81,8 +91,12 @@ SELECT '-------- switch to slave --------' as "";
# results after DDL(to be tested) # results after DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
###############################################################
# ROLLBACK
###############################################################
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
@ -93,11 +107,15 @@ SELECT MAX(f1) FROM t1;
# Try to detect if the DDL command caused that the INSERT is committed # Try to detect if the DDL command caused that the INSERT is committed
# $MAX holds the highest/last value just before the insert of MAX + 1 # $MAX holds the highest/last value just before the insert of MAX + 1
--disable_query_log --disable_query_log
eval SELECT CONCAT('TEST-INFO: MASTER: The INSERT is ', eval SELECT CONCAT(CONCAT('TEST-INFO: MASTER: The INSERT is ',
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')) AS "" IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
FROM d1.t1; IF((MAX(f1) = $MAX + 1) XOR NOT $my_master_commit,
' (Succeeded)',
' (Failed)')) AS ""
FROM mysqltest1.t1;
--enable_query_log --enable_query_log
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
sync_slave_with_master; sync_slave_with_master;
@ -108,13 +126,20 @@ SELECT '-------- switch to slave --------' as "";
# results after final ROLLBACK # results after final ROLLBACK
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--disable_query_log --disable_query_log
eval SELECT CONCAT('TEST-INFO: SLAVE: The INSERT is ', eval SELECT CONCAT(CONCAT('TEST-INFO: SLAVE: The INSERT is ',
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')) AS "" IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
FROM d1.t1; IF((MAX(f1) = $MAX + 1) XOR NOT $my_slave_commit,
' (Succeeded)',
' (Failed)')) AS ""
FROM mysqltest1.t1;
--enable_query_log --enable_query_log
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
###############################################################
# Manipulate binlog
###############################################################
#let $manipulate= 0; #let $manipulate= 0;
let $manipulate= 1; let $manipulate= 1;
while ($manipulate) while ($manipulate)

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
######################## rpl-ddl.test ######################## ######################## rpl_ddl.test ########################
# # # #
# DDL statements (sometimes with implicit COMMIT) executed # # DDL statements (sometimes with implicit COMMIT) executed #
# by the master and it's propagation into the slave # # by the master and it's propagation into the slave #
@ -28,89 +28,65 @@
# eval SELECT CONCAT('######## ','$my_stmt',' ########') as ""; # eval SELECT CONCAT('######## ','$my_stmt',' ########') as "";
# #
######## tested DDL commands
#
# let $my_stmt= COMMIT;
# let $my_stmt= ROLLBACK;
# let $my_stmt= SET AUTOCOMMIT=1;
# let $my_stmt= START TRANSACTION;
# let $my_stmt= BEGIN;
# let $my_stmt= DROP TABLE d1.t2;
# let $my_stmt= RENAME TABLE d1.t3 to d1.t20; <- wrong syntax !!
# let $my_stmt= ALTER TABLE d1.t4 ADD column f2 BIGINT;
# let $my_stmt= CREATE TABLE d1.t21 (f1 BIGINT) ENGINE= "InnoDB";
# let $my_stmt= TRUNCATE TABLE d1.t7;
# let $my_stmt= LOCK TABLES d1.t1 WRITE, d1.t8 READ;
# let $my_stmt= UNLOCK TABLES;
# let $my_stmt= DROP INDEX my_idx6 ON d1.t6;
# let $my_stmt= CREATE INDEX my_idx5 ON d1.t5(f1);
# let $my_stmt= DROP DATABASE d2;
# let $my_stmt= CREATE DATABASE d3;
#
# FIXME: @code{LOAD MASTER DATA} is not tested
#
#############################################
--source include/have_innodb.inc --source include/have_innodb.inc
source include/master-slave.inc; --source include/master-slave.inc
###############################################################
######## some preparations # Some preparations
# ###############################################################
SET AUTOCOMMIT = 1; SET AUTOCOMMIT = 1;
# #
# 1. DROP all objects, which probably already exist, but must be created here # 1. DROP all objects, which probably already exist, but must be created here
# #
--disable_warnings --disable_warnings
DROP DATABASE IF EXISTS d1; DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS d2; DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS d3; DROP DATABASE IF EXISTS mysqltest3;
--enable_warnings --enable_warnings
# #
# 2. CREATE all objects needed # 2. CREATE all objects needed
# working database is d1 # working database is mysqltest1
# working (transactional!) is d1.t1 # working (transactional!) is mysqltest1.t1
# #
CREATE DATABASE d1; CREATE DATABASE mysqltest1;
CREATE DATABASE d2; CREATE DATABASE mysqltest2;
CREATE TABLE d1.t1 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t1 (f1 BIGINT) ENGINE= "InnoDB";
INSERT INTO d1.t1 SET f1= 0; INSERT INTO mysqltest1.t1 SET f1= 0;
CREATE TABLE d1.t2 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t2 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t3 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t3 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t4 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t4 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t5 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t5 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t6 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t6 (f1 BIGINT) ENGINE= "InnoDB";
CREATE INDEX my_idx6 ON d1.t6(f1); CREATE INDEX my_idx6 ON mysqltest1.t6(f1);
CREATE TABLE d1.t7 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t7 (f1 BIGINT) ENGINE= "InnoDB";
INSERT INTO d1.t7 SET f1= 0; INSERT INTO mysqltest1.t7 SET f1= 0;
CREATE TABLE d1.t8 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t8 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t9 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t9 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t10 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t10 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t11 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t11 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t12 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t12 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t13 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t13 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t14 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t14 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t15 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t15 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t16 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t16 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t17 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t17 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t18 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t18 (f1 BIGINT) ENGINE= "InnoDB";
CREATE TABLE d1.t19 (f1 BIGINT) ENGINE= "InnoDB"; CREATE TABLE mysqltest1.t19 (f1 BIGINT) ENGINE= "InnoDB";
# CREATE TEMPORARY TABLE mysqltest1.t23 (f1 BIGINT);
COMMIT; # Just to be sure
# #
# 3. master sessions: never do AUTOCOMMIT # 3. master sessions: never do AUTOCOMMIT
# slave sessions: do AUTOCOMMIT, because we want to see fresh values # slave sessions: never do AUTOCOMMIT
# every time #
# default database is d1
SET AUTOCOMMIT = 0; SET AUTOCOMMIT = 0;
use d1; use mysqltest1;
sync_slave_with_master; sync_slave_with_master;
connection slave; connection slave;
--disable_query_log --disable_query_log
SELECT '-------- switch to slave --------' as ""; SELECT '-------- switch to slave --------' as "";
--enable_query_log --enable_query_log
SET AUTOCOMMIT = 1; SET AUTOCOMMIT = 0;
use d1; use mysqltest1;
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
@ -122,27 +98,48 @@ SELECT '-------- switch to master -------' as "";
# sequences are nearly independend of the previous statements. # sequences are nearly independend of the previous statements.
--disable_abort_on_error --disable_abort_on_error
###### banal case: (explicit) COMMIT and ROLLBACK ###############################################################
# just for checking if the test sequence is usable # Banal case: (explicit) COMMIT and ROLLBACK
# Just for checking if the test sequence is usable
###############################################################
let $my_stmt= COMMIT; let $my_stmt= COMMIT;
--source include/rpl_stmt_seq.inc let $my_master_commit= true;
let $my_stmt= ROLLBACK; let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
###### cases with commands very similar to COMMIT let $my_stmt= ROLLBACK;
let $my_master_commit= false;
let $my_slave_commit= false;
--source include/rpl_stmt_seq.inc
###############################################################
# Cases with commands very similar to COMMIT
###############################################################
let $my_stmt= SET AUTOCOMMIT=1; let $my_stmt= SET AUTOCOMMIT=1;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
SET AUTOCOMMIT=0; SET AUTOCOMMIT=0;
#
let $my_stmt= START TRANSACTION; let $my_stmt= START TRANSACTION;
--source include/rpl_stmt_seq.inc let $my_master_commit= true;
# let $my_slave_commit= true;
let $my_stmt= BEGIN;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
###### cases with commands, which create or drop objects let $my_stmt= BEGIN;
#### (BASE) TABLES and (UPDATABLE) VIEWs let $my_master_commit= true;
let $my_stmt= DROP TABLE d1.t2; let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
###############################################################
# Cases with (BASE) TABLES and (UPDATABLE) VIEWs
###############################################################
let $my_stmt= DROP TABLE mysqltest1.t2;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
SHOW TABLES LIKE 't2'; SHOW TABLES LIKE 't2';
connection slave; connection slave;
@ -154,8 +151,31 @@ connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
--enable_query_log --enable_query_log
#
let $my_stmt= RENAME TABLE d1.t3 to d1.t20; # Note: Since this test is executed with a skip-innodb slave, the
# slave incorrectly commits the insert. One can *not* have InnoDB on
# master and MyISAM on slave and expect that a transactional rollback
# after a CREATE TEMPORARY TABLE should work correctly on the slave.
# For this to work properly the handler on the slave must be able to
# handle transactions (e.g. InnoDB or NDB).
let $my_stmt= DROP TEMPORARY TABLE mysqltest1.t23;
let $my_master_commit= false;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
SHOW TABLES LIKE 't23';
connection slave;
--disable_query_log
SELECT '-------- switch to slave --------' as "";
--enable_query_log
SHOW TABLES LIKE 't23';
connection master;
--disable_query_log
SELECT '-------- switch to master -------' as "";
--enable_query_log
let $my_stmt= RENAME TABLE mysqltest1.t3 to mysqltest1.t20;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
SHOW TABLES LIKE 't20'; SHOW TABLES LIKE 't20';
connection slave; connection slave;
@ -167,102 +187,158 @@ connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
--enable_query_log --enable_query_log
#
let $my_stmt= ALTER TABLE d1.t4 ADD column f2 BIGINT; let $my_stmt= ALTER TABLE mysqltest1.t4 ADD column f2 BIGINT;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
describe d1.t4; describe mysqltest1.t4;
connection slave; connection slave;
--disable_query_log --disable_query_log
SELECT '-------- switch to slave --------' as ""; SELECT '-------- switch to slave --------' as "";
--enable_query_log --enable_query_log
describe d1.t4; describe mysqltest1.t4;
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
--enable_query_log --enable_query_log
#
let $my_stmt= CREATE TABLE d1.t21 (f1 BIGINT) ENGINE= "InnoDB"; let $my_stmt= CREATE TABLE mysqltest1.t21 (f1 BIGINT) ENGINE= "InnoDB";
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
#
let $my_stmt= TRUNCATE TABLE d1.t7; # Note: Since this test is executed with a skip-innodb slave, the
# slave incorrectly commits the insert. One can *not* have InnoDB on
# master and MyISAM on slave and expect that a transactional rollback
# after a CREATE TEMPORARY TABLE should work correctly on the slave.
# For this to work properly the handler on the slave must be able to
# handle transactions (e.g. InnoDB or NDB).
let $my_stmt= CREATE TEMPORARY TABLE mysqltest1.t22 (f1 BIGINT);
let $my_master_commit= false;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
SELECT * FROM d1.t7;
let $my_stmt= TRUNCATE TABLE mysqltest1.t7;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
SELECT * FROM mysqltest1.t7;
connection slave; connection slave;
--disable_query_log --disable_query_log
SELECT '-------- switch to slave --------' as ""; SELECT '-------- switch to slave --------' as "";
--enable_query_log --enable_query_log
SELECT * FROM d1.t7; SELECT * FROM mysqltest1.t7;
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
--enable_query_log --enable_query_log
#
# MySQL insists in locking d1.t1, because rpl_stmt_seq performs an INSERT into ###############################################################
# this table. # Cases with LOCK/UNLOCK
let $my_stmt= LOCK TABLES d1.t1 WRITE, d1.t8 READ; ###############################################################
# MySQL insists in locking mysqltest1.t1, because rpl_stmt_seq performs an
# INSERT into this table.
let $my_stmt= LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
UNLOCK TABLES; UNLOCK TABLES;
#
LOCK TABLES d1.t1 WRITE, d1.t8 READ; # No prior locking
let $my_stmt= UNLOCK TABLES; let $my_stmt= UNLOCK TABLES;
let $my_master_commit= false;
let $my_slave_commit= false;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
#
#### INDEXES # With prior read locking
let $my_stmt= DROP INDEX my_idx6 ON d1.t6; LOCK TABLES mysqltest1.t1 READ;
let $my_stmt= UNLOCK TABLES;
let $my_master_commit= false;
let $my_slave_commit= false;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
SHOW INDEX FROM d1.t6;
# With prior write locking
LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ;
let $my_stmt= UNLOCK TABLES;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
###############################################################
# Cases with INDEXES
###############################################################
let $my_stmt= DROP INDEX my_idx6 ON mysqltest1.t6;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
SHOW INDEX FROM mysqltest1.t6;
connection slave; connection slave;
--disable_query_log --disable_query_log
SELECT '-------- switch to slave --------' as ""; SELECT '-------- switch to slave --------' as "";
--enable_query_log --enable_query_log
SHOW INDEX FROM d1.t6; SHOW INDEX FROM mysqltest1.t6;
connection master;
--disable_query_log
SELECT '-------- switch to master -------' as "";
--enable_query_log
#
let $my_stmt= CREATE INDEX my_idx5 ON d1.t5(f1);
--source include/rpl_stmt_seq.inc
SHOW INDEX FROM d1.t5;
connection slave;
--disable_query_log
SELECT '-------- switch to slave --------' as "";
--enable_query_log
SHOW INDEX FROM d1.t5;
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
--enable_query_log --enable_query_log
#### DATABASES let $my_stmt= CREATE INDEX my_idx5 ON mysqltest1.t5(f1);
let $my_stmt= DROP DATABASE d2; let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc --source include/rpl_stmt_seq.inc
SHOW DATABASES LIKE "d2"; SHOW INDEX FROM mysqltest1.t5;
connection slave; connection slave;
--disable_query_log --disable_query_log
SELECT '-------- switch to slave --------' as ""; SELECT '-------- switch to slave --------' as "";
--enable_query_log --enable_query_log
SHOW DATABASES LIKE "d2"; SHOW INDEX FROM mysqltest1.t5;
connection master;
--disable_query_log
SELECT '-------- switch to master -------' as "";
--enable_query_log
#
let $my_stmt= CREATE DATABASE d3;
--source include/rpl_stmt_seq.inc
SHOW DATABASES LIKE "d3";
connection slave;
--disable_query_log
SELECT '-------- switch to slave --------' as "";
--enable_query_log
SHOW DATABASES LIKE "d3";
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
--enable_query_log --enable_query_log
###############################################################
# Cases with DATABASE
###############################################################
let $my_stmt= DROP DATABASE mysqltest2;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
SHOW DATABASES LIKE "mysqltest2";
connection slave;
--disable_query_log
SELECT '-------- switch to slave --------' as "";
--enable_query_log
SHOW DATABASES LIKE "mysqltest2";
connection master;
--disable_query_log
SELECT '-------- switch to master -------' as "";
--enable_query_log
let $my_stmt= CREATE DATABASE mysqltest3;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
SHOW DATABASES LIKE "mysqltest3";
connection slave;
--disable_query_log
SELECT '-------- switch to slave --------' as "";
--enable_query_log
SHOW DATABASES LIKE "mysqltest3";
connection master;
--disable_query_log
SELECT '-------- switch to master -------' as "";
--enable_query_log
###############################################################
# Cleanup
###############################################################
--disable_warnings --disable_warnings
DROP DATABASE IF EXISTS d1; DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS d2; DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS d3; DROP DATABASE IF EXISTS mysqltest3;
--enable_warnings --enable_warnings

View File

@ -2410,10 +2410,19 @@ mysql_execute_command(THD *thd)
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
{ {
/* If CREATE TABLE of non-temporary table, do implicit commit */ /* If CREATE TABLE of non-temporary table, do implicit commit */
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
end_active_trans(thd)) {
res= -1; if (end_active_trans(thd))
{
res= -1;
break;
}
}
else
{
/* So that CREATE TEMPORARY TABLE gets flushed to binlog */
thd->options|= (OPTION_STATUS_NO_TRANS_UPDATE);
}
/* Skip first table, which is the table we are creating */ /* Skip first table, which is the table we are creating */
TABLE_LIST *create_table, *create_table_local; TABLE_LIST *create_table, *create_table_local;
tables= lex->unlink_first_table(tables, &create_table, tables= lex->unlink_first_table(tables, &create_table,
@ -2979,6 +2988,9 @@ unsent_create_error:
*/ */
if (thd->slave_thread) if (thd->slave_thread)
lex->drop_if_exists= 1; lex->drop_if_exists= 1;
/* So that DROP TEMPORARY TABLE gets flushed to binlog */
thd->options|= (OPTION_STATUS_NO_TRANS_UPDATE);
} }
res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary); res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary);
} }