summaryrefslogtreecommitdiff
path: root/mysql-test/extra
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/extra')
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test1
-rw-r--r--mysql-test/extra/binlog_tests/drop_temp_table.test94
-rw-r--r--mysql-test/extra/rpl_tests/rpl_blackhole.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_blackhole_basic.test97
-rw-r--r--mysql-test/extra/rpl_tests/rpl_corruption.inc8
-rw-r--r--mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_foreign_key.test60
-rw-r--r--mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test426
-rw-r--r--mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test141
9 files changed, 420 insertions, 413 deletions
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index 831c6c886d5..369ce20d496 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -5,7 +5,6 @@
-- source include/have_log_bin.inc
-- source include/not_embedded.inc
-- source include/have_innodb.inc
--- source include/have_debug.inc
--disable_warnings
drop table if exists t1, t2;
diff --git a/mysql-test/extra/binlog_tests/drop_temp_table.test b/mysql-test/extra/binlog_tests/drop_temp_table.test
index c852ee4c8a0..7c95195eadc 100644
--- a/mysql-test/extra/binlog_tests/drop_temp_table.test
+++ b/mysql-test/extra/binlog_tests/drop_temp_table.test
@@ -1,3 +1,4 @@
+--source include/have_innodb.inc
--disable_warnings
DROP DATABASE IF EXISTS `drop-temp+table-test`;
@@ -14,12 +15,8 @@ CREATE TEMPORARY TABLE `table:name` (a INT);
CREATE TEMPORARY TABLE shortn2 (a INT);
##############################################################################
-# BUG#46572 DROP TEMPORARY table IF EXISTS does not have a consistent behavior
-# in ROW mode
-#
-# In RBR, 'DROP TEMPORARY TABLE ...' statement should never be binlogged no
-# matter if the tables exist or not. In contrast, both in SBR and MBR, the
-# statement should be always binlogged no matter if the tables exist or not.
+# MDEV-20091: DROP TEMPORARY TABLE IF EXISTS statements will be written
+# to binlog only if the corresponding temporary table exists.
##############################################################################
CREATE TEMPORARY TABLE tmp(c1 int);
CREATE TEMPORARY TABLE tmp1(c1 int);
@@ -30,12 +27,12 @@ CREATE TABLE t(c1 int);
DROP TEMPORARY TABLE IF EXISTS tmp;
--disable_warnings
-# Before fixing BUG#46572, 'DROP TEMPORARY TABLE IF EXISTS...' statement was
-# binlogged when the table did not exist in RBR.
+# Post MDEV-20091: Following DROP TEMPORARY TABLE statement should not be
+# logged as the table is already dropped above.
DROP TEMPORARY TABLE IF EXISTS tmp;
-# In RBR, 'DROP TEMPORARY TABLE ...' statement is never binlogged no matter if
-# the tables exist or not.
+# Post MDEV-20091: Only DROP TEMPORARY TABLE statement should be written only
+# for 'tmp1' table.
DROP TEMPORARY TABLE IF EXISTS tmp, tmp1;
DROP TEMPORARY TABLE tmp3;
@@ -79,6 +76,12 @@ DROP DATABASE `drop-temp+table-test`;
# if there are open temporary tables. As such the implicit drop
# for temporary tables on session closing must be logged.
#
+# MDEV-20091: DROP TEMPORARY TABLE IF EXISTS statements will be written to
+# binlog only if the corresponding temporary table exists. In row based
+# replication temporary tables are not replicated hence their corresponding
+# DROP TEMPORARY TABLE statement will be not be written to binary log upon
+# session closure.
+#
RESET MASTER;
@@ -92,11 +95,82 @@ SELECT @@session.binlog_format;
--disconnect con1
-- connection default
+if (!`SELECT @@BINLOG_FORMAT = 'ROW'`) {
--let $wait_binlog_event= DROP
--source include/wait_for_binlog_event.inc
+}
-- source include/show_binlog_events.inc
RESET MASTER;
DROP TABLE t1;
# End of 4.1 tests
+
+
+--echo #
+--echo # BUG#28642318: POINT IN TIME RECOVERY USING MYSQLBINLOG BROKEN
+--echo # WITH TEMPORARY TABLE -> ERRORS
+
+--echo # Test case for DELETE query.
+
+RESET MASTER;
+connect (con1,localhost,root,,);
+
+--echo # Set up.
+--connection default
+--disable_warnings
+SET @save_binlog_format= @@session.binlog_format;
+SET @@session.binlog_format=STATEMENT;
+let $MYSQLD_DATADIR= `select @@datadir`;
+CREATE TABLE t1 (a INT) ENGINE=INNODB;
+
+--connection con1
+SET @@session.binlog_format=STATEMENT;
+CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
+
+--connection default
+DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a;
+
+--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--connection default
+DROP TABLE t1;
+
+--echo # DELETE query fails with table re-open error without patch.
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--echo # Clean up.
+--connection con1
+DROP TABLE IF EXISTS t1;
+
+--connection default
+DROP TABLE IF EXISTS t1;
+RESET MASTER;
+
+--echo # Test case for DROP query.
+
+--connection default
+CREATE TABLE t2 (a INT) ENGINE=INNODB;
+
+--connection con1
+CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB;
+
+--connection default
+DROP TABLE t2;
+
+--connection con1
+DROP TABLE t2;
+
+--connection default
+--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--echo # DROP table query fails with unknown table error without patch.
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--echo # Clean up
+--connection default
+SET @@session.binlog_format= @save_binlog_format;
+RESET MASTER;
+
+--disconnect con1
+--enable_warnings
diff --git a/mysql-test/extra/rpl_tests/rpl_blackhole.test b/mysql-test/extra/rpl_tests/rpl_blackhole.test
index 1a0eeb3cf15..569a24e5252 100644
--- a/mysql-test/extra/rpl_tests/rpl_blackhole.test
+++ b/mysql-test/extra/rpl_tests/rpl_blackhole.test
@@ -11,7 +11,7 @@
# executing statement. If difference is >0, then something was
# written to the binary log on the slave.
-connection slave;
+# On Connection Slave
let $before = query_get_value("SHOW MASTER STATUS", Position, 1);
--echo [on master]
diff --git a/mysql-test/extra/rpl_tests/rpl_blackhole_basic.test b/mysql-test/extra/rpl_tests/rpl_blackhole_basic.test
new file mode 100644
index 00000000000..f3fdc915080
--- /dev/null
+++ b/mysql-test/extra/rpl_tests/rpl_blackhole_basic.test
@@ -0,0 +1,97 @@
+# PURPOSE. Test that blackhole works with replication in all three
+# modes: STATEMENT, MIXED, and ROW.
+#
+# METHOD. We start by creating a table on the master and then change
+# the engine to use blackhole on the slave.
+#
+# After insert/update/delete of one or more rows, the test the
+# proceeds to check that replication is running after replicating an
+# change, that the blackhole engine does not contain anything (which
+# is just a check that the correct engine is used), and that something
+# is written to the binary log.
+#
+# Whe check INSERT, UPDATE, and DELETE statement for tables with no
+# key (forcing a range search on the slave), primary keys (using a
+# primary key lookup), and index/key with multiple matches (forcing an
+# index search).
+
+# We start with no primary key
+CREATE TABLE t1 (a INT, b INT, c INT);
+CREATE TABLE t2 (a INT, b INT, c INT);
+
+sync_slave_with_master;
+ALTER TABLE t1 ENGINE=BLACKHOLE;
+
+connection master;
+INSERT INTO t2 VALUES (1,9,1), (2,9,2), (3,9,3), (4,9,4);
+sync_slave_with_master;
+
+# Test insert, no primary key
+let $statement = INSERT INTO t1 VALUES (1,1,1),(2,1,2),(3,1,3),(4,1,4);
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test update, no primary key
+let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 1;
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test delete, no primary key
+let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 1;
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test INSERT-SELECT into Blackhole, no primary key
+let $statement = INSERT INTO t1 SELECT * FROM t2;
+source extra/rpl_tests/rpl_blackhole.test;
+
+#
+# The MASTER has MyISAM as the engine for both tables. The SLAVE has Blackhole
+# on t1 (transactional engine) and MyISAM on t2 (non-transactional engine).
+#
+# In MIXED mode, the command "INSERT INTO t2 SELECT * FROM t1" is logged as
+# statement on the master. On the slave, it is tagged as unsafe because the
+# statement mixes both transactional and non-transactional engines and as such
+# its changes are logged as rows. However, due to the nature of the blackhole
+# engine, no rows are returned and thus any chain replication would make the
+# next master on the chain diverge.
+#
+# Fo this reason, we have disabled the statement.
+#
+# Test INSERT-SELECT from Blackhole, no primary key
+# let $statement = INSERT INTO t2 SELECT * FROM t1;
+# source extra/rpl_tests/rpl_blackhole.test;
+#
+
+connection master;
+ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
+sync_slave_with_master;
+
+# Test insert, primary key
+let $statement = INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test update, primary key
+let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 2;
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test delete, primary key
+let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 2;
+source extra/rpl_tests/rpl_blackhole.test;
+
+connection master;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a);
+sync_slave_with_master;
+
+# Test insert, key
+let $statement = INSERT INTO t1 VALUES (1,3,1),(2,3,2),(3,3,3),(4,3,4);
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test update, key
+let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 3;
+source extra/rpl_tests/rpl_blackhole.test;
+
+# Test delete, key
+let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 3;
+source extra/rpl_tests/rpl_blackhole.test;
+
+connection master;
+DROP TABLE t1,t2;
+sync_slave_with_master;
diff --git a/mysql-test/extra/rpl_tests/rpl_corruption.inc b/mysql-test/extra/rpl_tests/rpl_corruption.inc
index 048a9d74249..1726ee4ba2f 100644
--- a/mysql-test/extra/rpl_tests/rpl_corruption.inc
+++ b/mysql-test/extra/rpl_tests/rpl_corruption.inc
@@ -122,11 +122,11 @@ SET GLOBAL master_verify_checksum=0;
SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set";
--connection slave
START SLAVE IO_THREAD;
-# When the checksum error is detected, the slave sets error code 1913
+# When the checksum error is detected, the slave sets error code 1743
# (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE) in queue_event(), then immediately
# sets error 1595 (ER_SLAVE_RELAY_LOG_WRITE_FAILURE) in handle_slave_io().
-# So we usually get 1595, but it is occasionally possible to get 1913.
-let $slave_io_errno= 1595,1913;
+# So we usually get 1595, but it is occasionally possible to get 1743.
+let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
--source include/wait_for_slave_io_error.inc
--connection master
SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set";
@@ -138,7 +138,7 @@ SET GLOBAL master_verify_checksum=1;
--connection slave
SET GLOBAL debug_dbug="+d,corrupt_queue_event";
START SLAVE IO_THREAD;
-let $slave_io_errno= 1595,1913;
+let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
--source include/wait_for_slave_io_error.inc
SET GLOBAL debug_dbug="-d,corrupt_queue_event";
diff --git a/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test b/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test
index ffd7fe1a5c4..f8b521e3abf 100644
--- a/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test
+++ b/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test
@@ -32,6 +32,10 @@
# is any
# Drop-Temp-TT-Temp - Drops two temporary T-tables if there is any
# Drop-Temp-NN-Temp - Drops two temporary N-tables if there is any
+#
+# Note: MDEV-20091: DROP TEMPORARY TABLE IF EXISTS statements will be written
+# to binlog only if the corresponding temporary table exists.
+#
# Drop-Temp-Xe-Temp - Tries to drop a temporary table that does not exist
# Drop-Temp-NXe-Temp - Drops a temporary N-table if there is any and
# a temporary table that does not exist
diff --git a/mysql-test/extra/rpl_tests/rpl_foreign_key.test b/mysql-test/extra/rpl_tests/rpl_foreign_key.test
deleted file mode 100644
index d10deece1b1..00000000000
--- a/mysql-test/extra/rpl_tests/rpl_foreign_key.test
+++ /dev/null
@@ -1,60 +0,0 @@
-# Check the replication of the FOREIGN_KEY_CHECKS variable.
-
--- source include/master-slave.inc
-
-eval CREATE TABLE t1 (a INT AUTO_INCREMENT KEY) ENGINE=$engine_type;
-eval CREATE TABLE t2 (b INT AUTO_INCREMENT KEY, c INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=$engine_type;
-
-SET FOREIGN_KEY_CHECKS=0;
-INSERT INTO t1 VALUES (10);
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL);
-INSERT INTO t2 VALUES (5,0);
-INSERT INTO t2 VALUES (NULL,LAST_INSERT_ID());
-SET FOREIGN_KEY_CHECKS=1;
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY b;
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY b;
-
-connection master;
-SET TIMESTAMP=1000000000;
-CREATE TABLE t3 ( a INT UNIQUE );
-SET FOREIGN_KEY_CHECKS=0;
---error ER_DUP_ENTRY
-INSERT INTO t3 VALUES (1),(1);
-sync_slave_with_master;
-
-connection master;
-SET FOREIGN_KEY_CHECKS=0;
-DROP TABLE IF EXISTS t1,t2,t3;
-SET FOREIGN_KEY_CHECKS=1;
-sync_slave_with_master;
-
-#
-# Bug #32468 delete rows event on a table with foreign key constraint fails
-#
-
-connection master;
-
-eval create table t1 (b int primary key) engine = $engine_type;
-eval create table t2 (a int primary key, b int, foreign key (b) references t1(b))
- engine = $engine_type;
-
-insert into t1 set b=1;
-insert into t2 set a=1, b=1;
-
-set foreign_key_checks=0;
-delete from t1;
-
---echo must sync w/o a problem (could not with the buggy code)
-sync_slave_with_master;
-select count(*) from t1 /* must be zero */;
-
-
-# cleanup for bug#32468
-
-connection master;
-drop table t2,t1;
-
---source include/rpl_end.inc
diff --git a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
index ed758313770..20c79ed4b3b 100644
--- a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
+++ b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
@@ -32,345 +32,97 @@ INSERT INTO tt_2(ddl_case) VALUES(0);
--echo # CHECK IMPLICT COMMIT
--echo #########################################################################
SET AUTOCOMMIT= 0;
-let $ddl_cases= 43;
-while ($ddl_cases >= 1)
-{
- --echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
- let $in_temporary= no;
- let $ok= yes;
- #
- # In SBR and MIXED modes, the commit event is usually the third event in the
- # binary log:
- #
- # 1: BEGIN
- # 2: INSERT
- # 3: COMMIT
- # 4: DDL EVENT which triggered the previous commmit.
- #
- if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
- {
- let $commit_event_row_number= 3;
- }
- #
- # In RBR mode, the commit event is usually the fourth event in the binary log:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: ROW EVENT
- # 4: COMMIT
- # 5: DDL EVENT which triggered the previous commmit.
- #
- if (`select @@binlog_format = 'ROW'`)
- {
- let $commit_event_row_number= 4;
- }
-
- let $first_binlog_position= query_get_value("SHOW MASTER STATUS", Position, 1);
- --enable_query_log
- eval INSERT INTO tt_1(ddl_case) VALUES ($ddl_cases);
- if ($ddl_cases == 43)
- {
- let $cmd= CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO";
- }
- if ($ddl_cases == 42)
- {
- let $cmd= DROP FUNCTION myfunc_int;
- }
- if ($ddl_cases == 41)
- {
- let $cmd= LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES;
- }
- if ($ddl_cases == 40)
- {
- let $cmd= LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES;
- }
- if ($ddl_cases == 39)
- {
- let $cmd= ANALYZE TABLE nt_1;
- }
- if ($ddl_cases == 38)
- {
- let $cmd= CHECK TABLE nt_1;
- }
- if ($ddl_cases == 37)
- {
- let $cmd= OPTIMIZE TABLE nt_1;
- }
- if ($ddl_cases == 36)
- {
- let $cmd= REPAIR TABLE nt_1;
- }
- if ($ddl_cases == 35)
- {
- let $cmd= LOCK TABLES tt_1 WRITE;
- }
- if ($ddl_cases == 34)
- {
- let $cmd= UNLOCK TABLES;
- }
- if ($ddl_cases == 33)
- {
- let $cmd= CREATE USER 'user'@'localhost';
- }
- if ($ddl_cases == 32)
- {
- let $cmd= GRANT ALL ON *.* TO 'user'@'localhost';
- }
- if ($ddl_cases == 31)
- {
- let $cmd= SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass');
- }
- if ($ddl_cases == 30)
- {
- let $cmd= REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost';
- }
- if ($ddl_cases == 29)
- {
- let $cmd= RENAME USER 'user'@'localhost' TO 'user_new'@'localhost';
- }
- if ($ddl_cases == 28)
- {
- let $cmd= DROP USER 'user_new'@'localhost';
- }
- if ($ddl_cases == 27)
- {
- let $cmd= CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1;
- }
- if ($ddl_cases == 26)
- {
- let $cmd= ALTER EVENT evt COMMENT 'evt';
- }
- if ($ddl_cases == 25)
- {
- let $cmd= DROP EVENT evt;
- }
- if ($ddl_cases == 24)
- {
- let $cmd= CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case;
- }
- if ($ddl_cases == 23)
- {
- let $cmd= DROP TRIGGER tr;
- #
- # In RBR mode, due to the trigger the tt_2 is also updated:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: TABLE MAP EVENT
- # 4: ROW EVENT
- # 5: COMMIT
- # 6: DDL EVENT which triggered the previous commmit.
- #
- if (`select @@binlog_format = 'ROW'`)
- {
- let $commit_event_row_number= 5;
- }
- }
- if ($ddl_cases == 22)
- {
- let $cmd= CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc";
- }
- if ($ddl_cases == 21)
- {
- let $cmd= ALTER FUNCTION fc COMMENT 'fc';
- }
- if ($ddl_cases == 20)
- {
- let $cmd= DROP FUNCTION fc;
- }
- if ($ddl_cases == 19)
- {
- let $cmd= CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case;
- }
- if ($ddl_cases == 18)
- {
- let $cmd= ALTER PROCEDURE pc COMMENT 'pc';
- }
- if ($ddl_cases == 17)
- {
- let $cmd= DROP PROCEDURE pc;
- }
- if ($ddl_cases == 16)
- {
- let $cmd= CREATE VIEW v AS SELECT * FROM tt_1;
- }
- if ($ddl_cases == 15)
- {
- let $cmd= ALTER VIEW v AS SELECT * FROM tt_1;
- }
- if ($ddl_cases == 14)
- {
- let $cmd= DROP VIEW v;
- }
- if ($ddl_cases == 13)
- {
- let $cmd= CREATE INDEX ix ON tt_1(ddl_case);
- }
- if ($ddl_cases == 12)
- {
- let $cmd= DROP INDEX ix ON tt_1;
- }
- if ($ddl_cases == 11)
- {
- let $cmd= CREATE TEMPORARY TABLE tt_xx (a int);
- let $in_temporary= yes;
- # In SBR and MIXED modes, the DDL statement is written to the binary log but
- # does not commit the current transaction.
- #
- # 1: BEGIN
- # 2: CREATE TEMPORARY
- # 3: INSERT
- # 4: COMMIT
- #
- # In RBR the transaction is not committed either and the statement is not
- # written to the binary log:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: ROW EVENT
- # 4: COMMIT
- #
- if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'` )
- {
- let $commit_event_row_number= 4;
- }
- }
- if ($ddl_cases == 10)
- {
- let $cmd= ALTER TABLE tt_xx ADD COLUMN (b int);
- #
- # In MIXED mode, the changes are logged as rows and we have what follows:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: ROW EVENT
- # 4: COMMIT
- # 5: DDL EVENT which triggered the previous commmit.
- #
- if (`select @@binlog_format = 'MIXED'`)
- {
- let $commit_event_row_number= 4;
- }
- }
- if ($ddl_cases == 9)
- {
- let $cmd= ALTER TABLE tt_xx RENAME new_tt_xx;
- #
- # In MIXED mode, the changes are logged as rows and we have what follows:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: ROW EVENT
- # 4: COMMIT
- # 5: DDL EVENT which triggered the previous commmit.
- #
- if (`select @@binlog_format = 'MIXED'`)
- {
- let $commit_event_row_number= 4;
- }
- }
- if ($ddl_cases == 8)
- {
- let $cmd= DROP TEMPORARY TABLE IF EXISTS new_tt_xx;
- let $in_temporary= yes;
- #
- # In SBR and MIXED modes, the DDL statement is written to the binary log
- # but does not commit the current transaction:
- #
- # In SBR, we have what follows:
- #
- # 1: BEGIN
- # 2: INSERT
- # 3: DROP TEMPORARY
- # 4: COMMIT
- #
- # In RBR the transaction is not committed either and the statement is not
- # written to the binary log:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: ROW EVENT
- # 4: COMMIT
- #
- if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'ROW'`)
- {
- let $commit_event_row_number= 4;
- }
- # In MIXED mode, the changes are logged as rows and we have what follows:
- #
- # 1: BEGIN
- # 2: TABLE MAP EVENT
- # 3: ROW EVENT
- # 4: DROP TEMPORARY
- # 5: COMMIT
- #
- if (`select @@binlog_format = 'MIXED'`)
- {
- let $commit_event_row_number= 5;
- }
- }
- if ($ddl_cases == 7)
- {
- let $cmd= CREATE TABLE tt_xx (a int);
- }
- if ($ddl_cases == 6)
- {
- let $cmd= ALTER TABLE tt_xx ADD COLUMN (b int);
- }
- if ($ddl_cases == 5)
- {
- let $cmd= RENAME TABLE tt_xx TO new_tt_xx;
- }
- if ($ddl_cases == 4)
- {
- let $cmd= TRUNCATE TABLE new_tt_xx;
- }
- if ($ddl_cases == 3)
- {
- let $cmd= DROP TABLE IF EXISTS tt_xx, new_tt_xx;
- }
- if ($ddl_cases == 2)
- {
- let $cmd= CREATE DATABASE db;
- }
- if ($ddl_cases == 1)
- {
- let $cmd= DROP DATABASE IF EXISTS db;
- }
- --replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
- --eval $cmd
- --disable_query_log
- #
- # When a temporary table is either created or dropped, there is no implicit
- # commit. The flag in_temporary is used to avoid aborting the test in such
- # cases. Thus we force the commit.
- #
- if ($in_temporary == yes)
- {
- --eval COMMIT
- }
- let $event_commit= query_get_value("SHOW BINLOG EVENTS FROM $first_binlog_position", Info, $commit_event_row_number);
- if (`SELECT SUBSTRING("$event_commit",1,6) != "COMMIT"`)
- {
- if ($ok == yes)
- {
- --echo it *does not* commit the current transaction.
- --echo $cmd
- --echo $event_commit
- SHOW BINLOG EVENTS;
- exit;
- }
- }
+INSERT INTO tt_1(ddl_case) VALUES (43);
+replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB;
+eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO";
+INSERT INTO tt_1(ddl_case) VALUES (42);
+DROP FUNCTION myfunc_int;
+INSERT INTO tt_1(ddl_case) VALUES (41);
+LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES;
+INSERT INTO tt_1(ddl_case) VALUES (40);
+LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES;
+INSERT INTO tt_1(ddl_case) VALUES (39);
+ANALYZE TABLE nt_1;
+INSERT INTO tt_1(ddl_case) VALUES (38);
+CHECK TABLE nt_1;
+INSERT INTO tt_1(ddl_case) VALUES (37);
+OPTIMIZE TABLE nt_1;
+INSERT INTO tt_1(ddl_case) VALUES (36);
+REPAIR TABLE nt_1;
+INSERT INTO tt_1(ddl_case) VALUES (35);
+LOCK TABLES tt_1 WRITE;
+INSERT INTO tt_1(ddl_case) VALUES (34);
+UNLOCK TABLES;
+INSERT INTO tt_1(ddl_case) VALUES (33);
+CREATE USER 'user'@'localhost';
+INSERT INTO tt_1(ddl_case) VALUES (32);
+GRANT ALL ON *.* TO 'user'@'localhost';
+INSERT INTO tt_1(ddl_case) VALUES (31);
+SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass');
+INSERT INTO tt_1(ddl_case) VALUES (30);
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost';
+INSERT INTO tt_1(ddl_case) VALUES (29);
+RENAME USER 'user'@'localhost' TO 'user_new'@'localhost';
+INSERT INTO tt_1(ddl_case) VALUES (28);
+DROP USER 'user_new'@'localhost';
+INSERT INTO tt_1(ddl_case) VALUES (27);
+CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1;
+INSERT INTO tt_1(ddl_case) VALUES (26);
+ALTER EVENT evt COMMENT 'evt';
+INSERT INTO tt_1(ddl_case) VALUES (25);
+DROP EVENT evt;
+INSERT INTO tt_1(ddl_case) VALUES (24);
+CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case;
+INSERT INTO tt_1(ddl_case) VALUES (23);
+DROP TRIGGER tr;
+INSERT INTO tt_1(ddl_case) VALUES (22);
+CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc";
+INSERT INTO tt_1(ddl_case) VALUES (21);
+ALTER FUNCTION fc COMMENT 'fc';
+INSERT INTO tt_1(ddl_case) VALUES (20);
+DROP FUNCTION fc;
+INSERT INTO tt_1(ddl_case) VALUES (19);
+CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case;
+INSERT INTO tt_1(ddl_case) VALUES (18);
+ALTER PROCEDURE pc COMMENT 'pc';
+INSERT INTO tt_1(ddl_case) VALUES (17);
+DROP PROCEDURE pc;
+INSERT INTO tt_1(ddl_case) VALUES (16);
+CREATE VIEW v AS SELECT * FROM tt_1;
+INSERT INTO tt_1(ddl_case) VALUES (15);
+ALTER VIEW v AS SELECT * FROM tt_1;
+INSERT INTO tt_1(ddl_case) VALUES (14);
+DROP VIEW v;
+INSERT INTO tt_1(ddl_case) VALUES (13);
+CREATE INDEX ix ON tt_1(ddl_case);
+INSERT INTO tt_1(ddl_case) VALUES (12);
+DROP INDEX ix ON tt_1;
+INSERT INTO tt_1(ddl_case) VALUES (11);
+CREATE TEMPORARY TABLE tt_xx (a int);
+INSERT INTO tt_1(ddl_case) VALUES (10);
+ALTER TABLE tt_xx ADD COLUMN (b int);
+INSERT INTO tt_1(ddl_case) VALUES (9);
+ALTER TABLE tt_xx RENAME new_tt_xx;
+INSERT INTO tt_1(ddl_case) VALUES (8);
+DROP TEMPORARY TABLE IF EXISTS new_tt_xx;
+INSERT INTO tt_1(ddl_case) VALUES (7);
+CREATE TABLE tt_xx (a int);
+INSERT INTO tt_1(ddl_case) VALUES (6);
+ALTER TABLE tt_xx ADD COLUMN (b int);
+INSERT INTO tt_1(ddl_case) VALUES (5);
+RENAME TABLE tt_xx TO new_tt_xx;
+INSERT INTO tt_1(ddl_case) VALUES (4);
+TRUNCATE TABLE new_tt_xx;
+INSERT INTO tt_1(ddl_case) VALUES (3);
+DROP TABLE IF EXISTS tt_xx, new_tt_xx;
+INSERT INTO tt_1(ddl_case) VALUES (2);
+CREATE DATABASE db;
+INSERT INTO tt_1(ddl_case) VALUES (1);
+DROP DATABASE IF EXISTS db;
+
+source include/show_binlog_events.inc;
- --echo -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
- let $binlog_start= $first_binlog_position;
- --echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
- --source include/show_binlog_events.inc
- --echo -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
- --echo
- dec $ddl_cases;
-}
SET AUTOCOMMIT= 1;
--echo ###################################################################################
diff --git a/mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test b/mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test
new file mode 100644
index 00000000000..fa48142ee91
--- /dev/null
+++ b/mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test
@@ -0,0 +1,141 @@
+# BUG#37656
+#
+# This test aims at checking whether lower_case_table_names=1 option works
+# for database names and table names.
+#
+# This test checks the following (when lower_case_table_names=1 is set on slave):
+# (i) creating a database on upper case on master results in lower case
+# database name on slave
+# (ii) creating tables with upper case names on master results in lower case
+# table names on slave
+# (iii) loading data infile into capitalized table name on master replicates to
+# lower case table name on slave
+# (iv) Propagating changes from upper case table names on into correspondent
+# lower case table names on slave works.
+
+
+# setup: create database and tables
+-- echo ******** [ MASTER ] ********
+-- let $dbname_upper= BUG_37656
+-- let $dbname_lower= `SELECT LOWER('$dbname_upper')`
+-- eval CREATE DATABASE $dbname_upper
+-- eval use $dbname_upper
+
+# assert: database names are in upper case in master and lower
+# case in slave
+-- eval show databases like '$dbname_upper'
+sync_slave_with_master;
+-- echo ******** [ SLAVE ] ********
+--eval show databases like '$dbname_lower'
+
+-- connection master
+-- echo ******** [ MASTER ] ********
+CREATE TABLE T1 (a int);
+-- eval CREATE TABLE T2 (b int) ENGINE=$engine
+CREATE TABLE T3 (txt TEXT);
+
+# assert: that tables exist on master with upper case names
+show tables;
+
+# assert: that tables exist on slave but with lower case names
+-- sync_slave_with_master
+-- echo ******** [ SLAVE ] ********
+-- eval use $dbname_lower
+show tables;
+
+# action: lets create t1 for asserting below that t1 does not get changes
+# from master (slave configured with --replicate-ignore-db=$dbname_lower.t1)
+CREATE TABLE t1 (a INT);
+
+# action: fill data into tables
+-- connection master
+-- echo ******** [ MASTER ] ********
+-- eval use $dbname_upper
+INSERT INTO T1 VALUES (1);
+INSERT INTO T2 VALUES (1);
+if (`SELECT @@session.binlog_format != 'ROW'`)
+{
+ -- eval LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE $dbname_upper.T3
+}
+
+if (`SELECT @@session.binlog_format = 'ROW'`)
+{
+ use test;
+ -- eval INSERT INTO $dbname_upper.T1 VALUES (2)
+ -- eval INSERT INTO $dbname_upper.T2 VALUES (2)
+ -- eval LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE $dbname_upper.T3
+}
+# assert: lower case tables on lower case database on slave
+# get updates from upper case tables on upper case
+# database on master
+-- sync_slave_with_master
+-- echo ******** [ SLAVE ] ********
+
+# assert: changes for slave's t1 were filterd out
+if (`SELECT count(*) != 0 FROM t1`)
+{
+ -- echo UNEXPECTED DATA on $dbname_lower.t1 as table is filtered by replicate-ignore-table rules
+}
+
+-- let $diff_tables=master:$dbname_upper.T2, slave:$dbname_lower.t2
+-- source include/diff_tables.inc
+
+-- let $diff_tables=master:$dbname_upper.T3, slave:$dbname_lower.t3
+-- source include/diff_tables.inc
+
+# clean up
+-- connection master
+-- echo ******** [ MASTER ] ********
+-- eval DROP DATABASE $dbname_upper
+-- sync_slave_with_master
+
+
+#
+# BUG#50653: drop procedure implicitely treats db name in a case sensitive way
+#
+
+-- connection master
+
+-- let $dbname= B50653
+-- let $procname= b50653_proc
+
+-- eval CREATE DATABASE $dbname
+-- eval USE $dbname
+-- eval CREATE PROCEDURE $procname() BEGIN SELECT 1; END
+
+if (`SELECT count(*) = 1 FROM mysql.proc WHERE name like '$dbname'`)
+{
+ -- die Procedure not created on MASTER
+}
+
+-- sync_slave_with_master
+if (`SELECT count(*) = 1 FROM mysql.proc WHERE name like '$dbname'`)
+{
+ -- die Procedure not created on SLAVE
+}
+
+-- connection master
+-- eval DROP PROCEDURE $procname
+
+if (`SELECT count(*) FROM mysql.proc WHERE name like '$dbname'`)
+{
+ -- die Procedure not dropped on MASTER
+}
+
+-- sync_slave_with_master
+if (`SELECT count(*) FROM mysql.proc WHERE name like '$dbname'`)
+{
+ -- die Procedure not dropped on SLAVE
+}
+
+-- let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1)
+if ($last_error)
+{
+ -- die UNEXPECTED SLAVE SQL error: $last_error
+}
+
+-- connection master
+-- eval DROP DATABASE $dbname
+-- sync_slave_with_master
+
+-- source include/rpl_end.inc