mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
mergin 5.1 -> rep+2 -> rep+3. create_table_from_dump issue will be merged on the next step
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
RESET MASTER;
|
||||
CREATE TABLE t1 (a int);
|
||||
### assertion: index file contains regular entries
|
||||
SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
|
||||
SELECT @index;
|
||||
@index
|
||||
master-bin.000001
|
||||
|
||||
### assertion: show original binlogs
|
||||
show binary logs;
|
||||
Log_name File_size
|
||||
master-bin.000001 #
|
||||
### assertion: binlog contents from regular entries
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int)
|
||||
FLUSH LOGS;
|
||||
### assertion: index file contains renamed binlog and the new one
|
||||
SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
|
||||
SELECT @index;
|
||||
@index
|
||||
master-bin-b34582.000001
|
||||
master-bin.000002
|
||||
|
||||
### assertion: original binlog content still exists, despite we
|
||||
### renamed and changed the index file
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin-b34582.000001 # Query # # use `test`; CREATE TABLE t1 (a int)
|
||||
### assertion: user changed binlog index shows correct entries
|
||||
show binary logs;
|
||||
Log_name File_size
|
||||
master-bin-b34582.000001 #
|
||||
master-bin.000002 #
|
||||
DROP TABLE t1;
|
||||
### assertion: purging binlogs up to binlog created after instrumenting index file should work
|
||||
PURGE BINARY LOGS TO 'master-bin.000002';
|
||||
### assertion: show binary logs should only contain latest binlog
|
||||
show binary logs;
|
||||
Log_name File_size
|
||||
master-bin.000002 #
|
||||
### assertion: assert that binlog files were indeed purged (using file_exists calls)
|
||||
### assertion: assert that not purged binlog file exists
|
||||
### assertion: show index file contents and these should match show binary logs issued above
|
||||
SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
|
||||
SELECT @index;
|
||||
@index
|
||||
master-bin.000002
|
||||
|
||||
RESET MASTER;
|
8
mysql-test/suite/binlog/r/binlog_max_extension.result
Normal file
8
mysql-test/suite/binlog/r/binlog_max_extension.result
Normal file
@ -0,0 +1,8 @@
|
||||
call mtr.add_suppression("Next log extension: 2147483647. Remaining log filename extensions: 0.");
|
||||
call mtr.add_suppression("Log filename extension number exhausted:");
|
||||
call mtr.add_suppression("Can't generate a unique log-filename");
|
||||
RESET MASTER;
|
||||
FLUSH LOGS;
|
||||
Warnings:
|
||||
Warning 1098 Can't generate a unique log-filename master-bin.(1-999)
|
||||
|
@ -19,6 +19,7 @@ DROP TABLE IF EXISTS tmp2, t;
|
||||
SELECT GET_LOCK("a",10);
|
||||
GET_LOCK("a",10)
|
||||
1
|
||||
USE test;
|
||||
SELECT GET_LOCK("a",10);
|
||||
GET_LOCK("a",10)
|
||||
1
|
||||
|
42
mysql-test/suite/binlog/r/binlog_stm_do_db.result
Normal file
42
mysql-test/suite/binlog/r/binlog_stm_do_db.result
Normal file
@ -0,0 +1,42 @@
|
||||
SET @old_isolation_level= @@session.tx_isolation;
|
||||
SET @@session.tx_isolation= 'READ-COMMITTED';
|
||||
CREATE DATABASE b42829;
|
||||
use b42829;
|
||||
CREATE TABLE t1 (x int, y int) engine=InnoDB;
|
||||
CREATE TABLE t2 (x int, y int) engine=InnoDB;
|
||||
CREATE DATABASE b42829_filtered;
|
||||
use b42829_filtered;
|
||||
CREATE TABLE t1 (x int, y int) engine=InnoDB;
|
||||
CREATE TABLE t2 (x int, y int) engine=InnoDB;
|
||||
SET @@session.sql_log_bin= 0;
|
||||
INSERT INTO b42829_filtered.t1 VALUES (100,100);
|
||||
INSERT INTO b42829.t1 VALUES (100,100);
|
||||
SET @@session.sql_log_bin= 1;
|
||||
### assertion: the inserts will not raise log error because
|
||||
### binlog-do-db is filtering used database
|
||||
INSERT INTO t2 VALUES (1,2), (1,3), (1,4);
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
### assertion: assert that despite updating a not filtered
|
||||
### database this wont trigger an error as the
|
||||
### used database is the filtered one.
|
||||
UPDATE b42829_filtered.t1 ft1, b42829.t1 nft1 SET ft1.x=1, nft1.x=2;
|
||||
use b42829;
|
||||
### assertion: the statements *will* raise log error because
|
||||
### binlog-do-db is not filtering used database
|
||||
BEGIN;
|
||||
INSERT INTO t2 VALUES (1,2), (1,3), (1,4);
|
||||
ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'
|
||||
UPDATE b42829_filtered.t1 ft1, b42829.t1 nft1 SET ft1.x=1, nft1.x=2;
|
||||
ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'
|
||||
COMMIT;
|
||||
### assertion: filtered events did not make into the binlog
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # CREATE DATABASE b42829
|
||||
master-bin.000001 # Query # # use `b42829`; CREATE TABLE t1 (x int, y int) engine=InnoDB
|
||||
master-bin.000001 # Query # # use `b42829`; CREATE TABLE t2 (x int, y int) engine=InnoDB
|
||||
DROP DATABASE b42829;
|
||||
DROP DATABASE b42829_filtered;
|
||||
SET @@session.tx_isolation= @old_isolation_level;
|
@ -19,6 +19,7 @@ DROP TABLE IF EXISTS tmp2, t;
|
||||
SELECT GET_LOCK("a",10);
|
||||
GET_LOCK("a",10)
|
||||
1
|
||||
USE test;
|
||||
SELECT GET_LOCK("a",10);
|
||||
GET_LOCK("a",10)
|
||||
1
|
||||
|
@ -515,7 +515,11 @@ return n;
|
||||
end|
|
||||
reset master;
|
||||
insert into t2 values (bug27417(1));
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
insert into t2 select bug27417(2);
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
reset master;
|
||||
insert into t2 values (bug27417(2));
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
@ -534,6 +538,8 @@ select count(*) from t2;
|
||||
count(*)
|
||||
2
|
||||
delete from t2 where a=bug27417(3);
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
select count(*) from t2 /* nothing got deleted */;
|
||||
count(*)
|
||||
2
|
||||
@ -548,6 +554,8 @@ select count(*) from t1 /* must be 5 */;
|
||||
count(*)
|
||||
5
|
||||
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
affected rows: 0
|
||||
select count(*) from t1 /* must be 7 */;
|
||||
count(*)
|
||||
@ -771,7 +779,11 @@ return n;
|
||||
end|
|
||||
reset master;
|
||||
insert into t2 values (bug27417(1));
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
insert into t2 select bug27417(2);
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
reset master;
|
||||
insert into t2 values (bug27417(2));
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
@ -789,6 +801,8 @@ select count(*) from t2;
|
||||
count(*)
|
||||
2
|
||||
delete from t2 where a=bug27417(3);
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
select count(*) from t2 /* nothing got deleted */;
|
||||
count(*)
|
||||
2
|
||||
@ -802,6 +816,8 @@ select count(*) from t1 /* must be 5 */;
|
||||
count(*)
|
||||
5
|
||||
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
affected rows: 0
|
||||
select count(*) from t1 /* must be 7 */;
|
||||
count(*)
|
||||
|
@ -2988,4 +2988,59 @@ SET @@session.binlog_format = @old_binlog_format;
|
||||
DROP TABLE t1, t2;
|
||||
DROP PROCEDURE proc_insert_delayed;
|
||||
DROP FUNCTION func_limit;
|
||||
CREATE TABLE t1 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
CREATE FUNCTION func_modify_t1 ()
|
||||
RETURNS INT
|
||||
BEGIN
|
||||
INSERT INTO t1 SET a = 1;
|
||||
RETURN 0;
|
||||
END|
|
||||
# The following statement causes auto-incrementation
|
||||
# of both t1 and t2. It is logged in statement format,
|
||||
# so it should produce unsafe warning.
|
||||
INSERT INTO t2 SET a = func_modify_t1();
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
SET SESSION binlog_format = MIXED;
|
||||
# Check if the statement is logged in row format.
|
||||
INSERT INTO t2 SET a = func_modify_t1();
|
||||
SHOW BINLOG EVENTS FROM 12283;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 12283 Query 1 12351 BEGIN
|
||||
master-bin.000001 12351 Table_map 1 12393 table_id: 44 (test.t2)
|
||||
master-bin.000001 12393 Table_map 1 12435 table_id: 45 (test.t1)
|
||||
master-bin.000001 12435 Write_rows 1 12473 table_id: 45
|
||||
master-bin.000001 12473 Write_rows 1 12511 table_id: 44 flags: STMT_END_F
|
||||
master-bin.000001 12511 Query 1 12580 COMMIT
|
||||
DROP TABLE t1,t2;
|
||||
DROP FUNCTION func_modify_t1;
|
||||
SET SESSION binlog_format = STATEMENT;
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
CREATE TABLE t3 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
create trigger tri_modify_two_tables before insert on t1 for each row begin
|
||||
insert into t2(a) values(new.a);
|
||||
insert into t3(a) values(new.a);
|
||||
end |
|
||||
# The following statement causes auto-incrementation
|
||||
# of both t2 and t3. It is logged in statement format,
|
||||
# so it should produce unsafe warning
|
||||
INSERT INTO t1 SET a = 1;
|
||||
Warnings:
|
||||
Note 1592 Statement may not be safe to log in statement format.
|
||||
SET SESSION binlog_format = MIXED;
|
||||
# Check if the statement is logged in row format.
|
||||
INSERT INTO t1 SET a = 2;
|
||||
SHOW BINLOG EVENTS FROM 13426;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 13426 Query 1 13494 BEGIN
|
||||
master-bin.000001 13494 Table_map 1 13535 table_id: 47 (test.t1)
|
||||
master-bin.000001 13535 Table_map 1 13577 table_id: 48 (test.t3)
|
||||
master-bin.000001 13577 Table_map 1 13619 table_id: 49 (test.t2)
|
||||
master-bin.000001 13619 Write_rows 1 13657 table_id: 49
|
||||
master-bin.000001 13657 Write_rows 1 13695 table_id: 48
|
||||
master-bin.000001 13695 Write_rows 1 13729 table_id: 47 flags: STMT_END_F
|
||||
master-bin.000001 13729 Query 1 13798 COMMIT
|
||||
DROP TABLE t1,t2,t3;
|
||||
"End of tests"
|
||||
|
114
mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test
Normal file
114
mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test
Normal file
@ -0,0 +1,114 @@
|
||||
# BUG#34582: FLUSH LOGS does not close and reopen the binlog index
|
||||
# file
|
||||
#
|
||||
# WHAT
|
||||
# ====
|
||||
#
|
||||
# We want to test that FLUSH LOGS closes and reopens binlog index
|
||||
# file.
|
||||
#
|
||||
# HOW
|
||||
# ===
|
||||
#
|
||||
# PREPARE:
|
||||
# 1. create some binlog events
|
||||
# 2. show index content, binlog events and binlog contents
|
||||
# for mysql-bin.000001
|
||||
# 3. copy the mysql-bin.000001 to mysql-bin-b34582.000001
|
||||
# 4. change the index file so that mysql-bin.000001 is replaced
|
||||
# with mysql-bin-b34582.000001
|
||||
# 5. FLUSH the logs so that new index is closed and reopened
|
||||
#
|
||||
# ASSERTIONS:
|
||||
# 1. index file contents shows mysql-bin-b34582.000001 and
|
||||
# mysql-bin.000002
|
||||
# 1. show binary logs shows current index entries
|
||||
# 2. binlog contents for mysql-bin-b34582.000001 are displayed
|
||||
# 3. Purge binlogs up to the latest one succeeds
|
||||
# 4. SHOW BINARY LOGS presents the latest one only after purging
|
||||
# 5. Purged binlogs files don't exist in the filesystem
|
||||
# 6. Not purged binlog file exists in the filesystem
|
||||
#
|
||||
# CLEAN UP:
|
||||
# 1. RESET MASTER
|
||||
#
|
||||
|
||||
-- source include/have_log_bin.inc
|
||||
|
||||
RESET MASTER;
|
||||
|
||||
-- let $datadir= `SELECT @@datadir`
|
||||
-- let $index=$datadir/master-bin.index
|
||||
-- chmod 0644 $index
|
||||
|
||||
# action: issue one command so that binlog gets some event
|
||||
CREATE TABLE t1 (a int);
|
||||
|
||||
-- echo ### assertion: index file contains regular entries
|
||||
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
-- eval SET @index=LOAD_FILE('$index')
|
||||
-- replace_regex /\.[\\\/]master/master/
|
||||
SELECT @index;
|
||||
|
||||
--echo ### assertion: show original binlogs
|
||||
-- source include/show_binary_logs.inc
|
||||
|
||||
--echo ### assertion: binlog contents from regular entries
|
||||
-- source include/show_binlog_events.inc
|
||||
|
||||
# action: copy binlogs to other names and change entries in index file
|
||||
-- copy_file $datadir/master-bin.000001 $datadir/master-bin-b34582.000001
|
||||
let INDEX_FILE=$index;
|
||||
perl;
|
||||
$file= $ENV{'INDEX_FILE'};
|
||||
open(FILE, ">$file") || die "Unable to open $file.";
|
||||
truncate(FILE,0);
|
||||
close ($file);
|
||||
EOF
|
||||
|
||||
-- append_file $index
|
||||
master-bin-b34582.000001
|
||||
EOF
|
||||
|
||||
# action: should cause rotation, and creation of new binlogs
|
||||
FLUSH LOGS;
|
||||
|
||||
# file is not used anymore - remove it (mysql closed on flush logs).
|
||||
-- remove_file $datadir/master-bin.000001
|
||||
|
||||
-- echo ### assertion: index file contains renamed binlog and the new one
|
||||
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
-- eval SET @index=LOAD_FILE('$index')
|
||||
-- replace_regex /\.[\\\/]master/master/
|
||||
SELECT @index;
|
||||
|
||||
-- echo ### assertion: original binlog content still exists, despite we
|
||||
-- echo ### renamed and changed the index file
|
||||
-- source include/show_binlog_events.inc
|
||||
|
||||
-- echo ### assertion: user changed binlog index shows correct entries
|
||||
-- source include/show_binary_logs.inc
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
-- echo ### assertion: purging binlogs up to binlog created after instrumenting index file should work
|
||||
-- let $current_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
|
||||
-- eval PURGE BINARY LOGS TO '$current_binlog'
|
||||
|
||||
-- echo ### assertion: show binary logs should only contain latest binlog
|
||||
-- source include/show_binary_logs.inc
|
||||
|
||||
-- echo ### assertion: assert that binlog files were indeed purged (using file_exists calls)
|
||||
-- error 1
|
||||
-- file_exists $datadir/master-bin-b34852.000001
|
||||
|
||||
-- echo ### assertion: assert that not purged binlog file exists
|
||||
-- file_exists $datadir/$current_binlog
|
||||
|
||||
-- echo ### assertion: show index file contents and these should match show binary logs issued above
|
||||
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
-- eval SET @index=LOAD_FILE('$index')
|
||||
-- replace_regex /\.[\\\/]master/master/
|
||||
SELECT @index;
|
||||
|
||||
RESET MASTER;
|
92
mysql-test/suite/binlog/t/binlog_max_extension.test
Normal file
92
mysql-test/suite/binlog/t/binlog_max_extension.test
Normal file
@ -0,0 +1,92 @@
|
||||
# BUG#40611: MySQL cannot make a binary log after sequential number beyond
|
||||
# unsigned long.
|
||||
#
|
||||
# Problem statement
|
||||
# =================
|
||||
#
|
||||
# Extension for log file names might be created with negative
|
||||
# numbers (when counter used would wrap around), causing server
|
||||
# failure when incrementing -00001 (reaching number 000000
|
||||
# extension).
|
||||
#
|
||||
# Test
|
||||
# ====
|
||||
# This tests aims at testing the a patch that removes negatives
|
||||
# numbers from log name extensions and checks that the server
|
||||
# reports gracefully that the limit has been reached.
|
||||
#
|
||||
# It instruments index file to point to a log file close to
|
||||
# the new maximum and calls flush logs to get warning.
|
||||
#
|
||||
|
||||
call mtr.add_suppression("Next log extension: 2147483647. Remaining log filename extensions: 0.");
|
||||
call mtr.add_suppression("Log filename extension number exhausted:");
|
||||
call mtr.add_suppression("Can't generate a unique log-filename");
|
||||
|
||||
|
||||
-- source include/have_log_bin.inc
|
||||
RESET MASTER;
|
||||
|
||||
-- let $MYSQLD_DATADIR= `select @@datadir`
|
||||
|
||||
###############################################
|
||||
# check hitting maximum file name extension:
|
||||
###############################################
|
||||
|
||||
##########
|
||||
# Prepare
|
||||
##########
|
||||
|
||||
# 1. Stop master server
|
||||
-- write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
wait
|
||||
EOF
|
||||
-- shutdown_server 10
|
||||
-- source include/wait_until_disconnected.inc
|
||||
|
||||
# 2. Prepare log and index file
|
||||
-- copy_file $MYSQLD_DATADIR/master-bin.index $MYSQLD_DATADIR/master-bin.index.orig
|
||||
-- copy_file $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.2147483646
|
||||
-- append_file $MYSQLD_DATADIR/master-bin.index
|
||||
master-bin.2147483646
|
||||
EOF
|
||||
|
||||
# 3. Restart the server
|
||||
-- append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
restart
|
||||
EOF
|
||||
-- enable_reconnect
|
||||
-- source include/wait_until_connected_again.inc
|
||||
|
||||
###########
|
||||
# Assertion
|
||||
###########
|
||||
|
||||
# assertion: should throw warning
|
||||
FLUSH LOGS;
|
||||
|
||||
##############
|
||||
# Clean up
|
||||
##############
|
||||
|
||||
# 1. Stop the server
|
||||
-- write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
wait
|
||||
EOF
|
||||
-- shutdown_server 10
|
||||
-- source include/wait_until_disconnected.inc
|
||||
|
||||
# 2. Undo changes to index and log files
|
||||
-- remove_file $MYSQLD_DATADIR/master-bin.index
|
||||
-- copy_file $MYSQLD_DATADIR/master-bin.index.orig $MYSQLD_DATADIR/master-bin.index
|
||||
-- remove_file $MYSQLD_DATADIR/master-bin.index.orig
|
||||
|
||||
-- remove_file $MYSQLD_DATADIR/master-bin.2147483646
|
||||
-- remove_file $MYSQLD_DATADIR/master-bin.2147483647
|
||||
|
||||
# 3. Restart the server
|
||||
-- append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
restart
|
||||
EOF
|
||||
-- enable_reconnect
|
||||
-- source include/wait_until_connected_again.inc
|
1
mysql-test/suite/binlog/t/binlog_stm_do_db-master.opt
Normal file
1
mysql-test/suite/binlog/t/binlog_stm_do_db-master.opt
Normal file
@ -0,0 +1 @@
|
||||
--binlog-do-db=b42829
|
90
mysql-test/suite/binlog/t/binlog_stm_do_db.test
Normal file
90
mysql-test/suite/binlog/t/binlog_stm_do_db.test
Normal file
@ -0,0 +1,90 @@
|
||||
# BUG#42829: binlogging enabled for all schemas regardless of
|
||||
# binlog-db-db / binlog-ignore-db
|
||||
#
|
||||
# WHAT
|
||||
# ====
|
||||
#
|
||||
# We want to test whether filtered events from binlog will cause
|
||||
# raising an error mentioning that statement is unable to be logged or
|
||||
# not, when:
|
||||
#
|
||||
# 1. isolation level READ-COMMITTED; AND
|
||||
#
|
||||
# 2. using InnoDB engine; AND
|
||||
#
|
||||
# 3. using SBL (in which case InnoDB will only allow RBL).
|
||||
#
|
||||
# HOW
|
||||
# ===
|
||||
#
|
||||
# The test is implemented as follows:
|
||||
#
|
||||
# i) set tx_isolation to read-committed.
|
||||
#
|
||||
# ii) create two databases (one filtered other not - using
|
||||
# binlog-do-db)
|
||||
#
|
||||
# iii) Create statements that are to be filtered on filtered db
|
||||
#
|
||||
# - At this point, before fix, an error would be raised
|
||||
#
|
||||
# iv) do the same thing for not the filtered database and check
|
||||
# that events throw an error:
|
||||
#
|
||||
# - Error: ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
|
||||
#
|
||||
|
||||
-- source include/have_log_bin.inc
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/have_binlog_format_statement.inc
|
||||
|
||||
SET @old_isolation_level= @@session.tx_isolation;
|
||||
SET @@session.tx_isolation= 'READ-COMMITTED';
|
||||
|
||||
-- let $engine= InnoDB
|
||||
-- let $filtered= b42829_filtered
|
||||
-- let $not_filtered= b42829
|
||||
|
||||
-- eval CREATE DATABASE $not_filtered
|
||||
-- eval use $not_filtered
|
||||
-- eval CREATE TABLE t1 (x int, y int) engine=$engine
|
||||
-- eval CREATE TABLE t2 (x int, y int) engine=$engine
|
||||
|
||||
-- eval CREATE DATABASE $filtered
|
||||
-- eval use $filtered
|
||||
-- eval CREATE TABLE t1 (x int, y int) engine=$engine
|
||||
-- eval CREATE TABLE t2 (x int, y int) engine=$engine
|
||||
|
||||
SET @@session.sql_log_bin= 0;
|
||||
-- eval INSERT INTO $filtered.t1 VALUES (100,100)
|
||||
-- eval INSERT INTO $not_filtered.t1 VALUES (100,100)
|
||||
SET @@session.sql_log_bin= 1;
|
||||
|
||||
-- echo ### assertion: the inserts will not raise log error because
|
||||
-- echo ### binlog-do-db is filtering used database
|
||||
INSERT INTO t2 VALUES (1,2), (1,3), (1,4);
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
|
||||
-- echo ### assertion: assert that despite updating a not filtered
|
||||
-- echo ### database this wont trigger an error as the
|
||||
-- echo ### used database is the filtered one.
|
||||
-- eval UPDATE $filtered.t1 ft1, $not_filtered.t1 nft1 SET ft1.x=1, nft1.x=2
|
||||
|
||||
-- eval use $not_filtered
|
||||
-- echo ### assertion: the statements *will* raise log error because
|
||||
-- echo ### binlog-do-db is not filtering used database
|
||||
BEGIN;
|
||||
-- error ER_BINLOG_LOGGING_IMPOSSIBLE
|
||||
INSERT INTO t2 VALUES (1,2), (1,3), (1,4);
|
||||
-- error ER_BINLOG_LOGGING_IMPOSSIBLE
|
||||
-- eval UPDATE $filtered.t1 ft1, $not_filtered.t1 nft1 SET ft1.x=1, nft1.x=2
|
||||
-- error ER_BINLOG_LOGGING_IMPOSSIBLE
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
COMMIT;
|
||||
|
||||
-- echo ### assertion: filtered events did not make into the binlog
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
-- eval DROP DATABASE $not_filtered
|
||||
-- eval DROP DATABASE $filtered
|
||||
SET @@session.tx_isolation= @old_isolation_level;
|
@ -578,5 +578,72 @@ DROP TABLE t1, t2;
|
||||
DROP PROCEDURE proc_insert_delayed;
|
||||
DROP FUNCTION func_limit;
|
||||
|
||||
#
|
||||
# BUG#45827
|
||||
# The test verifies if stmt that have more than one
|
||||
# different tables to update with autoinc columns
|
||||
# will produce unsafe warning
|
||||
#
|
||||
|
||||
# Test case1: stmt that have more than one different tables
|
||||
# to update with autoinc columns should produce
|
||||
# unsafe warning when calling a function
|
||||
CREATE TABLE t1 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
|
||||
# The purpose of this function is to insert into t1 so that the second
|
||||
# column is auto_increment'ed.
|
||||
DELIMITER |;
|
||||
CREATE FUNCTION func_modify_t1 ()
|
||||
RETURNS INT
|
||||
BEGIN
|
||||
INSERT INTO t1 SET a = 1;
|
||||
RETURN 0;
|
||||
END|
|
||||
DELIMITER ;|
|
||||
--echo # The following statement causes auto-incrementation
|
||||
--echo # of both t1 and t2. It is logged in statement format,
|
||||
--echo # so it should produce unsafe warning.
|
||||
INSERT INTO t2 SET a = func_modify_t1();
|
||||
|
||||
SET SESSION binlog_format = MIXED;
|
||||
--echo # Check if the statement is logged in row format.
|
||||
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
INSERT INTO t2 SET a = func_modify_t1();
|
||||
eval SHOW BINLOG EVENTS FROM $pos0_master;
|
||||
|
||||
# clean up
|
||||
DROP TABLE t1,t2;
|
||||
DROP FUNCTION func_modify_t1;
|
||||
|
||||
# Test case2: stmt that have more than one different tables
|
||||
# to update with autoinc columns should produce
|
||||
# unsafe warning when invoking a trigger
|
||||
SET SESSION binlog_format = STATEMENT;
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
CREATE TABLE t3 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
|
||||
# The purpose of this function is to insert into t1 so that the second
|
||||
# column is auto_increment'ed.
|
||||
delimiter |;
|
||||
create trigger tri_modify_two_tables before insert on t1 for each row begin
|
||||
insert into t2(a) values(new.a);
|
||||
insert into t3(a) values(new.a);
|
||||
end |
|
||||
delimiter ;|
|
||||
--echo # The following statement causes auto-incrementation
|
||||
--echo # of both t2 and t3. It is logged in statement format,
|
||||
--echo # so it should produce unsafe warning
|
||||
INSERT INTO t1 SET a = 1;
|
||||
|
||||
SET SESSION binlog_format = MIXED;
|
||||
--echo # Check if the statement is logged in row format.
|
||||
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
INSERT INTO t1 SET a = 2;
|
||||
eval SHOW BINLOG EVENTS FROM $pos1_master;
|
||||
|
||||
# clean up
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
|
||||
--echo "End of tests"
|
||||
|
Reference in New Issue
Block a user