Skip to content
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
2 changes: 1 addition & 1 deletion libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/field.cc ../sql/field_conv.cc ../sql/field_comp.cc
../sql/filesort_utils.cc ../sql/sql_digest.cc
../sql/filesort.cc ../sql/grant.cc
../sql/gstream.cc ../sql/slave.cc
../sql/gstream.cc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when moving these functions to mysys, don't forget to remove slave.cc from libmysqld/CMakeLists.txt
init_intvar_from_file()’s code documentation

../sql/signal_handler.cc
../sql/handler.cc ../sql/hash_filo.cc ../sql/hostname.cc
../sql/init.cc ../sql/item_buff.cc ../sql/item_cmpfunc.cc
Expand Down
266 changes: 266 additions & 0 deletions mysql-test/main/change_master_default.result
Copy link
Contributor Author

@ParadoxV5 ParadoxV5 Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question for the future (no need to answer immediately):
Should other fields (the ones not listed) “recognize” the DEFAULT keyword as well?

Fields with trivial DEFAULTs

  • [P.S.] source name (the filename of the info files): Not specifying a name already means DEFAULT, which is @@SESSION.default_master_connection, whose default is empty.
  • Primary & Relay File/Pos:
    • MASTER_LOG_FILE: DEFAULT is empty, and empty means “first”.
    • MASTER_LOG_POS/RELAY_LOG_POS: DEFAULT is 4
      • silently set to DEFAULT if set to less
    • ignored with a warning when using GTID
  • MASTER_PORT: DEFAULT is the MariaDB port
    • 0 is (technically) invalid.
  • IGNORE_SERVER_IDS/DO_DOMAIN_IDS/IGNORE_DOMAIN_IDS: DEFAULT is empty.
  • MASTER_DELAY: DEFAULT is 0.
    • int32_t on paper, unsigned in practice: errors if set larger than MASTER_DELAY_MAX (0x7F'FF'FF'FF)

No DEFAULT – “recognizes” as an error

Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
# Start of main.change_master_default
CREATE PROCEDURE show_defaultable_fields()
SELECT connection_name,
connect_retry,
master_ssl_allowed,
master_ssl_ca_file,
master_ssl_ca_path,
master_ssl_cert,
master_ssl_cipher,
master_ssl_key,
`master_ssl_verify_server_cert`, # MDEV-38194
master_ssl_crl,
master_ssl_crlpath,
using_gtid,
master_retry_count,
slave_heartbeat_period
FROM information_schema.slave_status ORDER BY connection_name;
CHANGE MASTER 'unset' TO master_host='127.0.1.1';
CHANGE MASTER 'defaulted' TO
master_connect_retry= DEFAULT,
master_ssl= DEFAULT,
master_ssl_ca= DEFAULT,
master_ssl_capath= DEFAULT,
master_ssl_cert= DEFAULT,
master_ssl_cipher= DEFAULT,
master_ssl_key= DEFAULT,
master_ssl_verify_server_cert= DEFAULT,
master_ssl_crl= DEFAULT,
master_ssl_crlpath= DEFAULT,
master_use_gtid= DEFAULT,
master_retry_count= DEFAULT,
master_heartbeat_period= DEFAULT,
master_host= '127.0.1.2';
CHANGE MASTER TO # Default master does not replace named masters
master_connect_retry= 90,
master_ssl= FALSE,
master_ssl_ca= 'specified_ca',
master_ssl_capath= 'specified_capath',
master_ssl_cert= 'specified_cert',
master_ssl_cipher= 'specified_cipher',
master_ssl_key= 'specified_key',
master_ssl_verify_server_cert= FALSE,
master_ssl_crl= 'specified_crl',
master_ssl_crlpath= 'specified_crlpath',
master_use_gtid= NO,
master_retry_count= 150000,
master_heartbeat_period= 45,
master_host='127.0.0.1';
CALL show_defaultable_fields();
connection_name
connect_retry 90
master_ssl_allowed No
master_ssl_ca_file specified_ca
master_ssl_ca_path specified_capath
master_ssl_cert specified_cert
master_ssl_cipher specified_cipher
master_ssl_key specified_key
master_ssl_verify_server_cert No
master_ssl_crl specified_crl
master_ssl_crlpath specified_crlpath
using_gtid No
master_retry_count 150000
slave_heartbeat_period 45.000
connection_name defaulted
connect_retry 60
master_ssl_allowed Yes
master_ssl_ca_file
master_ssl_ca_path
master_ssl_cert
master_ssl_cipher
master_ssl_key
master_ssl_verify_server_cert Yes
master_ssl_crl
master_ssl_crlpath
using_gtid Slave_Pos
master_retry_count 100000
slave_heartbeat_period 60.000
connection_name unset
connect_retry 60
master_ssl_allowed Yes
master_ssl_ca_file
master_ssl_ca_path
master_ssl_cert
master_ssl_cipher
master_ssl_key
master_ssl_verify_server_cert Yes
master_ssl_crl
master_ssl_crlpath
using_gtid Slave_Pos
master_retry_count 100000
slave_heartbeat_period 60.000
# Those set or left as `DEFAULT` should pick up changes to defaults.
# restart: --skip-slave-start --master-connect-retry=30 --skip-master-ssl --master-ssl-ca=default_ca --master-ssl-capath=default_capath --master-ssl-cert=default_cert --master-ssl-cipher=default_cipher --master-ssl-key=default_key --skip-master-ssl-verify-server-cert --master-ssl-crl=default_crl --master-ssl-crlpath=default_crlpath --master-use-gtid=CURRENT_POS --master-retry-count=50000 --master-heartbeat-period=15
CALL show_defaultable_fields();
connection_name
connect_retry 90
master_ssl_allowed No
master_ssl_ca_file specified_ca
master_ssl_ca_path specified_capath
master_ssl_cert specified_cert
master_ssl_cipher specified_cipher
master_ssl_key specified_key
master_ssl_verify_server_cert No
master_ssl_crl specified_crl
master_ssl_crlpath specified_crlpath
using_gtid No
master_retry_count 150000
slave_heartbeat_period 45.000
connection_name defaulted
connect_retry 30
master_ssl_allowed No
master_ssl_ca_file default_ca
master_ssl_ca_path default_capath
master_ssl_cert default_cert
master_ssl_cipher default_cipher
master_ssl_key default_key
master_ssl_verify_server_cert No
master_ssl_crl default_crl
master_ssl_crlpath default_crlpath
using_gtid Current_Pos
master_retry_count 50000
slave_heartbeat_period 15.000
connection_name unset
connect_retry 30
master_ssl_allowed No
master_ssl_ca_file default_ca
master_ssl_ca_path default_capath
master_ssl_cert default_cert
master_ssl_cipher default_cipher
master_ssl_key default_key
master_ssl_verify_server_cert No
master_ssl_crl default_crl
master_ssl_crlpath default_crlpath
using_gtid Current_Pos
master_retry_count 50000
slave_heartbeat_period 15.000
SET @@GLOBAL.slave_net_timeout= 100;
SELECT connection_name, slave_heartbeat_period
FROM information_schema.slave_status ORDER BY connection_name;
connection_name slave_heartbeat_period
45.000
defaulted 15.000
unset 15.000
CHANGE MASTER TO
master_connect_retry= DEFAULT,
master_ssl= DEFAULT,
master_ssl_ca= DEFAULT,
master_ssl_capath= DEFAULT,
master_ssl_cert= DEFAULT,
master_ssl_cipher= DEFAULT,
master_ssl_key= DEFAULT,
master_ssl_verify_server_cert= DEFAULT,
master_ssl_crl= DEFAULT,
master_ssl_crlpath= DEFAULT,
master_use_gtid= DEFAULT,
master_retry_count= DEFAULT,
master_heartbeat_period= DEFAULT;
CALL show_defaultable_fields();
connection_name
connect_retry 30
master_ssl_allowed No
master_ssl_ca_file default_ca
master_ssl_ca_path default_capath
master_ssl_cert default_cert
master_ssl_cipher default_cipher
master_ssl_key default_key
master_ssl_verify_server_cert No
master_ssl_crl default_crl
master_ssl_crlpath default_crlpath
using_gtid Current_Pos
master_retry_count 50000
slave_heartbeat_period 15.000
connection_name defaulted
connect_retry 30
master_ssl_allowed No
master_ssl_ca_file default_ca
master_ssl_ca_path default_capath
master_ssl_cert default_cert
master_ssl_cipher default_cipher
master_ssl_key default_key
master_ssl_verify_server_cert No
master_ssl_crl default_crl
master_ssl_crlpath default_crlpath
using_gtid Current_Pos
master_retry_count 50000
slave_heartbeat_period 15.000
connection_name unset
connect_retry 30
master_ssl_allowed No
master_ssl_ca_file default_ca
master_ssl_ca_path default_capath
master_ssl_cert default_cert
master_ssl_cipher default_cipher
master_ssl_key default_key
master_ssl_verify_server_cert No
master_ssl_crl default_crl
master_ssl_crlpath default_crlpath
using_gtid Current_Pos
master_retry_count 50000
slave_heartbeat_period 15.000
RESET REPLICA 'unset' ALL;
CHANGE MASTER 'unset' TO master_host='127.0.1.3';
# Validate command line options
# restart_abort: --master-heartbeat-period=''
# restart_abort: --master-heartbeat-period=123abc
# restart_abort: --master-heartbeat-period=-1
# restart_abort: --master-heartbeat-period=4294967.296
# restart: --skip-slave-start --master-heartbeat-period=0.000499
SELECT connection_name, slave_heartbeat_period
FROM information_schema.slave_status ORDER BY connection_name;
connection_name slave_heartbeat_period
0.000
defaulted 0.000
unset 0.000
CALL mtr.add_suppression('.*master-heartbeat-period.+0.*disabl.+');
FOUND 1 /\[Warning\] .*master-heartbeat-period.+0.*disabl.+/ in mysqld.1.err
# restart: --skip-slave-start --skip-master-ssl --master-ssl --skip-master-ssl-verify-server-cert --master-ssl-verify-server-cert --master-use-gtid=NO --autoset-master-use-gtid --master-heartbeat-period=45 --autoset-master-heartbeat-period
CALL show_defaultable_fields();
connection_name
connect_retry 60
master_ssl_allowed Yes
master_ssl_ca_file
master_ssl_ca_path
master_ssl_cert
master_ssl_cipher
master_ssl_key
master_ssl_verify_server_cert Yes
master_ssl_crl
master_ssl_crlpath
using_gtid Slave_Pos
master_retry_count 100000
slave_heartbeat_period 60.000
connection_name defaulted
connect_retry 60
master_ssl_allowed Yes
master_ssl_ca_file
master_ssl_ca_path
master_ssl_cert
master_ssl_cipher
master_ssl_key
master_ssl_verify_server_cert Yes
master_ssl_crl
master_ssl_crlpath
using_gtid Slave_Pos
master_retry_count 100000
slave_heartbeat_period 60.000
connection_name unset
connect_retry 60
master_ssl_allowed Yes
master_ssl_ca_file
master_ssl_ca_path
master_ssl_cert
master_ssl_cipher
master_ssl_key
master_ssl_verify_server_cert Yes
master_ssl_crl
master_ssl_crlpath
using_gtid Slave_Pos
master_retry_count 100000
slave_heartbeat_period 60.000
# Clean-up
DROP PROCEDURE show_defaultable_fields;
RESET REPLICA 'unset' ALL;
RESET REPLICA 'defaulted' ALL;
RESET REPLICA ALL;
# End of main.change_master_default
Loading