mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 21:42:35 +01:00
2f78abd21b
Problem: Some system functions that could return different values on master and slave were not marked unsafe. In particular: GET_LOCK IS_FREE_LOCK IS_USED_LOCK MASTER_POS_WAIT RELEASE_LOCK SLEEP SYSDATE VERSION Fix: Mark these functions unsafe. mysql-test/extra/rpl_tests/rpl_stm_000001.test: - The test does not work in mixed mode any more, since it tries to simulate an error in the sql thread in a query that uses get_lock. Since get_lock now causes the query to be logged in row format, the error didn't happen. Hence, we now force statement mode. - Warnings must be disabled when the unsafe query is issued. - Replaced some save_master_pos+connection slave+sync_with_master by sync_slave_with_master. mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result: updated result file mysql-test/suite/binlog/r/binlog_stm_row.result: updated result file mysql-test/suite/binlog/r/binlog_unsafe.result: updated result file mysql-test/suite/binlog/t/binlog_killed.test: binlog_killed only works in statement format now, since it switches to row mode in mixed mode. mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test: suppress warnings for unsafe statements mysql-test/suite/binlog/t/binlog_stm_row.test: - Suppress warnings in test that causes warnings. - The test sets binlog format explicitly, so no need to execute it twice. mysql-test/suite/binlog/t/binlog_unsafe.test: Added test for all unsafe system functions. This test also includes system functions that were unsafe prior to BUG#47995. mysql-test/suite/rpl/r/rpl_err_ignoredtable.result: updated result file mysql-test/suite/rpl/r/rpl_get_lock.result: updated result file mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result: new result file mysql-test/suite/rpl/r/rpl_stm_000001.result: updated result file mysql-test/suite/rpl/r/rpl_trigger.result: updated result file mysql-test/suite/rpl/t/rpl_err_ignoredtable.test: - suppress warnings for unsafe statement - replaced save_master_pos+connection slave+sync_with_master with sync_slave_with_master mysql-test/suite/rpl/t/rpl_get_lock.test: update test case that causes new warnings mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test: Added new test case for nondeterministic functions. mysql-test/suite/rpl/t/rpl_trigger.test: update test case that causes new warnings sql/item_create.cc: Marked some system functions unsafe. sql/item_strfunc.cc: Clarified comment related to this bug. sql/sql_yacc.yy: Marked sysdate unsafe.
114 lines
3.1 KiB
Text
114 lines
3.1 KiB
Text
--source include/have_log_bin.inc
|
|
# Test sets its own binlog_format, so we restrict it to run only once
|
|
--source include/have_binlog_format_row.inc
|
|
|
|
CALL mtr.add_suppression("Statement may not be safe to log in statement format.");
|
|
|
|
# Get rid of previous tests binlog
|
|
--disable_query_log
|
|
reset master;
|
|
--enable_query_log
|
|
|
|
#
|
|
# Bug#34306: Can't make copy of log tables when server binary log is enabled
|
|
#
|
|
# This is an additional test for Bug#34306 in order to ensure that INSERT INTO
|
|
# .. SELECT FROM is properly replicated under SBR and RBR and that the proper
|
|
# read lock type are acquired.
|
|
#
|
|
|
|
--disable_warnings
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TABLE IF EXISTS t2;
|
|
--enable_warnings
|
|
|
|
set @saved_global_binlog_format = @@global.binlog_format;
|
|
set @saved_local_binlog_format = @@session.binlog_format;
|
|
SET GLOBAL BINLOG_FORMAT = STATEMENT;
|
|
SET SESSION BINLOG_FORMAT = STATEMENT;
|
|
|
|
CREATE TABLE t1 (a INT);
|
|
CREATE TABLE t2 LIKE t1;
|
|
select @@SESSION.BINLOG_FORMAT;
|
|
INSERT INTO t1 VALUES(1);
|
|
INSERT INTO t2 VALUES(2);
|
|
|
|
--connect(con1,localhost,root,,)
|
|
--connect(con2,localhost,root,,)
|
|
|
|
--echo #
|
|
--echo # Ensure that INSERT INTO .. SELECT FROM under SBR takes a read
|
|
--echo # lock that will prevent the source table from being modified.
|
|
--echo #
|
|
|
|
--connection con1
|
|
--echo # con1
|
|
SELECT GET_LOCK('Bug#34306', 120);
|
|
--connection con2
|
|
--echo # con2
|
|
PREPARE stmt FROM "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)";
|
|
--send EXECUTE stmt;
|
|
--connection default
|
|
--echo # default
|
|
let $wait_condition=
|
|
SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
|
|
state = "User lock" AND
|
|
info = "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)";
|
|
--source include/wait_condition.inc
|
|
--send INSERT INTO t2 VALUES (3);
|
|
--connection con1
|
|
--echo # con1
|
|
let $wait_condition=
|
|
SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
|
|
state = "Locked" and info = "INSERT INTO t2 VALUES (3)";
|
|
--source include/wait_condition.inc
|
|
SELECT RELEASE_LOCK('Bug#34306');
|
|
--connection con2
|
|
--echo # con2
|
|
--reap
|
|
SELECT RELEASE_LOCK('Bug#34306');
|
|
--connection default
|
|
--echo # default
|
|
--reap
|
|
|
|
--echo #
|
|
--echo # Ensure that INSERT INTO .. SELECT FROM prepared under SBR does
|
|
--echo # not prevent the source table from being modified if under RBR.
|
|
--echo #
|
|
|
|
--connection con2
|
|
--echo # con2
|
|
SET SESSION BINLOG_FORMAT = ROW;
|
|
--connection con1
|
|
--echo # con1
|
|
SELECT GET_LOCK('Bug#34306', 120);
|
|
--connection con2
|
|
--echo # con2
|
|
--send EXECUTE stmt;
|
|
--connection default
|
|
--echo # default
|
|
let $wait_condition=
|
|
SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
|
|
state = "User lock" AND
|
|
info = "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)";
|
|
--source include/wait_condition.inc
|
|
--connection con1
|
|
--echo # con1
|
|
INSERT INTO t2 VALUES (4);
|
|
SELECT RELEASE_LOCK('Bug#34306');
|
|
--connection con2
|
|
--echo # con2
|
|
--reap
|
|
|
|
--disconnect con1
|
|
--disconnect con2
|
|
--connection default
|
|
--echo # default
|
|
|
|
--echo # Show binlog events
|
|
source include/show_binlog_events.inc;
|
|
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
SET GLOBAL BINLOG_FORMAT = @saved_global_binlog_format;
|
|
SET SESSION BINLOG_FORMAT = @saved_local_binlog_format;
|