1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-30189 Add remaining replication options as system variables

Promote the last few SQL-inaccessible replication options (command line
or `mariadb.cnf`) as these GLOBAL read-only system variables:
```
@@master_info_file
@@replicate_same_server_id
@@show_slave_auth_info
```

Side effect: The latter two options changed from no argument
to optional argument. Quote `include/my_getopt.h`:
> It should be noted that for historical reasons variables with the
> combination arg_type=NO_ARG, my_option::var_type=GET_BOOL still
> accepts arguments. This is someone counter intuitive and care should
> be taken if the code is refactored.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
This commit is contained in:
ParadoxV5
2025-03-11 22:48:54 -06:00
parent 74c189c312
commit c29e83f226
12 changed files with 162 additions and 18 deletions

View File

@@ -0,0 +1,17 @@
# GLOBAL scope
SELECT @@GLOBAL.master_info_file;
@@GLOBAL.master_info_file
30189.info
SELECT @@master_info_file;
@@master_info_file
30189.info
# Not SESSION scope
SELECT @@SESSION.master_info_file;
ERROR HY000: Variable 'master_info_file' is a GLOBAL variable
# Read-only
SET @@master_info_file= 'master.info';
ERROR HY000: Variable 'master_info_file' is a read only variable
SET @@GLOBAL.master_info_file= 'master.info';
ERROR HY000: Variable 'master_info_file' is a read only variable
SET @@SESSION.master_info_file= 'master.info';
ERROR HY000: Variable 'master_info_file' is a read only variable

View File

@@ -0,0 +1,17 @@
# GLOBAL scope
SELECT @@GLOBAL.replicate_same_server_id;
@@GLOBAL.replicate_same_server_id
1
SELECT @@replicate_same_server_id;
@@replicate_same_server_id
1
# Not SESSION scope
SELECT @@SESSION.replicate_same_server_id;
ERROR HY000: Variable 'replicate_same_server_id' is a GLOBAL variable
# Read-only
SET @@replicate_same_server_id= OFF;
ERROR HY000: Variable 'replicate_same_server_id' is a read only variable
SET @@GLOBAL.replicate_same_server_id= OFF;
ERROR HY000: Variable 'replicate_same_server_id' is a read only variable
SET @@SESSION.replicate_same_server_id= OFF;
ERROR HY000: Variable 'replicate_same_server_id' is a read only variable

View File

@@ -0,0 +1,17 @@
# GLOBAL scope
SELECT @@GLOBAL.show_slave_auth_info;
@@GLOBAL.show_slave_auth_info
1
SELECT @@show_slave_auth_info;
@@show_slave_auth_info
1
# Not SESSION scope
SELECT @@SESSION.show_slave_auth_info;
ERROR HY000: Variable 'show_slave_auth_info' is a GLOBAL variable
# Read-only
SET @@show_slave_auth_info= OFF;
ERROR HY000: Variable 'show_slave_auth_info' is a read only variable
SET @@GLOBAL.show_slave_auth_info= OFF;
ERROR HY000: Variable 'show_slave_auth_info' is a read only variable
SET @@SESSION.show_slave_auth_info= OFF;
ERROR HY000: Variable 'show_slave_auth_info' is a read only variable

View File

@@ -2072,6 +2072,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON ENUM_VALUE_LIST OFF,ON
READ_ONLY NO READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME MASTER_INFO_FILE
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT The location and name of the file that remembers the master and where the I/O replication thread is in the master's binlogs. Defaults to master.info
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME MASTER_VERIFY_CHECKSUM VARIABLE_NAME MASTER_VERIFY_CHECKSUM
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN VARIABLE_TYPE BOOLEAN
@@ -3752,6 +3762,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
READ_ONLY NO READ_ONLY NO
COMMAND_LINE_ARGUMENT NULL COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME REPLICATE_SAME_SERVER_ID
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT In replication, if set to 1, do not skip events having our server id. Default value is 0 (to break infinite loops in circular replication). Can't be set to 1 if --log-slave-updates is used
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME REPLICATE_WILD_DO_TABLE VARIABLE_NAME REPLICATE_WILD_DO_TABLE
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR VARIABLE_TYPE VARCHAR
@@ -4012,6 +4032,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,STATE,CHARACTERISTICS ENUM_VALUE_LIST OFF,STATE,CHARACTERISTICS
READ_ONLY NO READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME SHOW_SLAVE_AUTH_INFO
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Show user and password in SHOW SLAVE HOSTS on this master
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME SKIP_EXTERNAL_LOCKING VARIABLE_NAME SKIP_EXTERNAL_LOCKING
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN VARIABLE_TYPE BOOLEAN

