summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/include/mtr_check.sql1
-rw-r--r--mysql-test/suite/multi_source/gtid.result6
-rw-r--r--mysql-test/suite/multi_source/gtid.test6
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_basic.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_crash.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result15
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_startpos.result42
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_stop_start.result2
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_basic.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_crash.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_startpos.test42
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_stop_start.test2
-rw-r--r--mysql-test/suite/sys_vars/r/gtid_pos_basic.result47
-rw-r--r--mysql-test/suite/sys_vars/t/gtid_pos_basic.test44
-rw-r--r--sql/lex.h2
-rw-r--r--sql/share/errmsg-utf8.txt6
-rw-r--r--sql/sql_lex.h10
-rw-r--r--sql/sql_repl.cc162
-rw-r--r--sql/sql_repl.h2
-rw-r--r--sql/sql_yacc.yy22
-rw-r--r--sql/sys_vars.cc86
-rw-r--r--sql/sys_vars.h40
25 files changed, 390 insertions, 188 deletions
diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql
index 6c1a3513324..c66a7fea938 100644
--- a/mysql-test/include/mtr_check.sql
+++ b/mysql-test/include/mtr_check.sql
@@ -31,6 +31,7 @@ BEGIN
AND variable_name not like "Last_IO_Err*"
AND variable_name != 'INNODB_IBUF_MAX_SIZE'
AND variable_name != 'INNODB_USE_NATIVE_AIO'
+ AND variable_name != 'GTID_POS'
ORDER BY variable_name;
-- Dump all databases, there should be none
diff --git a/mysql-test/suite/multi_source/gtid.result b/mysql-test/suite/multi_source/gtid.result
index 126483725bc..fb727aabae2 100644
--- a/mysql-test/suite/multi_source/gtid.result
+++ b/mysql-test/suite/multi_source/gtid.result
@@ -84,8 +84,8 @@ INSERT INTO t1 VALUES (2, "switch1");
INSERT INTO t3 VALUES (102, "switch1 a");
INSERT INTO t2 VALUES (2, "switch1");
INSERT INTO t3 VALUES (202, "switch1 b");
-CHANGE MASTER 'slave1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_gtid_pos=auto;
-CHANGE MASTER 'slave2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_gtid_pos=auto;
+CHANGE MASTER 'slave1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=1;
+CHANGE MASTER 'slave2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=1;
SET default_master_connection = 'slave1';
START SLAVE;
include/wait_for_slave_to_start.inc
@@ -102,7 +102,7 @@ INSERT INTO t3 VALUES (203, "switch 2 b");
STOP SLAVE 'slave2';
INSERT INTO t2 VALUES (4, "switch 3");
INSERT INTO t3 VALUES (204, "switch 3 b");
-CHANGE MASTER TO master_port=MYPORT_4, master_host='127.0.0.1', master_user='root', master_gtid_pos=auto;
+CHANGE MASTER TO master_port=MYPORT_4, master_host='127.0.0.1', master_user='root', master_use_gtid=1;
START SLAVE;
SELECT * FROM t1 ORDER BY a;
a b
diff --git a/mysql-test/suite/multi_source/gtid.test b/mysql-test/suite/multi_source/gtid.test
index 1352d4a3df4..06a0edf2ccc 100644
--- a/mysql-test/suite/multi_source/gtid.test
+++ b/mysql-test/suite/multi_source/gtid.test
@@ -69,9 +69,9 @@ INSERT INTO t3 VALUES (202, "switch1 b");
--connection slave2
--replace_result $SERVER_MYPORT_1 MYPORT_1
-eval CHANGE MASTER 'slave1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_gtid_pos=auto;
+eval CHANGE MASTER 'slave1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=1;
--replace_result $SERVER_MYPORT_2 MYPORT_2
-eval CHANGE MASTER 'slave2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_gtid_pos=auto;
+eval CHANGE MASTER 'slave2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=1;
SET default_master_connection = 'slave1';
START SLAVE;
--source include/wait_for_slave_to_start.inc
@@ -112,7 +112,7 @@ INSERT INTO t3 VALUES (204, "switch 3 b");
--connection slave1
--replace_result $SERVER_MYPORT_4 MYPORT_4
-eval CHANGE MASTER TO master_port=$SERVER_MYPORT_4, master_host='127.0.0.1', master_user='root', master_gtid_pos=auto;
+eval CHANGE MASTER TO master_port=$SERVER_MYPORT_4, master_host='127.0.0.1', master_user='root', master_use_gtid=1;
START SLAVE;
--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=3 AND (SELECT COUNT(*) FROM t2)=4 AND (SELECT COUNT(*) FROM t3)=7
--source include/wait_condition.inc
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index 75da3f6cbdb..bbe59ee69ae 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -49,7 +49,7 @@ include/stop_slave.inc
INSERT INTO t1 VALUES (5, "m1a");
INSERT INTO t2 VALUES (5, "i1a");
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS=AUTO;
+MASTER_USE_GTID=1;
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a b
@@ -68,7 +68,7 @@ a b
*** Now move B to D (C is still replicating from B) ***
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
-MASTER_GTID_POS=AUTO;
+MASTER_USE_GTID=1;
include/start_slave.inc
UPDATE t2 SET b="j1a" WHERE a=5;
SELECT * FROM t1 ORDER BY a;
@@ -92,7 +92,7 @@ INSERT INTO t2 VALUES (6, "i6b");
INSERT INTO t2 VALUES (7, "i7b");
COMMIT;
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
-MASTER_GTID_POS=AUTO;
+MASTER_USE_GTID=1;
include/start_slave.inc
SELECT * FROM t2 ORDER BY a;
a b
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_crash.result b/mysql-test/suite/rpl/r/rpl_gtid_crash.result
index 92c48909fce..b4c2056f45a 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_crash.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_crash.result
@@ -8,7 +8,7 @@ CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 0);
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS=AUTO;
+MASTER_USE_GTID=1;
INSERT INTO t1 VALUES (2,1);
INSERT INTO t1 VALUES (3,1);
include/start_slave.inc
@@ -20,7 +20,7 @@ DROP TABLE t1;
*** Test crashing the master mysqld and check that binlog state is recovered. ***
include/stop_slave.inc
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos='';
RESET MASTER;
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result b/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
index 7924ae6bec1..44e884db3cf 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
@@ -38,12 +38,13 @@ SET sql_log_bin = 0;
INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1;
INSERT INTO t1 VALUES (3);
-CHANGE MASTER TO master_gtid_pos = "0-1-1";
-ERROR HY000: Requested MASTER_GTID_POS 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
-CHANGE MASTER TO master_gtid_pos = "";
-ERROR HY000: Requested MASTER_GTID_POS contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
+CHANGE MASTER TO master_use_gtid=1;
+SET GLOBAL gtid_pos = "0-1-1";
+ERROR HY000: Requested GTID_POS 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
+SET GLOBAL gtid_pos = "";
+ERROR HY000: Requested GTID_POS contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos = "0-1-1";
+SET GLOBAL gtid_pos = "0-1-1";
START SLAVE;
SELECT * FROM t1 ORDER BY a;
a
@@ -53,7 +54,7 @@ a
4
*** Test slave requesting a GTID that is not present in the master's binlog ***
include/stop_slave.inc
-CHANGE MASTER TO master_gtid_pos = "0-1-3";
+SET GLOBAL gtid_pos = "0-1-3";
START SLAVE;
SET sql_log_bin=0;
CALL mtr.add_suppression("Got fatal error .* from master when reading data from binary log: 'Error: connecting slave requested to start from GTID .*, which is not in the master's binlog'");
@@ -64,7 +65,7 @@ Last_IO_Errno = '1236'
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Error: connecting slave requested to start from GTID 0-1-3, which is not in the master's binlog''
Using_Gtid = '1'
include/stop_slave.inc
-CHANGE MASTER TO master_gtid_pos = "0-1-2";
+SET GLOBAL gtid_pos = "0-1-2";
START SLAVE;
include/wait_for_slave_to_start.inc
INSERT INTO t1 VALUES (5);
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result b/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result
index 8f6a8801618..265d0ca185c 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result
@@ -24,7 +24,7 @@ slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4, 2)
slave-bin.000001 # Query # # COMMIT
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_PORT,
-master_user = 'root', master_gtid_pos = AUTO;
+master_user = 'root', master_use_gtid = 1;
START SLAVE;
SELECT * FROM t1 ORDER BY a;
a b
@@ -37,7 +37,7 @@ RESET SLAVE;
INSERT INTO t1 VALUES (5, 1);
INSERT INTO t1 VALUES (6, 1);
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-master_gtid_pos = AUTO;
+master_use_gtid = 1;
START SLAVE;
SELECT * FROM t1 ORDER BY a;
a b
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_startpos.result b/mysql-test/suite/rpl/r/rpl_gtid_startpos.result
index 911f5ad3909..1f95ee4a6e0 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_startpos.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_startpos.result
@@ -6,8 +6,9 @@ RESET SLAVE;
RESET MASTER;
FLUSH LOGS;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+SET GLOBAL gtid_pos="";
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS="";
+MASTER_USE_GTID=1;
include/start_slave.inc
SELECT * FROM t1;
a
@@ -23,8 +24,9 @@ include/wait_for_purge.inc "master-bin.000003"
show binary logs;
Log_name File_size
master-bin.000003 #
+SET GLOBAL gtid_pos="";
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS="";
+MASTER_USE_GTID=1;
START SLAVE;
include/wait_for_slave_io_error.inc [errno=1236]
include/stop_slave.inc
@@ -38,11 +40,12 @@ a
SET sql_log_bin=0;
call mtr.add_suppression('Could not find GTID state requested by slave in any binlog files');
SET sql_log_bin=1;
-*** Test that we give error when explict MASTER_GTID_POS=xxx that conflicts with what is in our binary log ***
+*** Test that we give error when explict @@gtid_pos=xxx that conflicts with what is in our binary log ***
include/stop_slave.inc
INSERT INTO t1 VALUES(3);
+SET GLOBAL gtid_pos='0-1-3';
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS='0-1-3';
+MASTER_USE_GTID=1;
include/start_slave.inc
SELECT * FROM t1 ORDER by a;
a
@@ -53,12 +56,10 @@ include/stop_slave.inc
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (10);
DELETE FROM t1 WHERE a=10;
-CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS='0-1-4';
-ERROR HY000: Requested MASTER_GTID_POS 0-1-4 conflicts with the binary log which contains a more recent GTID 0-2-6. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
+SET GLOBAL gtid_pos='0-1-4';
+ERROR HY000: Requested GTID_POS 0-1-4 conflicts with the binary log which contains a more recent GTID 0-2-6. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
RESET MASTER;
-CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_GTID_POS='0-1-4';
+SET GLOBAL gtid_pos='0-1-4';
START SLAVE;
SELECT * FROM t1 ORDER by a;
a
@@ -72,7 +73,8 @@ include/stop_slave.inc
RESET SLAVE ALL;
RESET MASTER;
RESET MASTER;
-CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_gtid_pos='';
+SET GLOBAL gtid_pos='';
+CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=1;
include/start_slave.inc
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1);
@@ -87,14 +89,14 @@ SELECT * FROM t1 ORDER BY a;
a
1
2
-*** MDEV-4329: MASTER_GTID_POS='' is not checked for conflicts with binlog ***
+*** MDEV-4329: GTID_POS='' is not checked for conflicts with binlog ***
include/stop_slave.inc
DROP TABLE t1;
RESET SLAVE;
-CHANGE MASTER TO master_gtid_pos='';
-ERROR HY000: Requested MASTER_GTID_POS contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-4. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
+SET GLOBAL gtid_pos="";
+ERROR HY000: Requested GTID_POS contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-4. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a
@@ -105,7 +107,7 @@ SET SQL_LOG_BIN=0;
DROP TABLE t1;
SET SQL_LOG_BIN=1;
RESET SLAVE;
-CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a
@@ -118,7 +120,7 @@ Using_Gtid = '0'
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=1050]
STOP SLAVE IO_THREAD;
-CHANGE MASTER TO MASTER_GTID_POS=AUTO;
+CHANGE MASTER TO MASTER_USE_GTID=1;
include/start_slave.inc
INSERT INTO t1 VALUES(3);
SELECT * FROM t1 ORDER BY a;
@@ -152,7 +154,7 @@ a
*** Test modifying binlog on slave and the effect on GTID state. ***
include/stop_slave.inc
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
RESET MASTER;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (10);
@@ -172,13 +174,13 @@ SELECT '0-2-4' AS Gtid_Pos;
Gtid_Pos
0-2-4
include/stop_slave.inc
-CHANGE MASTER TO master_gtid_pos= '0-1-2';
-ERROR HY000: Requested MASTER_GTID_POS 0-1-2 conflicts with the binary log which contains a more recent GTID 0-2-4. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
+SET GLOBAL gtid_pos='0-1-2';
+ERROR HY000: Requested GTID_POS 0-1-2 conflicts with the binary log which contains a more recent GTID 0-2-4. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
RESET MASTER;
SELECT '0-1-2' AS Gtid_Pos;
Gtid_Pos
0-1-2
-CHANGE MASTER TO master_gtid_pos= '0-1-2';
+SET GLOBAL gtid_pos='0-1-2';
include/start_slave.inc
SELECT '0-1-2' AS Gtid_Pos;
Gtid_Pos
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
index ab48d5dd7f6..0bb963cc2ab 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
@@ -5,7 +5,7 @@ INSERT INTO t1 VALUES (1);
include/stop_slave.inc
Master_Log_File = 'master-bin.000001'
Using_Gtid = '0'
-CHANGE MASTER TO master_gtid_pos=AUTO;
+CHANGE MASTER TO master_use_gtid=1;
FLUSH LOGS;
include/wait_for_purge.inc "master-bin.000002"
show binary logs;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
index aa49280fa91..becb284c0c2 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
@@ -49,7 +49,7 @@ save_master_pos;
connection server_4;
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS=AUTO;
+ MASTER_USE_GTID=1;
--source include/start_slave.inc
sync_with_master;
SELECT * FROM t1 ORDER BY a;
@@ -60,7 +60,7 @@ connection server_2;
--source include/stop_slave.inc
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
- MASTER_GTID_POS=AUTO;
+ MASTER_USE_GTID=1;
--source include/start_slave.inc
connection server_4;
@@ -85,7 +85,7 @@ COMMIT;
connection server_3;
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
- MASTER_GTID_POS=AUTO;
+ MASTER_USE_GTID=1;
--source include/start_slave.inc
# This time, let's sync up without reference to binlog on D.
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
@@ -93,7 +93,7 @@ eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
SELECT * FROM t2 ORDER BY a;
--echo *** Now change everything back to what it was, to make rpl_end.inc happy
-# Also check that MASTER_GTID_POS=AUTO is still enabled.
+# Also check that MASTER_USE_GTID=1 is still enabled.
connection server_2;
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_MYPORT
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash.test b/mysql-test/suite/rpl/t/rpl_gtid_crash.test
index 0f3f49948c2..51a81506ba7 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_crash.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_crash.test
@@ -23,7 +23,7 @@ INSERT INTO t1 VALUES (1, 0);
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS=AUTO;
+ MASTER_USE_GTID=1;
--connection server_1
INSERT INTO t1 VALUES (2,1);
@@ -80,7 +80,7 @@ DROP TABLE t1;
--sync_with_master
--source include/stop_slave.inc
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos='';
--connection server_1
RESET MASTER;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test b/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
index 2720d8c5028..74d9a3ad1f5 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
@@ -69,12 +69,13 @@ INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1;
INSERT INTO t1 VALUES (3);
+CHANGE MASTER TO master_use_gtid=1;
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
-CHANGE MASTER TO master_gtid_pos = "0-1-1";
+SET GLOBAL gtid_pos = "0-1-1";
--error ER_MASTER_GTID_POS_MISSING_DOMAIN
-CHANGE MASTER TO master_gtid_pos = "";
+SET GLOBAL gtid_pos = "";
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos = "0-1-1";
+SET GLOBAL gtid_pos = "0-1-1";
START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
@@ -84,7 +85,7 @@ SELECT * FROM t1 ORDER BY a;
--echo *** Test slave requesting a GTID that is not present in the master's binlog ***
--source include/stop_slave.inc
-CHANGE MASTER TO master_gtid_pos = "0-1-3";
+SET GLOBAL gtid_pos = "0-1-3";
START SLAVE;
SET sql_log_bin=0;
@@ -97,7 +98,7 @@ SET sql_log_bin=1;
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
-CHANGE MASTER TO master_gtid_pos = "0-1-2";
+SET GLOBAL gtid_pos = "0-1-2";
START SLAVE;
--source include/wait_for_slave_to_start.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test b/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test
index 1f34c143617..d8073e19fb0 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test
@@ -26,7 +26,7 @@ INSERT INTO t1 VALUES (4, 2);
--connection server_1
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT,
- master_user = 'root', master_gtid_pos = AUTO;
+ master_user = 'root', master_use_gtid = 1;
START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
--source include/wait_condition.inc
@@ -41,7 +41,7 @@ INSERT INTO t1 VALUES (6, 1);
--connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- master_gtid_pos = AUTO;
+ master_use_gtid = 1;
START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1
--source include/wait_condition.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_startpos.test b/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
index a5200de46ec..b7ec26f4728 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
@@ -16,9 +16,10 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--save_master_pos
--connection server_2
+SET GLOBAL gtid_pos="";
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS="";
+ MASTER_USE_GTID=1;
--source include/start_slave.inc
--sync_with_master
SELECT * FROM t1;
@@ -42,9 +43,10 @@ INSERT INTO t1 VALUES (2);
--source include/show_binary_logs.inc
--connection server_2
+SET GLOBAL gtid_pos="";
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS="";
+ MASTER_USE_GTID=1;
START SLAVE;
--let $slave_io_errno= 1236
--source include/wait_for_slave_io_error.inc
@@ -60,16 +62,17 @@ SET sql_log_bin=0;
call mtr.add_suppression('Could not find GTID state requested by slave in any binlog files');
SET sql_log_bin=1;
---echo *** Test that we give error when explict MASTER_GTID_POS=xxx that conflicts with what is in our binary log ***
+--echo *** Test that we give error when explict @@gtid_pos=xxx that conflicts with what is in our binary log ***
--source include/stop_slave.inc
--connection server_1
INSERT INTO t1 VALUES(3);
--connection server_2
+SET GLOBAL gtid_pos='0-1-3';
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS='0-1-3';
+ MASTER_USE_GTID=1;
--source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 3 FROM t1
--source include/wait_condition.inc
@@ -81,19 +84,15 @@ INSERT INTO t1 VALUES (4);
--connection server_2
# Now add some local transactions that conflict with the GTID position
-# being set for MASTER_GTID_POS.
+# being set for GTID_POS.
INSERT INTO t1 VALUES (10);
DELETE FROM t1 WHERE a=10;
---replace_result $MASTER_MYPORT MASTER_PORT
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
-eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS='0-1-4';
+SET GLOBAL gtid_pos='0-1-4';
# Try again after RESET MASTER to remove the conflicting binlog.
RESET MASTER;
---replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_GTID_POS='0-1-4';
+SET GLOBAL gtid_pos='0-1-4';
START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
--source include/wait_condition.inc
@@ -118,8 +117,9 @@ RESET MASTER;
RESET MASTER;
--connection server_2
+SET GLOBAL gtid_pos='';
--replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_gtid_pos='';
+eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_use_gtid=1;
--source include/start_slave.inc
--connection server_1
@@ -145,22 +145,22 @@ INSERT INTO t1 VALUES (2);
SELECT * FROM t1 ORDER BY a;
---echo *** MDEV-4329: MASTER_GTID_POS='' is not checked for conflicts with binlog ***
+--echo *** MDEV-4329: GTID_POS='' is not checked for conflicts with binlog ***
# Test starting the slave completely from scratch, deleting all tables and
# replicating from the start of the master's binlog. This requires RESET
# MASTER is run on the slave to avoid old junk in the binlog. The bug was
# that the code did not catch the error of missing RESET MASTER when an
-# empty MASTER_GTID_POS='' was specified.
+# empty GTID_POS='' was specified.
--connection server_2
--source include/stop_slave.inc
DROP TABLE t1;
RESET SLAVE;
--error ER_MASTER_GTID_POS_MISSING_DOMAIN
-eval CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
RESET MASTER;
-eval CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
--source include/start_slave.inc
--sync_with_master
@@ -176,7 +176,7 @@ SET SQL_LOG_BIN=0;
DROP TABLE t1;
SET SQL_LOG_BIN=1;
RESET SLAVE;
-eval CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
--source include/start_slave.inc
--sync_with_master
@@ -197,7 +197,7 @@ START SLAVE;
# Going back to using GTID should fix things.
STOP SLAVE IO_THREAD;
-CHANGE MASTER TO MASTER_GTID_POS=AUTO;
+CHANGE MASTER TO MASTER_USE_GTID=1;
--source include/start_slave.inc
--connection server_1
@@ -245,7 +245,7 @@ SELECT * FROM t1 ORDER BY a;
--connection server_2
--source include/stop_slave.inc
RESET MASTER;
-CHANGE MASTER TO master_gtid_pos='';
+SET GLOBAL gtid_pos="";
--connection server_1
RESET MASTER;
@@ -271,11 +271,11 @@ eval SELECT '$value' AS Gtid_Pos;
--source include/stop_slave.inc
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
-CHANGE MASTER TO master_gtid_pos= '0-1-2';
+SET GLOBAL gtid_pos='0-1-2';
RESET MASTER;
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Pos", 1)
eval SELECT '$value' AS Gtid_Pos;
-CHANGE MASTER TO master_gtid_pos= '0-1-2';
+SET GLOBAL gtid_pos='0-1-2';
--source include/start_slave.inc
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Pos", 1)
eval SELECT '$value' AS Gtid_Pos;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
index bb0c27e59ff..a0665110792 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
@@ -15,7 +15,7 @@ INSERT INTO t1 VALUES (1);
--let $status_items= Master_Log_File,Using_Gtid
--source include/show_slave_status.inc
-CHANGE MASTER TO master_gtid_pos=AUTO;
+CHANGE MASTER TO master_use_gtid=1;
# Now try to restart the slave mysqld server without starting the slave first
# threads after the CHANGE MASTER.
diff --git a/mysql-test/suite/sys_vars/r/gtid_pos_basic.result b/mysql-test/suite/sys_vars/r/gtid_pos_basic.result
new file mode 100644
index 00000000000..b97db1b657e
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/gtid_pos_basic.result
@@ -0,0 +1,47 @@
+SET @old_gtid_pos= @@gtid_pos;
+SET GLOBAL gtid_pos= '';
+SELECT @@gtid_pos;
+@@gtid_pos
+
+SET GLOBAL gtid_pos= '1-2-3';
+SELECT variable_value FROM information_schema.global_variables
+WHERE variable_name='gtid_pos';
+variable_value
+1-2-3
+SET @@global.gtid_pos= '1-2-4';
+SELECT @@gtid_pos;
+@@gtid_pos
+1-2-4
+SET GLOBAL gtid_pos= ' 1-2-3';
+SELECT @@gtid_pos;
+@@gtid_pos
+1-2-3
+SET GLOBAL gtid_pos= '1-2-3, 2-4-6';
+SELECT @@gtid_pos;
+@@gtid_pos
+1-2-3,2-4-6
+SET GLOBAL gtid_pos= '-1-2-3';
+ERROR HY000: Could not parse GTID list for GTID_POS
+SET GLOBAL gtid_pos= '1-2 -3';
+ERROR HY000: Could not parse GTID list for GTID_POS
+SET GLOBAL gtid_pos= '1-2-3 ';
+ERROR HY000: Could not parse GTID list for GTID_POS
+SET GLOBAL gtid_pos= '1-2-3,2-4';
+ERROR HY000: Could not parse GTID list for GTID_POS
+SET GLOBAL gtid_pos= '0-1-10,0-2-20';
+ERROR HY000: GTID 0-2-20 and 0-1-10 conflict (duplicate domain id 0)
+SET GLOBAL gtid_pos= '0-1-10,1-2-20,2-3-30,1-20-200,3-4-1';
+ERROR HY000: GTID 1-20-200 and 1-2-20 conflict (duplicate domain id 1)
+SET gtid_pos= '';
+ERROR HY000: Variable 'gtid_pos' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION gtid_pos= '';
+ERROR HY000: Variable 'gtid_pos' is a GLOBAL variable and should be set with SET GLOBAL
+SET GLOBAL gtid_pos= '1-2-3,2-4-6';
+SELECT @@gtid_pos;
+@@gtid_pos
+1-2-3,2-4-6
+SET GLOBAL gtid_pos= DEFAULT;
+ERROR 42000: Variable 'gtid_pos' doesn't have a default value
+SELECT @@session.gtid_pos;
+ERROR HY000: Variable 'gtid_pos' is a GLOBAL variable
+SET GLOBAL gtid_pos= @old_gtid_pos;
diff --git a/mysql-test/suite/sys_vars/t/gtid_pos_basic.test b/mysql-test/suite/sys_vars/t/gtid_pos_basic.test
new file mode 100644
index 00000000000..32cb27b0fa9
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/gtid_pos_basic.test
@@ -0,0 +1,44 @@
+SET @old_gtid_pos= @@gtid_pos;
+
+SET GLOBAL gtid_pos= '';
+SELECT @@gtid_pos;
+SET GLOBAL gtid_pos= '1-2-3';
+SELECT variable_value FROM information_schema.global_variables
+ WHERE variable_name='gtid_pos';
+SET @@global.gtid_pos= '1-2-4';
+SELECT @@gtid_pos;
+
+SET GLOBAL gtid_pos= ' 1-2-3';
+SELECT @@gtid_pos;
+SET GLOBAL gtid_pos= '1-2-3, 2-4-6';
+SELECT @@gtid_pos;
+
+--error ER_INCORRECT_GTID_STATE
+SET GLOBAL gtid_pos= '-1-2-3';
+--error ER_INCORRECT_GTID_STATE
+SET GLOBAL gtid_pos= '1-2 -3';
+--error ER_INCORRECT_GTID_STATE
+SET GLOBAL gtid_pos= '1-2-3 ';
+--error ER_INCORRECT_GTID_STATE
+SET GLOBAL gtid_pos= '1-2-3,2-4';
+
+--error ER_DUPLICATE_GTID_DOMAIN
+SET GLOBAL gtid_pos= '0-1-10,0-2-20';
+--error ER_DUPLICATE_GTID_DOMAIN
+SET GLOBAL gtid_pos= '0-1-10,1-2-20,2-3-30,1-20-200,3-4-1';
+
+--error ER_GLOBAL_VARIABLE
+SET gtid_pos= '';
+--error ER_GLOBAL_VARIABLE
+SET SESSION gtid_pos= '';
+
+SET GLOBAL gtid_pos= '1-2-3,2-4-6';
+SELECT @@gtid_pos;
+
+--error ER_NO_DEFAULT
+SET GLOBAL gtid_pos= DEFAULT;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.gtid_pos;
+
+SET GLOBAL gtid_pos= @old_gtid_pos;
diff --git a/sql/lex.h b/sql/lex.h
index 9883dfaf94d..edf833021b0 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -330,7 +330,7 @@ static SYMBOL symbols[] = {
{ "LOW_PRIORITY", SYM(LOW_PRIORITY)},
{ "MASTER", SYM(MASTER_SYM)},
{ "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_GTID_POS", SYM(MASTER_GTID_POS_SYM)},
+ { "MASTER_USE_GTID", SYM(MASTER_USE_GTID_SYM)},
{ "MASTER_HOST", SYM(MASTER_HOST_SYM)},
{ "MASTER_LOG_FILE", SYM(MASTER_LOG_FILE_SYM)},
{ "MASTER_LOG_POS", SYM(MASTER_LOG_POS_SYM)},
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 3ee66ae2a7a..ca62ed67ac1 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -6603,7 +6603,7 @@ ER_SLAVE_STOPPED
ER_FAILED_GTID_STATE_INIT
eng "Failed initializing replication GTID state"
ER_INCORRECT_GTID_STATE
- eng "Could not parse GTID list for MASTER_GTID_POS"
+ eng "Could not parse GTID list for GTID_POS"
ER_CANNOT_UPDATE_GTID_STATE
eng "Could not update replication slave gtid state"
ER_DUPLICATE_GTID_DOMAIN
@@ -6616,6 +6616,6 @@ ER_GTID_POSITION_NOT_FOUND_IN_BINLOG
ER_CANNOT_LOAD_SLAVE_GTID_STATE
eng "Failed to load replication slave GTID state from table %s.%s"
ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
- eng "Requested MASTER_GTID_POS %u-%u-%llu conflicts with the binary log which contains a more recent GTID %u-%u-%llu. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog"
+ eng "Requested GTID_POS %u-%u-%llu conflicts with the binary log which contains a more recent GTID %u-%u-%llu. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog"
ER_MASTER_GTID_POS_MISSING_DOMAIN
- eng "Requested MASTER_GTID_POS contains no value for replication domain %u. This conflicts with the binary log which contains GTID %u-%u-%llu. To use the requested MASTER_GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog"
+ eng "Requested GTID_POS contains no value for replication domain %u. This conflicts with the binary log which contains GTID %u-%u-%llu. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog"
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index f83df69a935..507c57f4325 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -290,8 +290,6 @@ struct LEX_MASTER_INFO
char *relay_log_name;
LEX_STRING connection_name;
ulonglong pos;
- LEX_STRING gtid_pos_str;
- bool gtid_pos_auto;
ulong relay_log_pos;
ulong server_id;
uint port, connect_retry;
@@ -301,7 +299,8 @@ struct LEX_MASTER_INFO
changed variable or if it should be left at old value
*/
enum {LEX_MI_UNCHANGED, LEX_MI_DISABLE, LEX_MI_ENABLE}
- ssl, ssl_verify_server_cert, heartbeat_opt, repl_ignore_server_ids_opt;
+ ssl, ssl_verify_server_cert, heartbeat_opt, repl_ignore_server_ids_opt,
+ use_gtid_opt;
void init()
{
@@ -315,12 +314,9 @@ struct LEX_MASTER_INFO
host= user= password= log_file_name= ssl_key= ssl_cert= ssl_ca=
ssl_capath= ssl_cipher= relay_log_name= 0;
pos= relay_log_pos= server_id= port= connect_retry= 0;
- gtid_pos_str.str= NULL;
- gtid_pos_str.length= 0;
- gtid_pos_auto= FALSE;
heartbeat_period= 0;
ssl= ssl_verify_server_cert= heartbeat_opt=
- repl_ignore_server_ids_opt= LEX_MI_UNCHANGED;
+ repl_ignore_server_ids_opt= use_gtid_opt= LEX_MI_UNCHANGED;
}
};
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index ad5e5f64dad..c2fcf67fc21 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -2503,7 +2503,6 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
char relay_log_info_file_tmp[FN_REFLEN];
my_off_t saved_log_pos;
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
- slave_connection_state tmp_slave_state;
DBUG_ENTER("change_master");
*master_info_added= false;
@@ -2534,78 +2533,6 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
goto err;
}
- if (lex_mi->gtid_pos_str.str)
- {
- if (master_info_index->give_error_if_slave_running())
- {
- ret= TRUE;
- goto err;
- }
- /*
- First load it into a dummy object, to check for parse errors.
- We do not want to wipe the previous state if there is an error
- in the syntax of the new state!
- */
- if (tmp_slave_state.load(lex_mi->gtid_pos_str.str,
- lex_mi->gtid_pos_str.length))
- {
- ret= TRUE;
- goto err;
- }
-
- /*
- Check our own binlog for any of our own transactions that are newer
- than the GTID state the user is requesting. Any such transactions would
- result in an out-of-order binlog, which could break anyone replicating
- with us as master.
-
- So give an error if this is found, requesting the user to do a
- RESET MASTER (to clean up the binlog) if they really want this.
- */
- if (mysql_bin_log.is_open())
- {
- rpl_gtid *binlog_gtid_list= NULL;
- uint32 num_binlog_gtids= 0;
- uint32 i;
-
- if (mysql_bin_log.get_most_recent_gtid_list(&binlog_gtid_list,
- &num_binlog_gtids))
- {
- my_error(ER_OUT_OF_RESOURCES, MYF(MY_WME));
- ret= TRUE;
- goto err;
- }
- for (i= 0; i < num_binlog_gtids; ++i)
- {
- rpl_gtid *binlog_gtid= &binlog_gtid_list[i];
- rpl_gtid *slave_gtid;
- if (binlog_gtid->server_id != global_system_variables.server_id)
- continue;
- if (!(slave_gtid= tmp_slave_state.find(binlog_gtid->domain_id)))
- {
- my_error(ER_MASTER_GTID_POS_MISSING_DOMAIN, MYF(0),
- binlog_gtid->domain_id, binlog_gtid->domain_id,
- binlog_gtid->server_id, binlog_gtid->seq_no);
- break;
- }
- if (slave_gtid->seq_no < binlog_gtid->seq_no)
- {
- my_error(ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG, MYF(0),
- slave_gtid->domain_id, slave_gtid->server_id,
- slave_gtid->seq_no, binlog_gtid->domain_id,
- binlog_gtid->server_id, binlog_gtid->seq_no);
- break;
- }
- }
- my_free(binlog_gtid_list);
- if (i != num_binlog_gtids)
- {
- ret= TRUE;
- goto err;
- }
- }
- }
-
thd_proc_info(thd, "Changing master");
create_logfile_name_with_suffix(master_info_file_tmp,
@@ -2771,9 +2698,9 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
mi->rli.group_relay_log_pos= mi->rli.event_relay_log_pos= lex_mi->relay_log_pos;
}
- if (lex_mi->gtid_pos_auto || lex_mi->gtid_pos_str.str)
+ if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_MI_ENABLE)
mi->using_gtid= true;
- else if (lex_mi->gtid_pos_str.str ||
+ else if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_MI_DISABLE ||
lex_mi->log_file_name || lex_mi->pos ||
lex_mi->relay_log_name || lex_mi->relay_log_pos)
mi->using_gtid= false;
@@ -2809,17 +2736,6 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
sizeof(mi->master_log_name)-1);
}
- if (lex_mi->gtid_pos_str.str)
- {
- if (rpl_global_gtid_slave_state.load(thd, lex_mi->gtid_pos_str.str,
- lex_mi->gtid_pos_str.length, true))
- {
- my_error(ER_FAILED_GTID_STATE_INIT, MYF(0));
- ret= TRUE;
- goto err;
- }
- }
-
/*
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
a slave before).
@@ -3386,4 +3302,78 @@ rpl_append_gtid_state(String *dest, bool use_binlog)
}
+bool
+rpl_gtid_pos_check(char *str, size_t len)
+{
+ slave_connection_state tmp_slave_state;
+
+ /* Check that we can parse the supplied string. */
+ if (tmp_slave_state.load(str, len))
+ return true;
+
+ /*
+ Check our own binlog for any of our own transactions that are newer
+ than the GTID state the user is requesting. Any such transactions would
+ result in an out-of-order binlog, which could break anyone replicating
+ with us as master.
+
+ So give an error if this is found, requesting the user to do a
+ RESET MASTER (to clean up the binlog) if they really want this.
+ */
+ if (mysql_bin_log.is_open())
+ {
+ rpl_gtid *binlog_gtid_list= NULL;
+ uint32 num_binlog_gtids= 0;
+ uint32 i;
+
+ if (mysql_bin_log.get_most_recent_gtid_list(&binlog_gtid_list,
+ &num_binlog_gtids))
+ {
+ my_error(ER_OUT_OF_RESOURCES, MYF(MY_WME));
+ return true;
+ }
+ for (i= 0; i < num_binlog_gtids; ++i)
+ {
+ rpl_gtid *binlog_gtid= &binlog_gtid_list[i];
+ rpl_gtid *slave_gtid;
+ if (binlog_gtid->server_id != global_system_variables.server_id)
+ continue;
+ if (!(slave_gtid= tmp_slave_state.find(binlog_gtid->domain_id)))
+ {
+ my_error(ER_MASTER_GTID_POS_MISSING_DOMAIN, MYF(0),
+ binlog_gtid->domain_id, binlog_gtid->domain_id,
+ binlog_gtid->server_id, binlog_gtid->seq_no);
+ break;
+ }
+ if (slave_gtid->seq_no < binlog_gtid->seq_no)
+ {
+ my_error(ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG, MYF(0),
+ slave_gtid->domain_id, slave_gtid->server_id,
+ slave_gtid->seq_no, binlog_gtid->domain_id,
+ binlog_gtid->server_id, binlog_gtid->seq_no);
+ break;
+ }
+ }
+ my_free(binlog_gtid_list);
+ if (i != num_binlog_gtids)
+ return true;
+ }
+
+ return false;
+}
+
+
+bool
+rpl_gtid_pos_update(THD *thd, char *str, size_t len)
+{
+ if (rpl_global_gtid_slave_state.load(thd, str, len, true))
+ {
+ my_error(ER_FAILED_GTID_STATE_INIT, MYF(0));
+ return true;
+ }
+ else
+ return false;
+}
+
+
#endif /* HAVE_REPLICATION */
diff --git a/sql/sql_repl.h b/sql/sql_repl.h
index 22183f2a2b2..3af8f721bd7 100644
--- a/sql/sql_repl.h
+++ b/sql/sql_repl.h
@@ -70,6 +70,8 @@ void rpl_init_gtid_slave_state();
void rpl_deinit_gtid_slave_state();
int gtid_state_from_binlog_pos(const char *name, uint32 pos, String *out_str);
int rpl_append_gtid_state(String *dest, bool use_binlog);
+bool rpl_gtid_pos_check(char *str, size_t len);
+bool rpl_gtid_pos_update(THD *thd, char *str, size_t len);
#endif /* HAVE_REPLICATION */
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 5bd02c39231..49900edbfd3 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1095,7 +1095,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token LOW_PRIORITY
%token LT /* OPERATOR */
%token MASTER_CONNECT_RETRY_SYM
-%token MASTER_GTID_POS_SYM
+%token MASTER_USE_GTID_SYM
%token MASTER_HOST_SYM
%token MASTER_LOG_FILE_SYM
%token MASTER_LOG_POS_SYM
@@ -2060,23 +2060,15 @@ master_file_def:
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
}
- | MASTER_GTID_POS_SYM EQ TEXT_STRING_sys
+ | MASTER_USE_GTID_SYM EQ ulong_num
{
- if (Lex->mi.gtid_pos_str.str || Lex->mi.gtid_pos_auto)
+ if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
{
- my_error(ER_DUP_ARGUMENT, MYF(0), "MASTER_GTID_POS");
+ my_error(ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid");
MYSQL_YYABORT;
}
- Lex->mi.gtid_pos_str = $3;
- }
- | MASTER_GTID_POS_SYM EQ AUTO_SYM
- {
- if (Lex->mi.gtid_pos_str.str || Lex->mi.gtid_pos_auto)
- {
- my_error(ER_DUP_ARGUMENT, MYF(0), "MASTER_GTID_POS");
- MYSQL_YYABORT;
- }
- Lex->mi.gtid_pos_auto = true;
+ Lex->mi.use_gtid_opt= $3 ?
+ LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
;
@@ -13313,7 +13305,7 @@ keyword_sp:
| MAX_ROWS {}
| MASTER_SYM {}
| MASTER_HEARTBEAT_PERIOD_SYM {}
- | MASTER_GTID_POS_SYM {}
+ | MASTER_USE_GTID_SYM {}
| MASTER_HOST_SYM {}
| MASTER_PORT_SYM {}
| MASTER_LOG_FILE_SYM {}
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index d37fa869042..a9e7b38155f 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -55,6 +55,7 @@
#include "../storage/perfschema/pfs_server.h"
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
#include "threadpool.h"
+#include "sql_repl.h"
/*
The rule for this file: everything should be 'static'. When a sys_var
@@ -1224,6 +1225,91 @@ static Sys_var_ulonglong Sys_gtid_seq_no(
BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_has_super));
+
+#ifdef HAVE_REPLICATION
+bool
+Sys_var_gtid_pos::do_check(THD *thd, set_var *var)
+{
+ String str, *res;
+ bool running;
+
+ DBUG_ASSERT(var->type == OPT_GLOBAL);
+ mysql_mutex_lock(&LOCK_active_mi);
+ running= master_info_index->give_error_if_slave_running();
+ mysql_mutex_unlock(&LOCK_active_mi);
+ if (running)
+ return true;
+ if (!(res= var->value->val_str(&str)))
+ return true;
+ if (rpl_gtid_pos_check(&((*res)[0]), res->length()))
+ return true;
+
+ if (!(var->save_result.string_value.str=
+ thd->strmake(res->ptr(), res->length())))
+ {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
+ return true;
+ }
+ var->save_result.string_value.length= res->length();
+ return false;
+}
+
+
+bool
+Sys_var_gtid_pos::global_update(THD *thd, set_var *var)
+{
+ bool err;
+
+ DBUG_ASSERT(var->type == OPT_GLOBAL);
+
+ if (!var->value)
+ {
+ my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
+ return true;
+ }
+
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_lock(&LOCK_active_mi);
+ if (master_info_index->give_error_if_slave_running())
+ err= true;
+ else
+ err= rpl_gtid_pos_update(thd, var->save_result.string_value.str,
+ var->save_result.string_value.length);
+ mysql_mutex_unlock(&LOCK_active_mi);
+ mysql_mutex_lock(&LOCK_global_system_variables);
+ return err;
+}
+
+
+uchar *
+Sys_var_gtid_pos::global_value_ptr(THD *thd, LEX_STRING *base)
+{
+ String str;
+ char *p;
+
+ str.length(0);
+ if (rpl_append_gtid_state(&str, true) ||
+ !(p= thd->strmake(str.ptr(), str.length())))
+ {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
+ return NULL;
+ }
+
+ return (uchar *)p;
+}
+
+
+static unsigned char opt_gtid_pos_dummy;
+static Sys_var_gtid_pos Sys_gtid_pos(
+ "gtid_pos",
+ "The list of global transaction IDs that were last replicated on the "
+ "server, one for each replication domain. This defines where a slave "
+ "starts replicating from on a master when connecting with global "
+ "transaction ID.",
+ GLOBAL_VAR(opt_gtid_pos_dummy), NO_CMD_LINE);
+#endif
+
+
static bool fix_max_join_size(sys_var *self, THD *thd, enum_var_type type)
{
SV *sv= type == OPT_GLOBAL ? &global_system_variables : &thd->variables;
diff --git a/sql/sys_vars.h b/sql/sys_vars.h
index 1729dcefd63..c1f994de860 100644
--- a/sql/sys_vars.h
+++ b/sql/sys_vars.h
@@ -2021,3 +2021,43 @@ public:
}
};
+
+/**
+ Class for @@global.gtid_pos.
+*/
+class Sys_var_gtid_pos: public sys_var
+{
+public:
+ Sys_var_gtid_pos(const char *name_arg,
+ const char *comment, int flag_args, ptrdiff_t off, size_t size,
+ CMD_LINE getopt)
+ : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
+ getopt.arg_type, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG,
+ NULL, NULL, NULL)
+ {
+ option.var_type= GET_STR;
+ }
+ bool do_check(THD *thd, set_var *var);
+ bool session_update(THD *thd, set_var *var)
+ {
+ DBUG_ASSERT(false);
+ return true;
+ }
+ bool global_update(THD *thd, set_var *var);
+ bool check_update_type(Item_result type) { return type != STRING_RESULT; }
+ void session_save_default(THD *thd, set_var *var)
+ {
+ DBUG_ASSERT(false);
+ }
+ void global_save_default(THD *thd, set_var *var)
+ {
+ /* Record the attempt to use default so we can error. */
+ var->value= 0;
+ }
+ uchar *session_value_ptr(THD *thd, LEX_STRING *base)
+ {
+ DBUG_ASSERT(false);
+ return NULL;
+ }
+ uchar *global_value_ptr(THD *thd, LEX_STRING *base);
+};