mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix for BUG#25843: changing default database between PREPARE and EXECUTE
of statement breaks binlog. There were two problems discovered by this bug: 1. Default (current) database is not fixed at the creation time. That leads to wrong output of DATABASE() function. 2. Database attributes (@@collation_database) are not fixed at the creation time. That leads to wrong resultset. Binlog breakage and Query Cache wrong output happened because of the first problem. The fix is to remember the current database at the PREPARE-time and set it each time at EXECUTE.
This commit is contained in:
@@ -26,5 +26,44 @@ from-master-2-'',
|
||||
from-var-from-master-3
|
||||
drop table t1;
|
||||
stop slave;
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# BUG#25843: Changing default database between PREPARE and EXECUTE of
|
||||
# statement breaks binlog.
|
||||
#
|
||||
########################################################################
|
||||
|
||||
#
|
||||
# Check that binlog is filled properly.
|
||||
#
|
||||
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE TABLE t1(c INT);
|
||||
|
||||
RESET MASTER;
|
||||
RESET SLAVE;
|
||||
|
||||
PREPARE stmt_d_1 FROM 'INSERT INTO t1 VALUES(1)';
|
||||
|
||||
EXECUTE stmt_d_1;
|
||||
|
||||
use mysqltest1;
|
||||
|
||||
EXECUTE stmt_d_1;
|
||||
|
||||
FLUSH LOGS;
|
||||
|
||||
SHOW BINLOG EVENTS FROM 106;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
slave-bin.000001 106 Query 2 193 use `test`; INSERT INTO t1 VALUES(1)
|
||||
slave-bin.000001 193 Query 2 280 use `test`; INSERT INTO t1 VALUES(1)
|
||||
slave-bin.000001 280 Rotate 2 323 slave-bin.000002;pos=4
|
||||
|
||||
DROP DATABASE mysqltest1;
|
||||
|
||||
use test;
|
||||
|
||||
########################################################################
|
||||
reset master;
|
||||
reset slave;
|
||||
|
@@ -46,6 +46,74 @@ stop slave;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
# Bug #25843 Changing default database between PREPARE and EXECUTE of statement
|
||||
# breaks binlog.
|
||||
#
|
||||
# There were actually two problems discovered by this bug:
|
||||
#
|
||||
# 1. Default (current) database is not fixed at the creation time.
|
||||
# That leads to wrong output of DATABASE() function.
|
||||
#
|
||||
# 2. Database attributes (@@collation_database) are not fixed at the creation
|
||||
# time. That leads to wrong resultset.
|
||||
#
|
||||
# Binlog breakage and Query Cache wrong output happened because of the first
|
||||
# problem.
|
||||
#
|
||||
|
||||
--echo
|
||||
--echo ########################################################################
|
||||
--echo #
|
||||
--echo # BUG#25843: Changing default database between PREPARE and EXECUTE of
|
||||
--echo # statement breaks binlog.
|
||||
--echo #
|
||||
--echo ########################################################################
|
||||
|
||||
###############################################################################
|
||||
|
||||
--echo
|
||||
--echo #
|
||||
--echo # Check that binlog is filled properly.
|
||||
--echo #
|
||||
|
||||
--echo
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE TABLE t1(c INT);
|
||||
|
||||
--echo
|
||||
RESET MASTER;
|
||||
RESET SLAVE;
|
||||
|
||||
--echo
|
||||
PREPARE stmt_d_1 FROM 'INSERT INTO t1 VALUES(1)';
|
||||
|
||||
--echo
|
||||
EXECUTE stmt_d_1;
|
||||
|
||||
--echo
|
||||
use mysqltest1;
|
||||
|
||||
--echo
|
||||
EXECUTE stmt_d_1;
|
||||
|
||||
--echo
|
||||
FLUSH LOGS;
|
||||
|
||||
--echo
|
||||
SHOW BINLOG EVENTS FROM 106;
|
||||
|
||||
--echo
|
||||
DROP DATABASE mysqltest1;
|
||||
|
||||
--echo
|
||||
use test;
|
||||
|
||||
--echo
|
||||
--echo ########################################################################
|
||||
|
||||
###############################################################################
|
||||
|
||||
reset master;
|
||||
reset slave;
|
||||
disconnect master;
|
||||
|
Reference in New Issue
Block a user