View File

@@ -0,0 +1 @@
--master-info-file='30189.info'

View File

@@ -0,0 +1,19 @@
--source include/not_embedded.inc
# MDEV-30189: Test minimal correctness of `@@master_info_file` itself
--echo # GLOBAL scope
# Expect different from default ('master.info') as configured by `.opt`
SELECT @@GLOBAL.master_info_file;
SELECT @@master_info_file;
--echo # Not SESSION scope
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@SESSION.master_info_file;
--echo # Read-only
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@master_info_file= 'master.info';
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.master_info_file= 'master.info';
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@SESSION.master_info_file= 'master.info';

View File

@@ -0,0 +1 @@
--replicate-same-server-id

View File

@@ -0,0 +1,19 @@
--source include/not_embedded.inc
# MDEV-30189: Test minimal correctness of `@@replicate_same_server_id` itself
--echo # GLOBAL scope
# Expect different from default (OFF) as configured by `.opt`
SELECT @@GLOBAL.replicate_same_server_id;
SELECT @@replicate_same_server_id;
--echo # Not SESSION scope
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@SESSION.replicate_same_server_id;
--echo # Read-only
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@replicate_same_server_id= OFF;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.replicate_same_server_id= OFF;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@SESSION.replicate_same_server_id= OFF;

View File

@@ -0,0 +1 @@
--show-slave-auth-info

View File

@@ -0,0 +1,19 @@
--source include/not_embedded.inc
# MDEV-30189: Test minimal correctness of `@@show_slave_auth_info` itself
--echo # GLOBAL scope
# Expect different from default (OFF) as configured by `.opt`
SELECT @@GLOBAL.show_slave_auth_info;
SELECT @@show_slave_auth_info;
--echo # Not SESSION scope
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@SESSION.show_slave_auth_info;
--echo # Read-only
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@show_slave_auth_info= OFF;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.show_slave_auth_info= OFF;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@SESSION.show_slave_auth_info= OFF;

View File

