mirror of
https://github.com/MariaDB/server.git
synced 2025-06-06 05:21:19 +03:00
MWL#234: After-review fixes, including better names for the new system variables.
This commit is contained in:
parent
c4d69f1775
commit
b1a13cb15a
@ -671,7 +671,7 @@ print_use_stmt(PRINT_EVENT_INFO* pinfo, const Query_log_event *ev)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Print "SET do_not_replicate=..." statement when needed.
|
Print "SET skip_replication=..." statement when needed.
|
||||||
|
|
||||||
Not all servers support this (only MariaDB from some version on). So we
|
Not all servers support this (only MariaDB from some version on). So we
|
||||||
mark the SET to only execute from the version of MariaDB that supports it,
|
mark the SET to only execute from the version of MariaDB that supports it,
|
||||||
@ -679,20 +679,20 @@ print_use_stmt(PRINT_EVENT_INFO* pinfo, const Query_log_event *ev)
|
|||||||
get spurious errors on MySQL@Oracle servers of higher version that do not
|
get spurious errors on MySQL@Oracle servers of higher version that do not
|
||||||
support the flag.
|
support the flag.
|
||||||
|
|
||||||
So we start out assuming @@do_not_replicate is 0, and only output a SET
|
So we start out assuming @@skip_replication is 0, and only output a SET
|
||||||
statement when it changes.
|
statement when it changes.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
print_do_not_replicate_statement(PRINT_EVENT_INFO *pinfo, const Log_event *ev)
|
print_skip_replication_statement(PRINT_EVENT_INFO *pinfo, const Log_event *ev)
|
||||||
{
|
{
|
||||||
int cur_val;
|
int cur_val;
|
||||||
|
|
||||||
cur_val= (ev->flags & LOG_EVENT_DO_NOT_REPLICATE_F) != 0;
|
cur_val= (ev->flags & LOG_EVENT_SKIP_REPLICATION_F) != 0;
|
||||||
if (cur_val == pinfo->do_not_replicate)
|
if (cur_val == pinfo->skip_replication)
|
||||||
return; /* Not changed. */
|
return; /* Not changed. */
|
||||||
fprintf(result_file, "/*!50400 SET do_not_replicate=%d*/%s\n",
|
fprintf(result_file, "/*!50400 SET skip_replication=%d*/%s\n",
|
||||||
cur_val, pinfo->delimiter);
|
cur_val, pinfo->delimiter);
|
||||||
pinfo->do_not_replicate= cur_val;
|
pinfo->skip_replication= cur_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -828,7 +828,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print_do_not_replicate_statement(print_event_info, ev);
|
print_skip_replication_statement(print_event_info, ev);
|
||||||
ev->print(result_file, print_event_info);
|
ev->print(result_file, print_event_info);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -861,7 +861,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print_do_not_replicate_statement(print_event_info, ev);
|
print_skip_replication_statement(print_event_info, ev);
|
||||||
ce->print(result_file, print_event_info, TRUE);
|
ce->print(result_file, print_event_info, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,10 +958,10 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||||||
if (!shall_skip_database(exlq->db))
|
if (!shall_skip_database(exlq->db))
|
||||||
{
|
{
|
||||||
print_use_stmt(print_event_info, exlq);
|
print_use_stmt(print_event_info, exlq);
|
||||||
print_do_not_replicate_statement(print_event_info, ev);
|
|
||||||
if (fname)
|
if (fname)
|
||||||
{
|
{
|
||||||
convert_path_to_forward_slashes(fname);
|
convert_path_to_forward_slashes(fname);
|
||||||
|
print_skip_replication_statement(print_event_info, ev);
|
||||||
exlq->print(result_file, print_event_info, fname);
|
exlq->print(result_file, print_event_info, fname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1062,13 +1062,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||||||
}
|
}
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
}
|
}
|
||||||
case INTVAR_EVENT:
|
|
||||||
case RAND_EVENT:
|
|
||||||
case USER_VAR_EVENT:
|
|
||||||
case XID_EVENT:
|
|
||||||
print_do_not_replicate_statement(print_event_info, ev);
|
|
||||||
/* Fall through ... */
|
|
||||||
default:
|
default:
|
||||||
|
print_skip_replication_statement(print_event_info, ev);
|
||||||
ev->print(result_file, print_event_info);
|
ev->print(result_file, print_event_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,20 @@ include/master-slave.inc
|
|||||||
CREATE USER 'nonsuperuser'@'127.0.0.1';
|
CREATE USER 'nonsuperuser'@'127.0.0.1';
|
||||||
GRANT ALTER,CREATE,DELETE,DROP,EVENT,INSERT,PROCESS,REPLICATION SLAVE,
|
GRANT ALTER,CREATE,DELETE,DROP,EVENT,INSERT,PROCESS,REPLICATION SLAVE,
|
||||||
SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';
|
SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
ERROR 42000: Access denied; you need the SUPER privilege for this operation
|
ERROR 42000: Access denied; you need the SUPER privilege for this operation
|
||||||
DROP USER'nonsuperuser'@'127.0.0.1';
|
DROP USER'nonsuperuser'@'127.0.0.1';
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
|
ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
||||||
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=innodb;
|
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=innodb;
|
||||||
INSERT INTO t1(a) VALUES (1);
|
INSERT INTO t1(a) VALUES (1);
|
||||||
INSERT INTO t2(a) VALUES (1);
|
INSERT INTO t2(a) VALUES (1);
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
||||||
INSERT INTO t1(a) VALUES (2);
|
INSERT INTO t1(a) VALUES (2);
|
||||||
INSERT INTO t2(a) VALUES (2);
|
INSERT INTO t2(a) VALUES (2);
|
||||||
@ -34,7 +34,7 @@ a b
|
|||||||
DROP TABLE t3;
|
DROP TABLE t3;
|
||||||
FLUSH NO_WRITE_TO_BINLOG LOGS;
|
FLUSH NO_WRITE_TO_BINLOG LOGS;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=0;
|
SET GLOBAL replicate_events_marked_for_skip=1;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
||||||
INSERT INTO t3(a) VALUES(2);
|
INSERT INTO t3(a) VALUES(2);
|
||||||
@ -44,11 +44,11 @@ a b
|
|||||||
DROP TABLE t3;
|
DROP TABLE t3;
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
RESET MASTER;
|
RESET MASTER;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (1,0);
|
INSERT INTO t1 VALUES (1,0);
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
INSERT INTO t1 VALUES (2,0);
|
INSERT INTO t1 VALUES (2,0);
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (3,0);
|
INSERT INTO t1 VALUES (3,0);
|
||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
a b
|
a b
|
||||||
@ -56,7 +56,7 @@ a b
|
|||||||
2 0
|
2 0
|
||||||
3 0
|
3 0
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
a b
|
a b
|
||||||
@ -71,15 +71,15 @@ a b
|
|||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL sql_slave_skip_counter=2;
|
SET GLOBAL sql_slave_skip_counter=2;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
SET @old_binlog_format= @@binlog_format;
|
SET @old_binlog_format= @@binlog_format;
|
||||||
SET binlog_format= statement;
|
SET binlog_format= statement;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (1,5);
|
INSERT INTO t1 VALUES (1,5);
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
INSERT INTO t1 VALUES (2,5);
|
INSERT INTO t1 VALUES (2,5);
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (3,5);
|
INSERT INTO t1 VALUES (3,5);
|
||||||
INSERT INTO t1 VALUES (4,5);
|
INSERT INTO t1 VALUES (4,5);
|
||||||
SET binlog_format= @old_binlog_format;
|
SET binlog_format= @old_binlog_format;
|
||||||
@ -100,29 +100,29 @@ a b
|
|||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
a b
|
a b
|
||||||
2 8
|
2 8
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
COMMIT;
|
COMMIT;
|
||||||
SET autocommit=0;
|
SET autocommit=0;
|
||||||
INSERT INTO t2(a) VALUES(100);
|
INSERT INTO t2(a) VALUES(100);
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
SET autocommit=1;
|
SET autocommit=1;
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
CREATE FUNCTION foo (x INT) RETURNS INT BEGIN SET SESSION do_not_replicate=x; RETURN x; END|
|
CREATE FUNCTION foo (x INT) RETURNS INT BEGIN SET SESSION skip_replication=x; RETURN x; END|
|
||||||
CREATE PROCEDURE bar(x INT) BEGIN SET SESSION do_not_replicate=x; END|
|
CREATE PROCEDURE bar(x INT) BEGIN SET SESSION skip_replication=x; END|
|
||||||
CREATE FUNCTION baz (x INT) RETURNS INT BEGIN CALL bar(x); RETURN x; END|
|
CREATE FUNCTION baz (x INT) RETURNS INT BEGIN CALL bar(x); RETURN x; END|
|
||||||
SELECT foo(0);
|
SELECT foo(0);
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
@ -140,23 +140,23 @@ INSERT INTO t1 VALUES (101, foo(1));
|
|||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
INSERT INTO t1 VALUES (101, baz(0));
|
INSERT INTO t1 VALUES (101, baz(0));
|
||||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
SELECT @@do_not_replicate;
|
SELECT @@skip_replication;
|
||||||
@@do_not_replicate
|
@@skip_replication
|
||||||
1
|
1
|
||||||
CALL bar(0);
|
CALL bar(0);
|
||||||
SELECT @@do_not_replicate;
|
SELECT @@skip_replication;
|
||||||
@@do_not_replicate
|
@@skip_replication
|
||||||
0
|
0
|
||||||
CALL bar(1);
|
CALL bar(1);
|
||||||
SELECT @@do_not_replicate;
|
SELECT @@skip_replication;
|
||||||
@@do_not_replicate
|
@@skip_replication
|
||||||
1
|
1
|
||||||
DROP FUNCTION foo;
|
DROP FUNCTION foo;
|
||||||
DROP PROCEDURE bar;
|
DROP PROCEDURE bar;
|
||||||
DROP FUNCTION baz;
|
DROP FUNCTION baz;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=0;
|
SET GLOBAL replicate_events_marked_for_skip=1;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
include/rpl_end.inc
|
include/rpl_end.inc
|
@ -2,33 +2,33 @@
|
|||||||
--source include/have_innodb.inc
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
connection slave;
|
connection slave;
|
||||||
# Test that SUPER is required to change @@replicate_ignore_do_not_replicate.
|
# Test that SUPER is required to change @@replicate_events_marked_for_skip.
|
||||||
CREATE USER 'nonsuperuser'@'127.0.0.1';
|
CREATE USER 'nonsuperuser'@'127.0.0.1';
|
||||||
GRANT ALTER,CREATE,DELETE,DROP,EVENT,INSERT,PROCESS,REPLICATION SLAVE,
|
GRANT ALTER,CREATE,DELETE,DROP,EVENT,INSERT,PROCESS,REPLICATION SLAVE,
|
||||||
SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';
|
SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';
|
||||||
connect(nonpriv, 127.0.0.1, nonsuperuser,, test, $SLAVE_MYPORT,);
|
connect(nonpriv, 127.0.0.1, nonsuperuser,, test, $SLAVE_MYPORT,);
|
||||||
connection nonpriv;
|
connection nonpriv;
|
||||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
disconnect nonpriv;
|
disconnect nonpriv;
|
||||||
connection slave;
|
connection slave;
|
||||||
DROP USER'nonsuperuser'@'127.0.0.1';
|
DROP USER'nonsuperuser'@'127.0.0.1';
|
||||||
|
|
||||||
--error ER_SLAVE_MUST_STOP
|
--error ER_SLAVE_MUST_STOP
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
|
|
||||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
||||||
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=innodb;
|
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=innodb;
|
||||||
INSERT INTO t1(a) VALUES (1);
|
INSERT INTO t1(a) VALUES (1);
|
||||||
INSERT INTO t2(a) VALUES (1);
|
INSERT INTO t2(a) VALUES (1);
|
||||||
|
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
|
|
||||||
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=myisam;
|
||||||
INSERT INTO t1(a) VALUES (2);
|
INSERT INTO t1(a) VALUES (2);
|
||||||
@ -52,7 +52,7 @@ FLUSH NO_WRITE_TO_BINLOG LOGS;
|
|||||||
sync_slave_with_master;
|
sync_slave_with_master;
|
||||||
connection slave;
|
connection slave;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=0;
|
SET GLOBAL replicate_events_marked_for_skip=1;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
@ -65,7 +65,7 @@ connection master;
|
|||||||
DROP TABLE t3;
|
DROP TABLE t3;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test that the slave will preserve the @@do_not_replicate flag in its
|
# Test that the slave will preserve the @@skip_replication flag in its
|
||||||
# own binlog.
|
# own binlog.
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -75,36 +75,36 @@ connection slave;
|
|||||||
RESET MASTER;
|
RESET MASTER;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (1,0);
|
INSERT INTO t1 VALUES (1,0);
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
INSERT INTO t1 VALUES (2,0);
|
INSERT INTO t1 VALUES (2,0);
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (3,0);
|
INSERT INTO t1 VALUES (3,0);
|
||||||
|
|
||||||
sync_slave_with_master;
|
sync_slave_with_master;
|
||||||
connection slave;
|
connection slave;
|
||||||
# Since slave has @@replicate_ignore_do_not_replicate=0, it should have
|
# Since slave has @@replicate_events_marked_for_skip=1, it should have
|
||||||
# applied all events.
|
# applied all events.
|
||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
|
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
let $SLAVE_DATADIR= `select @@datadir`;
|
let $SLAVE_DATADIR= `select @@datadir`;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
|
|
||||||
# Now apply the slave binlog to the master, to check that both the slave
|
# Now apply the slave binlog to the master, to check that both the slave
|
||||||
# and mysqlbinlog will preserve the @@do_not_replicate flag.
|
# and mysqlbinlog will preserve the @@skip_replication flag.
|
||||||
--exec $MYSQL_BINLOG $SLAVE_DATADIR/slave-bin.000001 > $MYSQLTEST_VARDIR/tmp/rpl_do_not_replicate.binlog
|
--exec $MYSQL_BINLOG $SLAVE_DATADIR/slave-bin.000001 > $MYSQLTEST_VARDIR/tmp/rpl_skip_replication.binlog
|
||||||
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/rpl_do_not_replicate.binlog
|
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/rpl_skip_replication.binlog
|
||||||
|
|
||||||
# The master should have all three events.
|
# The master should have all three events.
|
||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
|
|
||||||
# The slave should be missing event 2, which is marked with the
|
# The slave should be missing event 2, which is marked with the
|
||||||
# @@do_not_replicate flag.
|
# @@skip_replication flag.
|
||||||
|
|
||||||
connection slave;
|
connection slave;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
@ -116,7 +116,7 @@ connection slave;
|
|||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test that @@sql_slave_skip_counter does not count skipped @@do_not_replicate
|
# Test that @@sql_slave_skip_counter does not count skipped @@skip_replication
|
||||||
# events.
|
# events.
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -127,18 +127,18 @@ sync_slave_with_master;
|
|||||||
connection slave;
|
connection slave;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL sql_slave_skip_counter=2;
|
SET GLOBAL sql_slave_skip_counter=2;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=1;
|
SET GLOBAL replicate_events_marked_for_skip=0;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
# Need to fix @@binlog_format to get consistent event count.
|
# Need to fix @@binlog_format to get consistent event count.
|
||||||
SET @old_binlog_format= @@binlog_format;
|
SET @old_binlog_format= @@binlog_format;
|
||||||
SET binlog_format= statement;
|
SET binlog_format= statement;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (1,5);
|
INSERT INTO t1 VALUES (1,5);
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
INSERT INTO t1 VALUES (2,5);
|
INSERT INTO t1 VALUES (2,5);
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
INSERT INTO t1 VALUES (3,5);
|
INSERT INTO t1 VALUES (3,5);
|
||||||
INSERT INTO t1 VALUES (4,5);
|
INSERT INTO t1 VALUES (4,5);
|
||||||
SET binlog_format= @old_binlog_format;
|
SET binlog_format= @old_binlog_format;
|
||||||
@ -148,12 +148,12 @@ connection slave;
|
|||||||
|
|
||||||
# The slave should have skipped the first three inserts (number 1 and 3 due
|
# The slave should have skipped the first three inserts (number 1 and 3 due
|
||||||
# to @@sql_slave_skip_counter=2, number 2 due to
|
# to @@sql_slave_skip_counter=2, number 2 due to
|
||||||
# @@replicate_ignore_do_not_replicate=1). So only number 4 should be left.
|
# @@replicate_events_marked_for_skip=0). So only number 4 should be left.
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check that BINLOG statement preserves the @@do_not_replicate flag.
|
# Check that BINLOG statement preserves the @@skip_replication flag.
|
||||||
#
|
#
|
||||||
connection master;
|
connection master;
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
@ -161,10 +161,10 @@ TRUNCATE t1;
|
|||||||
# Format description log event.
|
# Format description log event.
|
||||||
BINLOG '66I6Tg8BAAAAZgAAAGoAAAABAAQANS40LjAtTWFyaWFEQi12YWxncmluZC1tYXgtZGVidWctbG9n
|
BINLOG '66I6Tg8BAAAAZgAAAGoAAAABAAQANS40LjAtTWFyaWFEQi12YWxncmluZC1tYXgtZGVidWctbG9n
|
||||||
AAAAAAAAAAAAAAAAAADrojpOEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC';
|
AAAAAAAAAAAAAAAAAADrojpOEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC';
|
||||||
# INSERT INTO t1 VALUES (1,8) # with @@do_not_replicate=1
|
# INSERT INTO t1 VALUES (1,8) # with @@skip_replication=1
|
||||||
BINLOG 'HaM6ThMBAAAAKgAAANgAAAAAgA8AAAAAAAEABHRlc3QAAnQxAAIDAwAC
|
BINLOG 'HaM6ThMBAAAAKgAAANgAAAAAgA8AAAAAAAEABHRlc3QAAnQxAAIDAwAC
|
||||||
HaM6ThcBAAAAJgAAAP4AAAAAgA8AAAAAAAEAAv/8AQAAAAgAAAA=';
|
HaM6ThcBAAAAJgAAAP4AAAAAgA8AAAAAAAEAAv/8AQAAAAgAAAA=';
|
||||||
# INSERT INTO t1 VALUES (2,8) # with @@do_not_replicate=0
|
# INSERT INTO t1 VALUES (2,8) # with @@skip_replication=0
|
||||||
BINLOG 'JqM6ThMBAAAAKgAAALEBAAAAAA8AAAAAAAEABHRlc3QAAnQxAAIDAwAC
|
BINLOG 'JqM6ThMBAAAAKgAAALEBAAAAAA8AAAAAAAEABHRlc3QAAnQxAAIDAwAC
|
||||||
JqM6ThcBAAAAJgAAANcBAAAAAA8AAAAAAAEAAv/8AgAAAAgAAAA=';
|
JqM6ThcBAAAAJgAAANcBAAAAAA8AAAAAAAEAAv/8AgAAAAgAAAA=';
|
||||||
|
|
||||||
@ -172,40 +172,40 @@ SELECT * FROM t1 ORDER BY a;
|
|||||||
sync_slave_with_master;
|
sync_slave_with_master;
|
||||||
connection slave;
|
connection slave;
|
||||||
# Slave should have only the second insert, the first should be ignored due to
|
# Slave should have only the second insert, the first should be ignored due to
|
||||||
# the @@do_not_replicate flag.
|
# the @@skip_replication flag.
|
||||||
SELECT * FROM t1 ORDER by a;
|
SELECT * FROM t1 ORDER by a;
|
||||||
|
|
||||||
|
|
||||||
# Test that it is not possible to d change @@do_not_replicate inside a
|
# Test that it is not possible to d change @@skip_replication inside a
|
||||||
# transaction or statement, thereby replicating only parts of statements
|
# transaction or statement, thereby replicating only parts of statements
|
||||||
# or transactions.
|
# or transactions.
|
||||||
connection master;
|
connection master;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
SET autocommit=0;
|
SET autocommit=0;
|
||||||
INSERT INTO t2(a) VALUES(100);
|
INSERT INTO t2(a) VALUES(100);
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
SET autocommit=1;
|
SET autocommit=1;
|
||||||
|
|
||||||
SET do_not_replicate=1;
|
SET skip_replication=1;
|
||||||
--delimiter |
|
--delimiter |
|
||||||
CREATE FUNCTION foo (x INT) RETURNS INT BEGIN SET SESSION do_not_replicate=x; RETURN x; END|
|
CREATE FUNCTION foo (x INT) RETURNS INT BEGIN SET SESSION skip_replication=x; RETURN x; END|
|
||||||
CREATE PROCEDURE bar(x INT) BEGIN SET SESSION do_not_replicate=x; END|
|
CREATE PROCEDURE bar(x INT) BEGIN SET SESSION skip_replication=x; END|
|
||||||
CREATE FUNCTION baz (x INT) RETURNS INT BEGIN CALL bar(x); RETURN x; END|
|
CREATE FUNCTION baz (x INT) RETURNS INT BEGIN CALL bar(x); RETURN x; END|
|
||||||
--delimiter ;
|
--delimiter ;
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
@ -224,22 +224,22 @@ UPDATE t2 SET b=baz(0);
|
|||||||
INSERT INTO t1 VALUES (101, foo(1));
|
INSERT INTO t1 VALUES (101, foo(1));
|
||||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||||
INSERT INTO t1 VALUES (101, baz(0));
|
INSERT INTO t1 VALUES (101, baz(0));
|
||||||
SELECT @@do_not_replicate;
|
SELECT @@skip_replication;
|
||||||
CALL bar(0);
|
CALL bar(0);
|
||||||
SELECT @@do_not_replicate;
|
SELECT @@skip_replication;
|
||||||
CALL bar(1);
|
CALL bar(1);
|
||||||
SELECT @@do_not_replicate;
|
SELECT @@skip_replication;
|
||||||
DROP FUNCTION foo;
|
DROP FUNCTION foo;
|
||||||
DROP PROCEDURE bar;
|
DROP PROCEDURE bar;
|
||||||
DROP FUNCTION baz;
|
DROP FUNCTION baz;
|
||||||
|
|
||||||
# Clean up.
|
# Clean up.
|
||||||
connection master;
|
connection master;
|
||||||
SET do_not_replicate=0;
|
SET skip_replication=0;
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
connection slave;
|
connection slave;
|
||||||
STOP SLAVE;
|
STOP SLAVE;
|
||||||
SET GLOBAL replicate_ignore_do_not_replicate=0;
|
SET GLOBAL replicate_events_marked_for_skip=1;
|
||||||
START SLAVE;
|
START SLAVE;
|
||||||
|
|
||||||
--source include/rpl_end.inc
|
--source include/rpl_end.inc
|
@ -671,7 +671,7 @@ Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
|
|||||||
when= thd->start_time;
|
when= thd->start_time;
|
||||||
cache_stmt= using_trans;
|
cache_stmt= using_trans;
|
||||||
flags= flags_arg |
|
flags= flags_arg |
|
||||||
(thd->options & OPTION_DO_NOT_REPLICATE ? LOG_EVENT_DO_NOT_REPLICATE_F : 0);
|
(thd->options & OPTION_SKIP_REPLICATION ? LOG_EVENT_SKIP_REPLICATION_F : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -828,8 +828,8 @@ Log_event::do_shall_skip(Relay_log_info *rli)
|
|||||||
rli->slave_skip_counter));
|
rli->slave_skip_counter));
|
||||||
if ((server_id == ::server_id && !rli->replicate_same_server_id) ||
|
if ((server_id == ::server_id && !rli->replicate_same_server_id) ||
|
||||||
(rli->slave_skip_counter == 1 && rli->is_in_group()) ||
|
(rli->slave_skip_counter == 1 && rli->is_in_group()) ||
|
||||||
(flags & LOG_EVENT_DO_NOT_REPLICATE_F
|
(flags & LOG_EVENT_SKIP_REPLICATION_F
|
||||||
&& opt_replicate_ignore_do_not_replicate))
|
&& !opt_replicate_events_marked_for_skip))
|
||||||
return EVENT_SKIP_IGNORE;
|
return EVENT_SKIP_IGNORE;
|
||||||
if (rli->slave_skip_counter > 0)
|
if (rli->slave_skip_counter > 0)
|
||||||
return EVENT_SKIP_COUNT;
|
return EVENT_SKIP_COUNT;
|
||||||
@ -3488,11 +3488,11 @@ Query_log_event::do_shall_skip(Relay_log_info *rli)
|
|||||||
DBUG_ASSERT(query && q_len > 0);
|
DBUG_ASSERT(query && q_len > 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
An event skipped due to @@do_not_replicate must not be counted towards the
|
An event skipped due to @@skip_replication must not be counted towards the
|
||||||
number of events to be skipped due to @@sql_slave_skip_counter.
|
number of events to be skipped due to @@sql_slave_skip_counter.
|
||||||
*/
|
*/
|
||||||
if (flags & LOG_EVENT_DO_NOT_REPLICATE_F &&
|
if (flags & LOG_EVENT_SKIP_REPLICATION_F &&
|
||||||
opt_replicate_ignore_do_not_replicate)
|
!opt_replicate_events_marked_for_skip)
|
||||||
DBUG_RETURN(Log_event::EVENT_SKIP_IGNORE);
|
DBUG_RETURN(Log_event::EVENT_SKIP_IGNORE);
|
||||||
|
|
||||||
if (rli->slave_skip_counter > 0)
|
if (rli->slave_skip_counter > 0)
|
||||||
@ -9792,7 +9792,7 @@ st_print_event_info::st_print_event_info()
|
|||||||
auto_increment_increment(0),auto_increment_offset(0), charset_inited(0),
|
auto_increment_increment(0),auto_increment_offset(0), charset_inited(0),
|
||||||
lc_time_names_number(~0),
|
lc_time_names_number(~0),
|
||||||
charset_database_number(ILLEGAL_CHARSET_INFO_NUMBER),
|
charset_database_number(ILLEGAL_CHARSET_INFO_NUMBER),
|
||||||
thread_id(0), thread_id_printed(false), do_not_replicate(0),
|
thread_id(0), thread_id_printed(false), skip_replication(0),
|
||||||
base64_output_mode(BASE64_OUTPUT_UNSPEC), printed_fd_event(FALSE)
|
base64_output_mode(BASE64_OUTPUT_UNSPEC), printed_fd_event(FALSE)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -491,16 +491,16 @@ struct sql_ex_info
|
|||||||
#define LOG_EVENT_RELAY_LOG_F 0x40
|
#define LOG_EVENT_RELAY_LOG_F 0x40
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@def LOG_EVENT_DO_NOT_REPLICATE_F
|
@def LOG_EVENT_SKIP_REPLICATION_F
|
||||||
|
|
||||||
Flag set by application creating the event (with @@do_not_replicate); the
|
Flag set by application creating the event (with @@skip_replication); the
|
||||||
slave will skip replication of such events if
|
slave will skip replication of such events if
|
||||||
--replicate-ignore-do-not-replicate is set.
|
--replicate-events-marked-for-skip is false.
|
||||||
|
|
||||||
This is a MariaDB flag; we allocate it from the end of the available
|
This is a MariaDB flag; we allocate it from the end of the available
|
||||||
values to reduce risk of conflict with new MySQL flags.
|
values to reduce risk of conflict with new MySQL flags.
|
||||||
*/
|
*/
|
||||||
#define LOG_EVENT_DO_NOT_REPLICATE_F 0x8000
|
#define LOG_EVENT_SKIP_REPLICATION_F 0x8000
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -670,10 +670,10 @@ typedef struct st_print_event_info
|
|||||||
uint thread_id;
|
uint thread_id;
|
||||||
bool thread_id_printed;
|
bool thread_id_printed;
|
||||||
/*
|
/*
|
||||||
Track when @@do_not_replicate changes so we need to output a SET
|
Track when @@skip_replication changes so we need to output a SET
|
||||||
statement for it.
|
statement for it.
|
||||||
*/
|
*/
|
||||||
int do_not_replicate;
|
int skip_replication;
|
||||||
|
|
||||||
st_print_event_info();
|
st_print_event_info();
|
||||||
|
|
||||||
@ -929,7 +929,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Some 16 flags. See the definitions above for LOG_EVENT_TIME_F,
|
Some 16 flags. See the definitions above for LOG_EVENT_TIME_F,
|
||||||
LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F,
|
LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F,
|
||||||
LOG_EVENT_SUPPRESS_USE_F, and LOG_EVENT_DO_NOT_REPLICATE_F for notes.
|
LOG_EVENT_SUPPRESS_USE_F, and LOG_EVENT_SKIP_REPLICATION_F for notes.
|
||||||
*/
|
*/
|
||||||
uint16 flags;
|
uint16 flags;
|
||||||
|
|
||||||
@ -3933,8 +3933,8 @@ public:
|
|||||||
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
|
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
|
||||||
m_message.str= NULL; /* Just as a precaution */
|
m_message.str= NULL; /* Just as a precaution */
|
||||||
m_message.length= 0;
|
m_message.length= 0;
|
||||||
/* Replicate the incident irregardless of @@do_not_replicate. */
|
/* Replicate the incident irregardless of @@skip_replication. */
|
||||||
flags&= ~LOG_EVENT_DO_NOT_REPLICATE_F;
|
flags&= ~LOG_EVENT_SKIP_REPLICATION_F;
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3944,8 +3944,8 @@ public:
|
|||||||
DBUG_ENTER("Incident_log_event::Incident_log_event");
|
DBUG_ENTER("Incident_log_event::Incident_log_event");
|
||||||
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
|
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
|
||||||
m_message= msg;
|
m_message= msg;
|
||||||
/* Replicate the incident irregardless of @@do_not_replicate. */
|
/* Replicate the incident irregardless of @@skip_replication. */
|
||||||
flags&= ~LOG_EVENT_DO_NOT_REPLICATE_F;
|
flags&= ~LOG_EVENT_SKIP_REPLICATION_F;
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -504,7 +504,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
#define TMP_TABLE_FORCE_MYISAM (ULL(1) << 32)
|
#define TMP_TABLE_FORCE_MYISAM (ULL(1) << 32)
|
||||||
#define OPTION_PROFILING (ULL(1) << 33)
|
#define OPTION_PROFILING (ULL(1) << 33)
|
||||||
#define OPTION_DO_NOT_REPLICATE (ULL(1) << 34) // THD, user
|
#define OPTION_SKIP_REPLICATION (ULL(1) << 34) // THD, user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2065,7 +2065,7 @@ extern my_bool opt_old_style_user_limits, trust_function_creators;
|
|||||||
extern uint opt_crash_binlog_innodb;
|
extern uint opt_crash_binlog_innodb;
|
||||||
extern char *shared_memory_base_name, *mysqld_unix_port;
|
extern char *shared_memory_base_name, *mysqld_unix_port;
|
||||||
extern my_bool opt_enable_shared_memory;
|
extern my_bool opt_enable_shared_memory;
|
||||||
extern my_bool opt_replicate_ignore_do_not_replicate;
|
extern my_bool opt_replicate_events_marked_for_skip;
|
||||||
extern char *default_tz_name;
|
extern char *default_tz_name;
|
||||||
#endif /* MYSQL_SERVER */
|
#endif /* MYSQL_SERVER */
|
||||||
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
|
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
|
||||||
|
@ -553,7 +553,7 @@ uint opt_large_page_size= 0;
|
|||||||
uint opt_debug_sync_timeout= 0;
|
uint opt_debug_sync_timeout= 0;
|
||||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||||
my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
|
my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
|
||||||
my_bool opt_replicate_ignore_do_not_replicate;
|
my_bool opt_replicate_events_marked_for_skip;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
True if there is at least one per-hour limit for some user, so we should
|
True if there is at least one per-hour limit for some user, so we should
|
||||||
@ -5935,6 +5935,7 @@ enum options_mysqld
|
|||||||
OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE,
|
OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE,
|
||||||
OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE,
|
OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE,
|
||||||
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
|
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
|
||||||
|
OPT_REPLICATE_EVENTS_MARKED_FOR_SKIP,
|
||||||
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
|
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
|
||||||
OPT_ABORT_SLAVE_EVENT_COUNT,
|
OPT_ABORT_SLAVE_EVENT_COUNT,
|
||||||
OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
|
OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
|
||||||
@ -6087,8 +6088,7 @@ enum options_mysqld
|
|||||||
OPT_IGNORE_BUILTIN_INNODB,
|
OPT_IGNORE_BUILTIN_INNODB,
|
||||||
OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
|
OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
|
||||||
OPT_DEFAULT_CHARACTER_SET_OLD,
|
OPT_DEFAULT_CHARACTER_SET_OLD,
|
||||||
OPT_MAX_LONG_DATA_SIZE,
|
OPT_MAX_LONG_DATA_SIZE
|
||||||
OPT_REPLICATE_IGNORE_DO_NOT_REPLICATE
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -6785,11 +6785,12 @@ each time the SQL thread starts.",
|
|||||||
"cross database updates. If you need cross database updates to work, "
|
"cross database updates. If you need cross database updates to work, "
|
||||||
"make sure you have 3.23.28 or later, and use replicate-wild-ignore-"
|
"make sure you have 3.23.28 or later, and use replicate-wild-ignore-"
|
||||||
"table=db_name.%. ", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
"table=db_name.%. ", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
{"replicate-ignore-do-not-replicate", OPT_REPLICATE_IGNORE_DO_NOT_REPLICATE,
|
{"replicate-events-marked-for-skip", OPT_REPLICATE_EVENTS_MARKED_FOR_SKIP,
|
||||||
"Tells the slave thread not to replicate events that were created with"
|
"Tells the slave thread to replicate events that were created with"
|
||||||
"@@do_not_replicat=1.", &opt_replicate_ignore_do_not_replicate,
|
"@@skip_replication=1. Default true. If set to false, such events will not"
|
||||||
&opt_replicate_ignore_do_not_replicate, 0, GET_BOOL, NO_ARG,
|
"be replicated.", &opt_replicate_events_marked_for_skip,
|
||||||
0, 0, 0 ,0, 0, 0},
|
&opt_replicate_events_marked_for_skip, 0, GET_BOOL, NO_ARG,
|
||||||
|
1, 0, 0 ,0, 0, 0},
|
||||||
{"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE,
|
{"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE,
|
||||||
"Tells the slave thread to not replicate to the specified table. To specify "
|
"Tells the slave thread to not replicate to the specified table. To specify "
|
||||||
"more than one table to ignore, use the directive multiple times, once for "
|
"more than one table to ignore, use the directive multiple times, once for "
|
||||||
|
@ -117,7 +117,7 @@ static bool set_option_log_bin_bit(THD *thd, set_var *var);
|
|||||||
static bool set_option_autocommit(THD *thd, set_var *var);
|
static bool set_option_autocommit(THD *thd, set_var *var);
|
||||||
static int check_log_update(THD *thd, set_var *var);
|
static int check_log_update(THD *thd, set_var *var);
|
||||||
static bool set_log_update(THD *thd, set_var *var);
|
static bool set_log_update(THD *thd, set_var *var);
|
||||||
static int check_do_not_replicate(THD *thd, set_var *var);
|
static int check_skip_replication(THD *thd, set_var *var);
|
||||||
static int check_pseudo_thread_id(THD *thd, set_var *var);
|
static int check_pseudo_thread_id(THD *thd, set_var *var);
|
||||||
void fix_binlog_format_after_update(THD *thd, enum_var_type type);
|
void fix_binlog_format_after_update(THD *thd, enum_var_type type);
|
||||||
static void fix_low_priority_updates(THD *thd, enum_var_type type);
|
static void fix_low_priority_updates(THD *thd, enum_var_type type);
|
||||||
@ -831,10 +831,20 @@ static sys_var_thd_bit sys_profiling(&vars, "profiling", NULL,
|
|||||||
static sys_var_thd_ulong sys_profiling_history_size(&vars, "profiling_history_size",
|
static sys_var_thd_ulong sys_profiling_history_size(&vars, "profiling_history_size",
|
||||||
&SV::profiling_history_size);
|
&SV::profiling_history_size);
|
||||||
#endif
|
#endif
|
||||||
static sys_var_thd_bit sys_do_not_replicate(&vars, "do_not_replicate",
|
/*
|
||||||
check_do_not_replicate,
|
When this is set by a connection, binlogged events will be marked with a
|
||||||
|
corresponding flag. The slave can be configured to not replicate events
|
||||||
|
so marked.
|
||||||
|
In the binlog dump thread on the master, this variable is re-used for a
|
||||||
|
related purpose: The slave sets this flag when connecting to the master to
|
||||||
|
request that the master filter out (ie. not send) any events with the flag
|
||||||
|
set, thus saving network traffic on events that would be ignored by the
|
||||||
|
slave anyway.
|
||||||
|
*/
|
||||||
|
static sys_var_thd_bit sys_skip_replication(&vars, "skip_replication",
|
||||||
|
check_skip_replication,
|
||||||
set_option_bit,
|
set_option_bit,
|
||||||
OPTION_DO_NOT_REPLICATE);
|
OPTION_SKIP_REPLICATION);
|
||||||
|
|
||||||
/* Local state variables */
|
/* Local state variables */
|
||||||
|
|
||||||
@ -912,10 +922,10 @@ static sys_var_thd_set sys_log_slow_verbosity(&vars,
|
|||||||
&SV::log_slow_verbosity,
|
&SV::log_slow_verbosity,
|
||||||
&log_slow_verbosity_typelib);
|
&log_slow_verbosity_typelib);
|
||||||
#ifdef HAVE_REPLICATION
|
#ifdef HAVE_REPLICATION
|
||||||
static sys_var_replicate_ignore_do_not_replicate
|
static sys_var_replicate_events_marked_for_skip
|
||||||
sys_replicate_ignore_do_not_replicate(&vars,
|
sys_replicate_events_marked_for_skip(&vars,
|
||||||
"replicate_ignore_do_not_replicate",
|
"replicate_events_marked_for_skip",
|
||||||
&opt_replicate_ignore_do_not_replicate);
|
&opt_replicate_events_marked_for_skip);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Global read-only variable containing hostname */
|
/* Global read-only variable containing hostname */
|
||||||
@ -3279,10 +3289,10 @@ static bool set_log_update(THD *thd, set_var *var)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int check_do_not_replicate(THD *thd, set_var *var)
|
static int check_skip_replication(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
We must not change @@do_not_replicate in the middle of a transaction or
|
We must not change @@skip_replication in the middle of a transaction or
|
||||||
statement, as that could result in only part of the transaction / statement
|
statement, as that could result in only part of the transaction / statement
|
||||||
being replicated.
|
being replicated.
|
||||||
(This would be particularly serious if we were to replicate eg.
|
(This would be particularly serious if we were to replicate eg.
|
||||||
@ -4443,11 +4453,11 @@ sys_var_event_scheduler::update(THD *thd, set_var *var)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_REPLICATION
|
#ifdef HAVE_REPLICATION
|
||||||
bool sys_var_replicate_ignore_do_not_replicate::update(THD *thd, set_var *var)
|
bool sys_var_replicate_events_marked_for_skip::update(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
int thread_mask;
|
int thread_mask;
|
||||||
DBUG_ENTER("sys_var_replicate_ignore_do_not_replicate::update");
|
DBUG_ENTER("sys_var_replicate_events_marked_for_skip::update");
|
||||||
|
|
||||||
/* Slave threads must be stopped to change the variable. */
|
/* Slave threads must be stopped to change the variable. */
|
||||||
pthread_mutex_lock(&LOCK_active_mi);
|
pthread_mutex_lock(&LOCK_active_mi);
|
||||||
|
@ -1286,17 +1286,17 @@ public:
|
|||||||
|
|
||||||
#ifdef HAVE_REPLICATION
|
#ifdef HAVE_REPLICATION
|
||||||
/**
|
/**
|
||||||
Handler for setting the system variable --replicate-ignore-do-not-replicate.
|
Handler for setting the system variable --replicate-events-marked-for-skip.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class sys_var_replicate_ignore_do_not_replicate :public sys_var_bool_ptr
|
class sys_var_replicate_events_marked_for_skip :public sys_var_bool_ptr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
sys_var_replicate_ignore_do_not_replicate(sys_var_chain *chain,
|
sys_var_replicate_events_marked_for_skip(sys_var_chain *chain,
|
||||||
const char *name_arg,
|
const char *name_arg,
|
||||||
my_bool *value_arg) :
|
my_bool *value_arg) :
|
||||||
sys_var_bool_ptr(chain, name_arg, value_arg) {};
|
sys_var_bool_ptr(chain, name_arg, value_arg) {};
|
||||||
~sys_var_replicate_ignore_do_not_replicate() {};
|
~sys_var_replicate_events_marked_for_skip() {};
|
||||||
bool update(THD *thd, set_var *var);
|
bool update(THD *thd, set_var *var);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
34
sql/slave.cc
34
sql/slave.cc
@ -1177,18 +1177,18 @@ when it try to get the value of TIME_ZONE global variable from master.";
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Request the master to filter away events with the @@do_not_replicate flag
|
Request the master to filter away events with the @@skip_replication flag
|
||||||
set, if we are running with --replicate-ignore-do_not_replicate=1.
|
set, if we are running with --replicate-events-marked-for-skip=0.
|
||||||
*/
|
*/
|
||||||
if (opt_replicate_ignore_do_not_replicate)
|
if (!opt_replicate_events_marked_for_skip)
|
||||||
{
|
{
|
||||||
if (!mysql_real_query(mysql, STRING_WITH_LEN("SET do_not_replicate=1")))
|
if (mysql_real_query(mysql, STRING_WITH_LEN("SET skip_replication=1")))
|
||||||
{
|
{
|
||||||
err_code= mysql_errno(mysql);
|
err_code= mysql_errno(mysql);
|
||||||
if (is_network_error(err_code))
|
if (is_network_error(err_code))
|
||||||
{
|
{
|
||||||
mi->report(ERROR_LEVEL, err_code,
|
mi->report(ERROR_LEVEL, err_code,
|
||||||
"Setting master-side filtering of @@do_not_replicate failed "
|
"Setting master-side filtering of @@skip_replication failed "
|
||||||
"with error: %s", mysql_error(mysql));
|
"with error: %s", mysql_error(mysql));
|
||||||
goto network_err;
|
goto network_err;
|
||||||
}
|
}
|
||||||
@ -1196,15 +1196,24 @@ when it try to get the value of TIME_ZONE global variable from master.";
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
The master is older than the slave and does not support the
|
The master is older than the slave and does not support the
|
||||||
@@do_not_replicate feature.
|
@@skip_replication feature.
|
||||||
This is not a problem, as such master will not generate events with
|
This is not a problem, as such master will not generate events with
|
||||||
the @@do_not_replicate flag set in the first place. We will still
|
the @@skip_replication flag set in the first place. We will still
|
||||||
do slave-side filtering of such events though, to handle the (rare)
|
do slave-side filtering of such events though, to handle the (rare)
|
||||||
case of downgrading a master and receiving old events generated from
|
case of downgrading a master and receiving old events generated from
|
||||||
before the downgrade with the @@do_not_replicate flag set.
|
before the downgrade with the @@skip_replication flag set.
|
||||||
*/
|
*/
|
||||||
DBUG_PRINT("info", ("Old master does not support master-side filtering "
|
DBUG_PRINT("info", ("Old master does not support master-side filtering "
|
||||||
"of @@do_not_replicate events."));
|
"of @@skip_replication events."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Fatal error */
|
||||||
|
errmsg= "The slave I/O thread stops because a fatal error is "
|
||||||
|
"encountered when it tries to request filtering of events marked "
|
||||||
|
"with the @@skip_replication flag.";
|
||||||
|
sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2146,8 +2155,8 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli)
|
|||||||
thd->lex->current_select= 0;
|
thd->lex->current_select= 0;
|
||||||
if (!ev->when)
|
if (!ev->when)
|
||||||
ev->when= my_time(0);
|
ev->when= my_time(0);
|
||||||
thd->options= (thd->options & ~OPTION_DO_NOT_REPLICATE) |
|
thd->options= (thd->options & ~OPTION_SKIP_REPLICATION) |
|
||||||
(ev->flags & LOG_EVENT_DO_NOT_REPLICATE_F ? OPTION_DO_NOT_REPLICATE : 0);
|
(ev->flags & LOG_EVENT_SKIP_REPLICATION_F ? OPTION_SKIP_REPLICATION : 0);
|
||||||
ev->thd = thd; // because up to this point, ev->thd == 0
|
ev->thd = thd; // because up to this point, ev->thd == 0
|
||||||
|
|
||||||
int reason= ev->shall_skip(rli);
|
int reason= ev->shall_skip(rli);
|
||||||
@ -3627,7 +3636,6 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
|
|||||||
buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */)
|
buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */)
|
||||||
DBUG_RETURN(queue_old_event(mi,buf,event_len));
|
DBUG_RETURN(queue_old_event(mi,buf,event_len));
|
||||||
|
|
||||||
LINT_INIT(inc_pos);
|
|
||||||
pthread_mutex_lock(&mi->data_lock);
|
pthread_mutex_lock(&mi->data_lock);
|
||||||
|
|
||||||
switch (buf[EVENT_TYPE_OFFSET]) {
|
switch (buf[EVENT_TYPE_OFFSET]) {
|
||||||
@ -3702,7 +3710,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If we filter events master-side (eg. @@do_not_replicate), we will see holes
|
If we filter events master-side (eg. @@skip_replication), we will see holes
|
||||||
in the event positions from the master. If we see such a hole, adjust
|
in the event positions from the master. If we see such a hole, adjust
|
||||||
mi->master_log_pos accordingly so we maintain the correct position (for
|
mi->master_log_pos accordingly so we maintain the correct position (for
|
||||||
reconnect, MASTER_POS_WAIT(), etc.)
|
reconnect, MASTER_POS_WAIT(), etc.)
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
void mysql_client_binlog_statement(THD* thd)
|
void mysql_client_binlog_statement(THD* thd)
|
||||||
{
|
{
|
||||||
ulonglong save_do_not_replicate;
|
ulonglong save_skip_replication;
|
||||||
DBUG_ENTER("mysql_client_binlog_statement");
|
DBUG_ENTER("mysql_client_binlog_statement");
|
||||||
DBUG_PRINT("info",("binlog base64: '%*s'",
|
DBUG_PRINT("info",("binlog base64: '%*s'",
|
||||||
(int) (thd->lex->comment.length < 2048 ?
|
(int) (thd->lex->comment.length < 2048 ?
|
||||||
@ -214,15 +214,15 @@ void mysql_client_binlog_statement(THD* thd)
|
|||||||
reporting.
|
reporting.
|
||||||
*/
|
*/
|
||||||
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
|
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
|
||||||
save_do_not_replicate= thd->options & OPTION_DO_NOT_REPLICATE;
|
save_skip_replication= thd->options & OPTION_SKIP_REPLICATION;
|
||||||
thd->options= (thd->options & ~OPTION_DO_NOT_REPLICATE) |
|
thd->options= (thd->options & ~OPTION_SKIP_REPLICATION) |
|
||||||
(ev->flags & LOG_EVENT_DO_NOT_REPLICATE_F ?
|
(ev->flags & LOG_EVENT_SKIP_REPLICATION_F ?
|
||||||
OPTION_DO_NOT_REPLICATE : 0);
|
OPTION_SKIP_REPLICATION : 0);
|
||||||
|
|
||||||
err= ev->apply_event(rli);
|
err= ev->apply_event(rli);
|
||||||
|
|
||||||
thd->options= (thd->options & ~OPTION_DO_NOT_REPLICATE) |
|
thd->options= (thd->options & ~OPTION_SKIP_REPLICATION) |
|
||||||
save_do_not_replicate;
|
save_skip_replication;
|
||||||
#else
|
#else
|
||||||
err= 0;
|
err= 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -349,13 +349,17 @@ send_event_to_slave(THD *thd, NET *net, String* const packet)
|
|||||||
thd_proc_info(thd, "Sending binlog event to slave");
|
thd_proc_info(thd, "Sending binlog event to slave");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Skip events with the @@do_not_replicate flag set, if slave requested
|
Skip events with the @@skip_replication flag set, if slave requested
|
||||||
skipping of such events.
|
skipping of such events.
|
||||||
*/
|
*/
|
||||||
if (thd->options & OPTION_DO_NOT_REPLICATE)
|
if (thd->options & OPTION_SKIP_REPLICATION)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
The first byte of the packet is a '\0' to distinguish it from an error
|
||||||
|
packet. So the actual event starts at offset +1.
|
||||||
|
*/
|
||||||
uint16 flags= uint2korr(&((*packet)[FLAGS_OFFSET+1]));
|
uint16 flags= uint2korr(&((*packet)[FLAGS_OFFSET+1]));
|
||||||
if (flags & LOG_EVENT_DO_NOT_REPLICATE_F)
|
if (flags & LOG_EVENT_SKIP_REPLICATION_F)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user