Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
#
# Test Case 1: No warning when Using_Gtid is already 'No' and
# explicitly setting master_use_gtid=NO
#
CHANGE MASTER TO master_use_gtid=NO;
# Using_Gtid should be 'No': No
CHANGE MASTER TO master_use_gtid=NO;
# No warning should appear above
#
# Test Case 2: No warning when Using_Gtid is already 'No' and
# setting relay_log_pos (which implicitly sets Using_Gtid to No)
#
CHANGE MASTER TO relay_log_pos=0;
# No warning should appear above
#
# Test Case 3: Warning IS shown when actually changing from
# Slave_Pos to No (via relay_log_pos)
#
CHANGE MASTER TO master_use_gtid=Slave_Pos;
# Using_Gtid should be 'Slave_Pos': Slave_Pos
CHANGE MASTER TO relay_log_pos=0;
Warnings:
Note 4190 CHANGE MASTER TO is implicitly changing the value of 'Using_Gtid' from 'Slave_Pos' to 'No'
# Warning 4190 should appear above about changing from 'Slave_Pos' to 'No'
#
# Cleanup
#
CHANGE MASTER TO master_use_gtid=NO;
include/start_slave.inc
include/rpl_end.inc
69 changes: 69 additions & 0 deletions mysql-test/suite/rpl/t/rpl_change_master_use_gtid_no_warning.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# MDEV-37842: Fix CHANGE_MASTER_TO warning message
#
# Purpose:
# Verify that CHANGE MASTER TO master_use_gtid=NO does not produce
# a spurious warning when Using_Gtid is already 'No'.
#
# The bug was that running:
# CHANGE MASTER TO master_use_gtid=NO;
# when Using_Gtid was already 'No' would produce:
# Note 4190 CHANGE MASTER TO is implicitly changing the value of
# 'Using_Gtid' from 'No' to 'No'
#
# This test verifies:
# 1. No warning when changing from No to No (explicit master_use_gtid=NO)
# 2. No warning when Using_Gtid is already No and relay_log_pos is set (which implicitly sets Using_Gtid to No)
# 3. Warning IS shown when actually changing from Slave_Pos to No
#

--source include/master-slave.inc

--connection slave
--source include/stop_slave.inc

--echo #
--echo # Test Case 1: No warning when Using_Gtid is already 'No' and
--echo # explicitly setting master_use_gtid=NO
--echo #

# First ensure Using_Gtid is No
CHANGE MASTER TO master_use_gtid=NO;
--let $using_gtid= query_get_value(SHOW SLAVE STATUS, Using_Gtid, 1)
--echo # Using_Gtid should be 'No': $using_gtid

# Now set it to NO again - should NOT produce warning 4190
CHANGE MASTER TO master_use_gtid=NO;
--echo # No warning should appear above

--echo #
--echo # Test Case 2: No warning when Using_Gtid is already 'No' and
--echo # setting relay_log_pos (which implicitly sets Using_Gtid to No)
--echo #

# Using_Gtid is still No from previous test
CHANGE MASTER TO relay_log_pos=0;
--echo # No warning should appear above

--echo #
--echo # Test Case 3: Warning IS shown when actually changing from
--echo # Slave_Pos to No (via relay_log_pos)
--echo #

# Set Using_Gtid to Slave_Pos first
CHANGE MASTER TO master_use_gtid=Slave_Pos;
--let $using_gtid= query_get_value(SHOW SLAVE STATUS, Using_Gtid, 1)
--echo # Using_Gtid should be 'Slave_Pos': $using_gtid

# Now set relay_log_pos which implicitly changes Using_Gtid to No
# This SHOULD produce warning 4190
CHANGE MASTER TO relay_log_pos=0;
--echo # Warning 4190 should appear above about changing from 'Slave_Pos' to 'No'

--echo #
--echo # Cleanup
--echo #
CHANGE MASTER TO master_use_gtid=NO;
--source include/start_slave.inc

--source include/rpl_end.inc
2 changes: 1 addition & 1 deletion sql/sql_repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3869,7 +3869,7 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
lex_mi->log_file_name || lex_mi->pos ||
lex_mi->relay_log_name || lex_mi->relay_log_pos)
{
if (lex_mi->use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_NO)
if (lex_mi->use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_NO && mi->using_gtid_astext(mi->using_gtid) != mi->using_gtid_astext(Master_info::USE_GTID_NO))
{
push_warning_printf(
thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_CHANGING,
Expand Down