@@ -6818,12 +6818,6 @@ struct my_option my_long_options[]=
"more than one storage engine, when binary log is disabled)", "more than one storage engine, when binary log is disabled)",
&opt_tc_log_file, &opt_tc_log_file, 0, GET_STR, &opt_tc_log_file, &opt_tc_log_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"master-info-file", 0,
"The location and name of the file that remembers the master and where "
"the I/O replication thread is in the master's binlogs. Defaults to "
"master.info",
&master_info_file, &master_info_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"master-retry-count", 0, {"master-retry-count", 0,
"The number of tries the slave will make to connect to the master before giving up", "The number of tries the slave will make to connect to the master before giving up",
&master_retry_count, &master_retry_count, 0, GET_ULONG, &master_retry_count, &master_retry_count, 0, GET_ULONG,
@@ -6874,14 +6868,6 @@ struct my_option my_long_options[]=
"Updates to a database with a different name than the original. Example: " "Updates to a database with a different name than the original. Example: "
"replicate-rewrite-db=master_db_name->slave_db_name", "replicate-rewrite-db=master_db_name->slave_db_name",
0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_REPLICATION
{"replicate-same-server-id", 0,
"In replication, if set to 1, do not skip events having our server id. "
"Default value is 0 (to break infinite loops in circular replication). "
"Can't be set to 1 if --log-slave-updates is used",
&replicate_same_server_id, &replicate_same_server_id,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE, {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE,
"Tells the slave thread to restrict replication to the tables that match " "Tells the slave thread to restrict replication to the tables that match "
"the specified wildcard pattern. To specify more than one table, use the " "the specified wildcard pattern. To specify more than one table, use the "
@@ -6904,10 +6890,6 @@ struct my_option my_long_options[]=
"Don't allow new user creation by the user who has no write privileges to the mysql.user table", "Don't allow new user creation by the user who has no write privileges to the mysql.user table",
&opt_safe_user_create, &opt_safe_user_create, 0, GET_BOOL, &opt_safe_user_create, &opt_safe_user_create, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"show-slave-auth-info", 0,
"Show user and password in SHOW SLAVE HOSTS on this master",
&opt_show_slave_auth_info, &opt_show_slave_auth_info, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"silent-startup", OPT_SILENT, "Don't print [Note] to the error log during startup", {"silent-startup", OPT_SILENT, "Don't print [Note] to the error log during startup",
&opt_silent_startup, &opt_silent_startup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, &opt_silent_startup, &opt_silent_startup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0, {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0,

View File

@@ -5306,6 +5306,12 @@ static Sys_var_uint Sys_repl_report_port(
"to the slave. If not sure, leave this option unset", "to the slave. If not sure, leave this option unset",
READ_ONLY GLOBAL_VAR(report_port), CMD_LINE(REQUIRED_ARG), READ_ONLY GLOBAL_VAR(report_port), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
static Sys_var_mybool Sys_show_slave_auth_info(
"show_slave_auth_info",
"Show user and password in SHOW SLAVE HOSTS on this master",
READ_ONLY GLOBAL_VAR(opt_show_slave_auth_info), CMD_LINE(OPT_ARG),
DEFAULT(FALSE));
#endif #endif
static Sys_var_mybool Sys_keep_files_on_create( static Sys_var_mybool Sys_keep_files_on_create(
@@ -5706,6 +5712,13 @@ static Sys_var_charptr_fscs Sys_relay_log_info_file(
READ_ONLY GLOBAL_VAR(relay_log_info_file), CMD_LINE(REQUIRED_ARG), READ_ONLY GLOBAL_VAR(relay_log_info_file), CMD_LINE(REQUIRED_ARG),
DEFAULT(0)); DEFAULT(0));
static Sys_var_charptr_fscs Sys_master_info_file(
"master_info_file", "The location and name of the file that "
"remembers the master and where the I/O replication thread "
"is in the master's binlogs. Defaults to master.info",
READ_ONLY GLOBAL_VAR(master_info_file), CMD_LINE(REQUIRED_ARG),
DEFAULT(0));
static Sys_var_on_access_global<Sys_var_mybool, static Sys_var_on_access_global<Sys_var_mybool,
PRIV_SET_SYSTEM_GLOBAL_VAR_RELAY_LOG_PURGE> PRIV_SET_SYSTEM_GLOBAL_VAR_RELAY_LOG_PURGE>
Sys_relay_log_purge( Sys_relay_log_purge(
@@ -6979,6 +6992,14 @@ static Sys_var_mybool Sys_replicate_annotate_row_events(
"to its own binary log. Ignored if log_slave_updates is not set", "to its own binary log. Ignored if log_slave_updates is not set",
READ_ONLY GLOBAL_VAR(opt_replicate_annotate_row_events), READ_ONLY GLOBAL_VAR(opt_replicate_annotate_row_events),
CMD_LINE(OPT_ARG), DEFAULT(TRUE)); CMD_LINE(OPT_ARG), DEFAULT(TRUE));
static Sys_var_mybool Sys_replicate_same_server_id(
"replicate_same_server_id",
"In replication, if set to 1, do not skip events having our server id. "
"Default value is 0 (to break infinite loops in circular replication). "
"Can't be set to 1 if --log-slave-updates is used",
READ_ONLY GLOBAL_VAR(replicate_same_server_id),
CMD_LINE(OPT_ARG), DEFAULT(FALSE));
#endif #endif
static Sys_var_ulonglong Sys_join_buffer_space_limit( static Sys_var_ulonglong Sys_join_buffer_space_limit(