Commit 75908fc4 authored by Sergei Golubchik's avatar Sergei Golubchik

BUG#13627921 - MISSING FLAGS IN SQL_COMMAND_FLAGS MAY LEAD TO REPLICATION PROBLEMS

merge from MySQL-5.6, revision:

revno: 3677.2.1
committer: Alfranio Correia <alfranio.correia@oracle.com>
timestamp: Tue 2012-02-28 16:26:37 +0000
message:
  BUG#13627921 - MISSING FLAGS IN SQL_COMMAND_FLAGS MAY LEAD TO REPLICATION PROBLEMS

  Flags in sql_command_flags[command] are not correctly set for the following
  commands:

    . SQLCOM_SET_OPTION is missing CF_CAN_GENERATE_ROW_EVENTS;
    . SQLCOM_BINLOG_BASE64_EVENT is missing CF_CAN_GENERATE_ROW_EVENTS;
    . SQLCOM_REVOKE_ALL is missing CF_CHANGES_DATA;
    . SQLCOM_CREATE_FUNCTION is missing CF_AUTO_COMMIT_TRANS;

  This may lead to a wrong sequence of events in the binary log. To fix
  the problem, we correctly set the flags in sql_command_flags[command].
parent 5e1fad85
......@@ -32,7 +32,7 @@ INSERT INTO tt_2(ddl_case) VALUES(0);
--echo # CHECK IMPLICT COMMIT
--echo #########################################################################
SET AUTOCOMMIT= 0;
let $ddl_cases= 41;
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-
......@@ -84,6 +84,15 @@ while ($ddl_cases >= 1)
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;
......@@ -611,6 +620,7 @@ while ($ddl_cases >= 1)
let $commit_event_row_number= 6;
}
}
--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
--eval $cmd
--disable_query_log
#
......@@ -634,6 +644,7 @@ while ($ddl_cases >= 1)
exit;
}
}
--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-
......
......@@ -113,6 +113,19 @@ if ($commands == 'configure')
RETURN "fc_i_nt_5_suc";
END|
CREATE FUNCTION fc_i_nt_3_tt_3_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
BEGIN
DECLARE in_stmt_id INTEGER;
SELECT max(stmt_id) INTO in_stmt_id FROM nt_3 WHERE trans_id= p_trans_id;
SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
INSERT INTO nt_3(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
SELECT max(stmt_id) INTO in_stmt_id FROM tt_3 WHERE trans_id= p_trans_id;
SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
INSERT INTO tt_3(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
RETURN "fc_i_nt_3_tt_3_suc";
END|
CREATE TRIGGER tr_i_tt_3_to_nt_3 AFTER INSERT ON tt_3 FOR EACH ROW
BEGIN
DECLARE in_stmt_id INTEGER;
......@@ -186,6 +199,7 @@ if ($commands == 'clean')
DROP PROCEDURE pc_i_nt_5_suc;
DROP FUNCTION fc_i_tt_5_suc;
DROP FUNCTION fc_i_nt_5_suc;
DROP FUNCTION fc_i_nt_3_tt_3_suc;
--disable_query_log
if ($database_name != 'test')
......@@ -439,6 +453,21 @@ while ($commands != '')
eval INSERT INTO tt_5(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, ''), ($old_trans_id, $old_stmt_id, fc_i_nt_5_suc ($trans_id, $stmt_id));
inc $stmt_id;
}
if ($command == 'set-T')
{
--eval SET @var= fc_i_tt_5_suc($trans_id, $stmt_id)
inc $stmt_id;
}
if ($command == 'set-N')
{
--eval SET @var= fc_i_nt_5_suc($trans_id, $stmt_id)
inc $stmt_id;
}
if ($command == 'set-NT')
{
--eval SET @var= fc_i_nt_3_tt_3_suc($trans_id, $stmt_id)
inc $stmt_id;
}
if ($command == 'CS-T->T')
{
--eval CREATE TABLE tt_xx_$tb_id (PRIMARY KEY(trans_id, stmt_id)) engine=$engine_type SELECT * FROM tt_1;
......
......@@ -1762,6 +1762,43 @@ connection master;
--source extra/rpl_tests/rpl_mixing_engines.inc
--echo ###################################################################################
--echo # 5 - SET WITH ROW CHANGES
--echo ###################################################################################
--let $commands= set-T
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= set-N
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= set-NT
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-N set-T C
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-T set-N C
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-N set-T R
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-T set-N R
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-NT set-T C
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-T set-NT C
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-NT set-T R
--source extra/rpl_tests/rpl_mixing_engines.inc
--let $commands= B set-T set-NT R
--source extra/rpl_tests/rpl_mixing_engines.inc
--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
......
......@@ -88,6 +88,7 @@ let $script=
s{SQL_LOAD-[a-z,0-9,-]*.[a-z]*}{SQL_LOAD-<SERVER UUID>-<MASTER server-id>-<file-id>.<extension>};
s{rand_seed1=[0-9]*,rand_seed2=[0-9]*}{rand_seed1=<seed 1>,rand_seed2=<seed 2>};
s{((?:master|slave|slave-relay)-bin\.[0-9]{6};pos=)[0-9]+DOLLAR}{DOLLAR1POS};
s{SONAME ".*"}{SONAME "LIB"};
s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g;
||
--let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'};
......
......@@ -13,6 +13,34 @@ INSERT INTO tt_2(ddl_case) VALUES(0);
# CHECK IMPLICT COMMIT
#########################################################################
SET AUTOCOMMIT= 0;
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (43);
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (43)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB"
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (42);
DROP FUNCTION myfunc_int;
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (42)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (41);
LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES;
......
......@@ -13,6 +13,36 @@ INSERT INTO tt_2(ddl_case) VALUES(0);
# CHECK IMPLICT COMMIT
#########################################################################
SET AUTOCOMMIT= 0;
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (43);
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Table_map # # table_id: # (test.tt_1)
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB"
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (42);
DROP FUNCTION myfunc_int;
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Table_map # # table_id: # (test.tt_1)
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (41);
LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES;
......
......@@ -13,6 +13,34 @@ INSERT INTO tt_2(ddl_case) VALUES(0);
# CHECK IMPLICT COMMIT
#########################################################################
SET AUTOCOMMIT= 0;
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (43);
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (43)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB"
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (42);
DROP FUNCTION myfunc_int;
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (42)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
INSERT INTO tt_1(ddl_case) VALUES (41);
LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES;
......
################################################################################
# Check file extra/rpl_tests/rpl_implicit_commit_binlog.test
################################################################################
--source include/have_udf.inc
--source include/have_binlog_format_mixed.inc
--source include/master-slave.inc
--source include/have_innodb.inc
......
################################################################################
# Check file extra/rpl_tests/rpl_implicit_commit_binlog.test
################################################################################
--source include/have_udf.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--source include/have_innodb.inc
......
################################################################################
# Check file extra/rpl_tests/rpl_implicit_commit_binlog.test
################################################################################
--source include/have_udf.inc
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
--source include/have_innodb.inc
......
......@@ -3217,7 +3217,10 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
thd->in_multi_stmt_transaction_mode()) || trx_cache;
break;
case SQLCOM_SET_OPTION:
use_cache= trx_cache= (lex->autocommit ? FALSE : TRUE);
if (lex->autocommit)
use_cache= trx_cache= FALSE;
else
use_cache= TRUE;
break;
case SQLCOM_RELEASE_SAVEPOINT:
case SQLCOM_ROLLBACK_TO_SAVEPOINT:
......
......@@ -356,6 +356,7 @@ void init_update_queries(void)
*/
sql_command_flags[SQLCOM_SET_OPTION]= CF_REEXECUTION_FRAGILE |
CF_AUTO_COMMIT_TRANS |
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE; // (1)
// (1) so that subquery is traced when doing "DO @var := (subquery)"
sql_command_flags[SQLCOM_DO]= CF_REEXECUTION_FRAGILE |
......@@ -420,13 +421,7 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_REVOKE]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_REVOKE_ROLE]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_OPTIMIZE]= CF_CHANGES_DATA;
/*
@todo SQLCOM_CREATE_FUNCTION should have CF_AUTO_COMMIT_TRANS
set. this currently is binlogged *before* the transaction if
executed inside a transaction because it does not have an implicit
pre-commit and is written to the statement cache. /Sven
*/
sql_command_flags[SQLCOM_CREATE_FUNCTION]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_CREATE_FUNCTION]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_CREATE_PROCEDURE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_CREATE_SPFUNCTION]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_DROP_PROCEDURE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
......@@ -479,8 +474,8 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_RENAME_USER]|= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_CREATE_ROLE]|= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_DROP_ROLE]|= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_REVOKE_ALL]= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_REVOKE]|= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_REVOKE_ALL]= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_REVOKE_ROLE]|= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_GRANT]|= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_GRANT_ROLE]|= CF_AUTO_COMMIT_TRANS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment