diff options
35 files changed, 614 insertions, 14 deletions
diff --git a/mysql-test/r/flush2.result b/mysql-test/r/flush2.result index 13bcc371ef6..ff5d8755f01 100644 --- a/mysql-test/r/flush2.result +++ b/mysql-test/r/flush2.result @@ -3,10 +3,32 @@ set global expire_logs_days = 3; show variables like 'log_bin%'; Variable_name Value log_bin OFF +log_bin_basename +log_bin_index log_bin_trust_function_creators ON +show variables like 'relay_log%'; +Variable_name Value +relay_log mysqld-relay-bin +relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +relay_log_info_file relay-log.info +relay_log_purge ON +relay_log_recovery OFF +relay_log_space_limit 0 flush logs; show variables like 'log_bin%'; Variable_name Value log_bin OFF +log_bin_basename +log_bin_index log_bin_trust_function_creators ON +show variables like 'relay_log%'; +Variable_name Value +relay_log mysqld-relay-bin +relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +relay_log_info_file relay-log.info +relay_log_purge ON +relay_log_recovery OFF +relay_log_space_limit 0 set global expire_logs_days = 0; diff --git a/mysql-test/r/variables-notembedded.result b/mysql-test/r/variables-notembedded.result index 75fd2430e4b..f8191345219 100644 --- a/mysql-test/r/variables-notembedded.result +++ b/mysql-test/r/variables-notembedded.result @@ -44,19 +44,58 @@ ERROR HY000: Variable 'relay_log' is a read only variable SET @@global.relay_log= 'x'; ERROR HY000: Variable 'relay_log' is a read only variable # +SHOW VARIABLES like 'relay_log_basename'; +Variable_name Value +relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin +SELECT @@session.relay_log_basename; +ERROR HY000: Variable 'relay_log_basename' is a GLOBAL variable +SELECT @@global.relay_log_basename; +@@global.relay_log_basename +MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin +SET @@session.relay_log_basename= 'x'; +ERROR HY000: Variable 'relay_log_basename' is a read only variable +SET @@global.relay_log_basename= 'x'; +ERROR HY000: Variable 'relay_log_basename' is a read only variable +# +SHOW VARIABLES like 'log_bin_basename'; +Variable_name Value +log_bin_basename +SELECT @@session.log_bin_basename; +ERROR HY000: Variable 'log_bin_basename' is a GLOBAL variable +SELECT @@global.log_bin_basename; +@@global.log_bin_basename +NULL +SET @@session.log_bin_basename= 'x'; +ERROR HY000: Variable 'log_bin_basename' is a read only variable +SET @@global.log_bin_basename= 'x'; +ERROR HY000: Variable 'log_bin_basename' is a read only variable +# SHOW VARIABLES like 'relay_log_index'; Variable_name Value -relay_log_index mysqld-relay-bin.index +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index SELECT @@session.relay_log_index; ERROR HY000: Variable 'relay_log_index' is a GLOBAL variable SELECT @@global.relay_log_index; @@global.relay_log_index -mysqld-relay-bin.index +MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index SET @@session.relay_log_index= 'x'; ERROR HY000: Variable 'relay_log_index' is a read only variable SET @@global.relay_log_index= 'x'; ERROR HY000: Variable 'relay_log_index' is a read only variable # +SHOW VARIABLES like 'log_bin_index'; +Variable_name Value +log_bin_index +SELECT @@session.log_bin_index; +ERROR HY000: Variable 'log_bin_index' is a GLOBAL variable +SELECT @@global.log_bin_index; +@@global.log_bin_index +NULL +SET @@session.log_bin_index= 'x'; +ERROR HY000: Variable 'log_bin_index' is a read only variable +SET @@global.log_bin_index= 'x'; +ERROR HY000: Variable 'log_bin_index' is a read only variable +# SHOW VARIABLES like 'relay_log_info_file'; Variable_name Value relay_log_info_file relay-log.info diff --git a/mysql-test/suite/binlog/r/binlog_variables_log_bin.result b/mysql-test/suite/binlog/r/binlog_variables_log_bin.result new file mode 100644 index 00000000000..215e14f97df --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_variables_log_bin.result @@ -0,0 +1,9 @@ +SHOW VARIABLES LIKE 'log_bin%'; +Variable_name log_bin +Value ON +Variable_name log_bin_basename +Value MYSQLTEST_VARDIR/mysqld.1/data/other +Variable_name log_bin_index +Value MYSQLTEST_VARDIR/mysqld.1/data/mysqld-bin.index +Variable_name log_bin_trust_function_creators +Value ON diff --git a/mysql-test/suite/binlog/r/binlog_variables_log_bin_index.result b/mysql-test/suite/binlog/r/binlog_variables_log_bin_index.result new file mode 100644 index 00000000000..fb7324ced34 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_variables_log_bin_index.result @@ -0,0 +1,9 @@ +SHOW VARIABLES LIKE 'log_bin%'; +Variable_name log_bin +Value ON +Variable_name log_bin_basename +Value MYSQLTEST_VARDIR/mysqld.1/data/other +Variable_name log_bin_index +Value MYSQLTEST_VARDIR/tmp/something.index +Variable_name log_bin_trust_function_creators +Value ON diff --git a/mysql-test/suite/binlog/r/binlog_variables_relay_log.result b/mysql-test/suite/binlog/r/binlog_variables_relay_log.result new file mode 100644 index 00000000000..59135837c29 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_variables_relay_log.result @@ -0,0 +1,15 @@ +SHOW VARIABLES LIKE 'relay_log%'; +Variable_name relay_log +Value other-relay +Variable_name relay_log_basename +Value MYSQLTEST_VARDIR/mysqld.1/data/other-relay +Variable_name relay_log_index +Value MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +Variable_name relay_log_info_file +Value relay-log.info +Variable_name relay_log_purge +Value ON +Variable_name relay_log_recovery +Value OFF +Variable_name relay_log_space_limit +Value 0 diff --git a/mysql-test/suite/binlog/r/binlog_variables_relay_log_index.result b/mysql-test/suite/binlog/r/binlog_variables_relay_log_index.result new file mode 100644 index 00000000000..1b18b89d298 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_variables_relay_log_index.result @@ -0,0 +1,15 @@ +SHOW VARIABLES LIKE 'relay_log%'; +Variable_name relay_log +Value other-relay +Variable_name relay_log_basename +Value MYSQLTEST_VARDIR/mysqld.1/data/other-relay +Variable_name relay_log_index +Value MYSQLTEST_VARDIR/tmp/something-relay.index +Variable_name relay_log_info_file +Value relay-log.info +Variable_name relay_log_purge +Value ON +Variable_name relay_log_recovery +Value OFF +Variable_name relay_log_space_limit +Value 0 diff --git a/mysql-test/suite/binlog/t/binlog_variables_log_bin-master.opt b/mysql-test/suite/binlog/t/binlog_variables_log_bin-master.opt new file mode 100644 index 00000000000..85d14ea7af9 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_log_bin-master.opt @@ -0,0 +1 @@ +--log-bin=other diff --git a/mysql-test/suite/binlog/t/binlog_variables_log_bin.test b/mysql-test/suite/binlog/t/binlog_variables_log_bin.test new file mode 100644 index 00000000000..d94d565d004 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_log_bin.test @@ -0,0 +1,4 @@ +--source include/not_embedded.inc + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--query_vertical SHOW VARIABLES LIKE 'log_bin%' diff --git a/mysql-test/suite/binlog/t/binlog_variables_log_bin_index-master.opt b/mysql-test/suite/binlog/t/binlog_variables_log_bin_index-master.opt new file mode 100644 index 00000000000..68e580bd205 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_log_bin_index-master.opt @@ -0,0 +1,2 @@ +--log-bin=other +--log-bin-index=$MYSQLTEST_VARDIR/tmp/something.index diff --git a/mysql-test/suite/binlog/t/binlog_variables_log_bin_index.test b/mysql-test/suite/binlog/t/binlog_variables_log_bin_index.test new file mode 100644 index 00000000000..d94d565d004 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_log_bin_index.test @@ -0,0 +1,4 @@ +--source include/not_embedded.inc + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--query_vertical SHOW VARIABLES LIKE 'log_bin%' diff --git a/mysql-test/suite/binlog/t/binlog_variables_relay_log-master.opt b/mysql-test/suite/binlog/t/binlog_variables_relay_log-master.opt new file mode 100644 index 00000000000..a01432d7a17 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_relay_log-master.opt @@ -0,0 +1 @@ +--relay-log=other-relay diff --git a/mysql-test/suite/binlog/t/binlog_variables_relay_log.test b/mysql-test/suite/binlog/t/binlog_variables_relay_log.test new file mode 100644 index 00000000000..1e987901986 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_relay_log.test @@ -0,0 +1,4 @@ +--source include/not_embedded.inc + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--query_vertical SHOW VARIABLES LIKE 'relay_log%' diff --git a/mysql-test/suite/binlog/t/binlog_variables_relay_log_index-master.opt b/mysql-test/suite/binlog/t/binlog_variables_relay_log_index-master.opt new file mode 100644 index 00000000000..eeabaca11a0 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_relay_log_index-master.opt @@ -0,0 +1,2 @@ +--relay-log=other-relay +--relay-log-index=$MYSQLTEST_VARDIR/tmp/something-relay.index diff --git a/mysql-test/suite/binlog/t/binlog_variables_relay_log_index.test b/mysql-test/suite/binlog/t/binlog_variables_relay_log_index.test new file mode 100644 index 00000000000..1e987901986 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_variables_relay_log_index.test @@ -0,0 +1,4 @@ +--source include/not_embedded.inc + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--query_vertical SHOW VARIABLES LIKE 'relay_log%' diff --git a/mysql-test/suite/rpl/r/rpl_flushlog_loop.result b/mysql-test/suite/rpl/r/rpl_flushlog_loop.result index 7b93a221953..a5bf73cdbfa 100644 --- a/mysql-test/suite/rpl/r/rpl_flushlog_loop.result +++ b/mysql-test/suite/rpl/r/rpl_flushlog_loop.result @@ -2,7 +2,8 @@ include/rpl_init.inc [topology=1->2->1] show variables like 'relay_log%'; Variable_name Value relay_log master-relay-bin -relay_log_index master-relay-bin.index +relay_log_basename MYSQLD_DATADIR/master-relay-bin +relay_log_index MYSQLD_DATADIR/master-relay-bin.index relay_log_info_file relay-log.info relay_log_purge ON relay_log_recovery OFF diff --git a/mysql-test/suite/rpl/r/rpl_variables.result b/mysql-test/suite/rpl/r/rpl_variables.result index 8711dce4ab6..f91cdad6e47 100644 --- a/mysql-test/suite/rpl/r/rpl_variables.result +++ b/mysql-test/suite/rpl/r/rpl_variables.result @@ -38,6 +38,34 @@ include/stop_slave.inc include/start_slave.inc SET @@global.init_slave = 'SELECT 1'; [on master] +SELECT @@pid_file, @@datadir; +@@pid_file MYSQLTEST_VARDIR/run/mysqld.1.pid +@@datadir MYSQLTEST_VARDIR/mysqld.1/data/ +**** Relay log variables +SELECT @@relay_log, @@relay_log_index, @@relay_log_basename; +@@relay_log master-relay-bin +@@relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin.index +@@relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin +**** Binary log variables +SELECT @@log_bin, @@log_bin_index, @@log_bin_basename; +@@log_bin 1 +@@log_bin_index MYSQLTEST_VARDIR/mysqld.1/data/master-bin.index +@@log_bin_basename MYSQLTEST_VARDIR/mysqld.1/data/master-bin +[on slave] +SELECT @@pid_file, @@datadir; +@@pid_file MYSQLTEST_VARDIR/run/mysqld.2.pid +@@datadir MYSQLTEST_VARDIR/mysqld.2/data/ +**** Relay log variables +SELECT @@relay_log, @@relay_log_index, @@relay_log_basename; +@@relay_log slave-relay-bin +@@relay_log_index MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.index +@@relay_log_basename MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin +**** Binary log variables +SELECT @@log_bin, @@log_bin_index, @@log_bin_basename; +@@log_bin 1 +@@log_bin_index MYSQLTEST_VARDIR/mysqld.2/data/slave-bin.index +@@log_bin_basename MYSQLTEST_VARDIR/mysqld.2/data/slave-bin +[on master] CREATE TABLE tstmt (id INT AUTO_INCREMENT PRIMARY KEY, truth BOOLEAN, num INT, diff --git a/mysql-test/suite/rpl/t/rpl_variables.test b/mysql-test/suite/rpl/t/rpl_variables.test index ca90054da2a..246e595d265 100644 --- a/mysql-test/suite/rpl/t/rpl_variables.test +++ b/mysql-test/suite/rpl/t/rpl_variables.test @@ -119,6 +119,30 @@ SET @@global.init_slave = 'SELECT 1'; --echo [on master] connection master; +# checking values of read-only variables +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +query_vertical SELECT @@pid_file, @@datadir; +--echo **** Relay log variables +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +query_vertical SELECT @@relay_log, @@relay_log_index, @@relay_log_basename; +--echo **** Binary log variables +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +query_vertical SELECT @@log_bin, @@log_bin_index, @@log_bin_basename; + +--echo [on slave] +connection slave; +# checking values of read-only variables +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +query_vertical SELECT @@pid_file, @@datadir; +--echo **** Relay log variables +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +query_vertical SELECT @@relay_log, @@relay_log_index, @@relay_log_basename; +--echo **** Binary log variables +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +query_vertical SELECT @@log_bin, @@log_bin_index, @@log_bin_basename; + +--echo [on master] +connection master; # Tables where everything happens. CREATE TABLE tstmt (id INT AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/suite/sys_vars/inc/bin_relay_log_basename_index.inc b/mysql-test/suite/sys_vars/inc/bin_relay_log_basename_index.inc new file mode 100644 index 00000000000..58d6ce2deb2 --- /dev/null +++ b/mysql-test/suite/sys_vars/inc/bin_relay_log_basename_index.inc @@ -0,0 +1,55 @@ +# ==== Usage ==== +# [--let $rpl_debug=1] +# --let $rpl_log_var_name= log_bin_basename|relay_log_basename|... +# --source suite/sys_vars/inc/bin_relay_log_basename_index.inc +# +# $rpl_log_var_name +# The name of the variable to test, i.e., one of: +# - log_bin_basename +# - relay_log_basename +# - log_bin_index +# - relay_log_index +# +# $rpl_debug +# See include/rpl_init.inc + +if ($rpl_debug) +{ + --echo Testing variable named: $rpl_log_var_name +} + +--let $basename= `SELECT @@global.$rpl_log_var_name` + +# +# Assert that the variable is indeed only global +# +--replace_result $basename REPLACED +--eval select @@global.$rpl_log_var_name + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +--eval select @@session.$rpl_log_var_name + +# +# Assert that it is retrievable +# +--replace_result $basename REPLACED +--eval show global variables like '$rpl_log_var_name' + +--replace_result $basename REPLACED +--eval show session variables like '$rpl_log_var_name' + +--replace_result $basename REPLACED +--eval select * from information_schema.global_variables where variable_name='$rpl_log_var_name' + +--replace_result $basename REPLACED +--eval select * from information_schema.session_variables where variable_name='$rpl_log_var_name' + +# +# Assert it is read-only +# +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +--eval set global $rpl_log_var_name=1 + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +--eval set session $rpl_log_var_name=1 + diff --git a/mysql-test/suite/sys_vars/r/log_bin_basename_basic.result b/mysql-test/suite/sys_vars/r/log_bin_basename_basic.result new file mode 100644 index 00000000000..696e384ac6e --- /dev/null +++ b/mysql-test/suite/sys_vars/r/log_bin_basename_basic.result @@ -0,0 +1,21 @@ +select @@global.log_bin_basename; +@@global.log_bin_basename +REPLACED +select @@session.log_bin_basename; +ERROR HY000: Variable 'log_bin_basename' is a GLOBAL variable +show global variables like 'log_bin_basename'; +Variable_name Value +log_bin_basename REPLACED +show session variables like 'log_bin_basename'; +Variable_name Value +log_bin_basename REPLACED +select * from information_schema.global_variables where variable_name='log_bin_basename'; +VARIABLE_NAME VARIABLE_VALUE +LOG_BIN_BASENAME REPLACED +select * from information_schema.session_variables where variable_name='log_bin_basename'; +VARIABLE_NAME VARIABLE_VALUE +LOG_BIN_BASENAME REPLACED +set global log_bin_basename=1; +ERROR HY000: Variable 'log_bin_basename' is a read only variable +set session log_bin_basename=1; +ERROR HY000: Variable 'log_bin_basename' is a read only variable diff --git a/mysql-test/suite/sys_vars/r/log_bin_index_basic.result b/mysql-test/suite/sys_vars/r/log_bin_index_basic.result new file mode 100644 index 00000000000..6b28f5fd3e3 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/log_bin_index_basic.result @@ -0,0 +1,21 @@ +select @@global.log_bin_index; +@@global.log_bin_index +REPLACED +select @@session.log_bin_index; +ERROR HY000: Variable 'log_bin_index' is a GLOBAL variable +show global variables like 'log_bin_index'; +Variable_name Value +log_bin_index REPLACED +show session variables like 'log_bin_index'; +Variable_name Value +log_bin_index REPLACED +select * from information_schema.global_variables where variable_name='log_bin_index'; +VARIABLE_NAME VARIABLE_VALUE +LOG_BIN_INDEX REPLACED +select * from information_schema.session_variables where variable_name='log_bin_index'; +VARIABLE_NAME VARIABLE_VALUE +LOG_BIN_INDEX REPLACED +set global log_bin_index=1; +ERROR HY000: Variable 'log_bin_index' is a read only variable +set session log_bin_index=1; +ERROR HY000: Variable 'log_bin_index' is a read only variable diff --git a/mysql-test/suite/sys_vars/r/relay_log_basename_basic.result b/mysql-test/suite/sys_vars/r/relay_log_basename_basic.result new file mode 100644 index 00000000000..10ad3711949 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/relay_log_basename_basic.result @@ -0,0 +1,24 @@ +include/master-slave.inc +[connection master] +select @@global.relay_log_basename; +@@global.relay_log_basename +REPLACED +select @@session.relay_log_basename; +ERROR HY000: Variable 'relay_log_basename' is a GLOBAL variable +show global variables like 'relay_log_basename'; +Variable_name Value +relay_log_basename REPLACED +show session variables like 'relay_log_basename'; +Variable_name Value +relay_log_basename REPLACED +select * from information_schema.global_variables where variable_name='relay_log_basename'; +VARIABLE_NAME VARIABLE_VALUE +RELAY_LOG_BASENAME REPLACED +select * from information_schema.session_variables where variable_name='relay_log_basename'; +VARIABLE_NAME VARIABLE_VALUE +RELAY_LOG_BASENAME REPLACED +set global relay_log_basename=1; +ERROR HY000: Variable 'relay_log_basename' is a read only variable +set session relay_log_basename=1; +ERROR HY000: Variable 'relay_log_basename' is a read only variable +include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/relay_log_index_basic.result b/mysql-test/suite/sys_vars/r/relay_log_index_basic.result index d0ceddc96fe..6d8eec9eb30 100644 --- a/mysql-test/suite/sys_vars/r/relay_log_index_basic.result +++ b/mysql-test/suite/sys_vars/r/relay_log_index_basic.result @@ -1,21 +1,45 @@ +include/master-slave.inc +[connection master] select @@global.relay_log_index; @@global.relay_log_index -mysqld-relay-bin.index +MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin.index select @@session.relay_log_index; ERROR HY000: Variable 'relay_log_index' is a GLOBAL variable show global variables like 'relay_log_index'; Variable_name Value -relay_log_index mysqld-relay-bin.index +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin.index show session variables like 'relay_log_index'; Variable_name Value -relay_log_index mysqld-relay-bin.index +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin.index select * from information_schema.global_variables where variable_name='relay_log_index'; VARIABLE_NAME VARIABLE_VALUE -RELAY_LOG_INDEX mysqld-relay-bin.index +RELAY_LOG_INDEX MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin.index select * from information_schema.session_variables where variable_name='relay_log_index'; VARIABLE_NAME VARIABLE_VALUE -RELAY_LOG_INDEX mysqld-relay-bin.index +RELAY_LOG_INDEX MYSQLTEST_VARDIR/mysqld.1/data/master-relay-bin.index set global relay_log_index=1; ERROR HY000: Variable 'relay_log_index' is a read only variable set session relay_log_index=1; ERROR HY000: Variable 'relay_log_index' is a read only variable +select @@global.relay_log_index; +@@global.relay_log_index +REPLACED +select @@session.relay_log_index; +ERROR HY000: Variable 'relay_log_index' is a GLOBAL variable +show global variables like 'relay_log_index'; +Variable_name Value +relay_log_index REPLACED +show session variables like 'relay_log_index'; +Variable_name Value +relay_log_index REPLACED +select * from information_schema.global_variables where variable_name='relay_log_index'; +VARIABLE_NAME VARIABLE_VALUE +RELAY_LOG_INDEX REPLACED +select * from information_schema.session_variables where variable_name='relay_log_index'; +VARIABLE_NAME VARIABLE_VALUE +RELAY_LOG_INDEX REPLACED +set global relay_log_index=1; +ERROR HY000: Variable 'relay_log_index' is a read only variable +set session relay_log_index=1; +ERROR HY000: Variable 'relay_log_index' is a read only variable +include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 10b3b12dabb..547d9b1f79e 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -1689,6 +1689,34 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NULL +VARIABLE_NAME LOG_BIN_BASENAME +SESSION_VALUE NULL +GLOBAL_VALUE +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE NULL +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT The full path of the binary log file names, excluding the extension. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY YES +COMMAND_LINE_ARGUMENT NULL +VARIABLE_NAME LOG_BIN_INDEX +SESSION_VALUE NULL +GLOBAL_VALUE +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE NULL +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT File that holds the names for last binary log files. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY YES +COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME LOG_BIN_TRUST_FUNCTION_CREATORS SESSION_VALUE NULL GLOBAL_VALUE ON @@ -3355,11 +3383,25 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME RELAY_LOG_BASENAME +SESSION_VALUE NULL +GLOBAL_VALUE PATH +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE NULL +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT The full path of the relay log file names, excluding the extension. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY YES +COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME RELAY_LOG_INDEX SESSION_VALUE NULL -GLOBAL_VALUE mysqld-relay-bin.index -GLOBAL_VALUE_ORIGIN AUTO -DEFAULT_VALUE +GLOBAL_VALUE PATH +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR VARIABLE_COMMENT The location and name to use for the file that keeps a list of the last relay logs @@ -3368,7 +3410,7 @@ NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY YES -COMMAND_LINE_ARGUMENT REQUIRED +COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME RELAY_LOG_INFO_FILE SESSION_VALUE NULL GLOBAL_VALUE relay-log.info diff --git a/mysql-test/suite/sys_vars/t/log_bin_basename_basic.test b/mysql-test/suite/sys_vars/t/log_bin_basename_basic.test new file mode 100644 index 00000000000..8ad5bd22bb6 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/log_bin_basename_basic.test @@ -0,0 +1,13 @@ +# +# WL#5465: System variables: paths to relay log and binary log files +# +# Test for variable: +# Variable Name: log_bin_basename +# Variable Scope: Global +# Dynamic Variable: No + +--source include/not_embedded.inc +--source include/have_log_bin.inc + +--let $rpl_log_var_name=log_bin_basename +--source suite/sys_vars/inc/bin_relay_log_basename_index.inc diff --git a/mysql-test/suite/sys_vars/t/log_bin_index_basic.test b/mysql-test/suite/sys_vars/t/log_bin_index_basic.test new file mode 100644 index 00000000000..c99df79f36f --- /dev/null +++ b/mysql-test/suite/sys_vars/t/log_bin_index_basic.test @@ -0,0 +1,13 @@ +# +# WL#5465: System variables: paths to relay log and binary log files +# +# Test for variable: +# Variable Name: log_bin_index +# Variable Scope: Global +# Dynamic Variable: No + +--source include/not_embedded.inc +--source include/have_log_bin.inc + +--let $rpl_log_var_name=log_bin_index +--source suite/sys_vars/inc/bin_relay_log_basename_index.inc diff --git a/mysql-test/suite/sys_vars/t/relay_log_basename_basic.test b/mysql-test/suite/sys_vars/t/relay_log_basename_basic.test new file mode 100644 index 00000000000..29b70e6cd47 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/relay_log_basename_basic.test @@ -0,0 +1,16 @@ +# +# WL#5465: System variables: paths to relay log and binary log files +# +# Test for variable: +# Variable Name: relay_log_basename +# Variable Scope: Global +# Dynamic Variable: No + +--source include/not_embedded.inc +--source include/master-slave.inc + +--connection slave +--let $rpl_log_var_name=relay_log_basename +--source suite/sys_vars/inc/bin_relay_log_basename_index.inc + +--source include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/t/relay_log_index_basic.test b/mysql-test/suite/sys_vars/t/relay_log_index_basic.test index fa69d978016..5a585ac289f 100644 --- a/mysql-test/suite/sys_vars/t/relay_log_index_basic.test +++ b/mysql-test/suite/sys_vars/t/relay_log_index_basic.test @@ -1,13 +1,20 @@ --source include/not_embedded.inc +--source include/master-slave.inc + # # only global # +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR select @@global.relay_log_index; --error ER_INCORRECT_GLOBAL_LOCAL_VAR select @@session.relay_log_index; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show global variables like 'relay_log_index'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show session variables like 'relay_log_index'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR select * from information_schema.global_variables where variable_name='relay_log_index'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR select * from information_schema.session_variables where variable_name='relay_log_index'; # @@ -17,3 +24,10 @@ select * from information_schema.session_variables where variable_name='relay_lo set global relay_log_index=1; --error ER_INCORRECT_GLOBAL_LOCAL_VAR set session relay_log_index=1; + +--connection slave +--let $rpl_log_var_name=relay_log_index +--source suite/sys_vars/inc/bin_relay_log_basename_index.inc + +--source include/rpl_end.inc + diff --git a/mysql-test/t/flush2.test b/mysql-test/t/flush2.test index 7582ab8426b..496b57ccea4 100644 --- a/mysql-test/t/flush2.test +++ b/mysql-test/t/flush2.test @@ -1,9 +1,16 @@ # # Bug#17733 Flushing logs causes daily server crash # + +--source include/not_embedded.inc + flush logs; set global expire_logs_days = 3; show variables like 'log_bin%'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +show variables like 'relay_log%'; flush logs; show variables like 'log_bin%'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +show variables like 'relay_log%'; set global expire_logs_days = 0; diff --git a/mysql-test/t/variables-notembedded.test b/mysql-test/t/variables-notembedded.test index 471212bf38f..2aa77e1e254 100644 --- a/mysql-test/t/variables-notembedded.test +++ b/mysql-test/t/variables-notembedded.test @@ -58,9 +58,33 @@ SET @@session.relay_log= 'x'; SET @@global.relay_log= 'x'; # --echo # +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW VARIABLES like 'relay_log_basename'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.relay_log_basename; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SELECT @@global.relay_log_basename; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.relay_log_basename= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.relay_log_basename= 'x'; +# +--echo # +SHOW VARIABLES like 'log_bin_basename'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.log_bin_basename; +SELECT @@global.log_bin_basename; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.log_bin_basename= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.log_bin_basename= 'x'; +# +--echo # +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR SHOW VARIABLES like 'relay_log_index'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.relay_log_index; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR SELECT @@global.relay_log_index; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.relay_log_index= 'x'; @@ -68,6 +92,16 @@ SET @@session.relay_log_index= 'x'; SET @@global.relay_log_index= 'x'; # --echo # +SHOW VARIABLES like 'log_bin_index'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.log_bin_index; +SELECT @@global.log_bin_index; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.log_bin_index= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.log_bin_index= 'x'; +# +--echo # SHOW VARIABLES like 'relay_log_info_file'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.relay_log_info_file; diff --git a/sql/log.cc b/sql/log.cc index 593d9ba04ea..35f6184f81a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -67,6 +67,9 @@ handlerton *binlog_hton; LOGGER logger; +const char *log_bin_index= 0; +const char *log_bin_basename= 0; + MYSQL_BIN_LOG mysql_bin_log(&sync_binlog_period); static bool test_if_number(const char *str, diff --git a/sql/log.h b/sql/log.h index a48b09cb9fc..2d0c2d1eee9 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1087,6 +1087,8 @@ void binlog_reset_cache(THD *thd); extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; extern LOGGER logger; +extern const char *log_bin_index; +extern const char *log_bin_basename; /** Turns a relative log binary log path into a full path, based on the diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2bde88189fb..50f6984a646 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2162,6 +2162,12 @@ void clean_up(bool print_message) mysql_cond_broadcast(&COND_thread_count); mysql_mutex_unlock(&LOCK_thread_count); + my_free(const_cast<char*>(log_bin_basename)); + my_free(const_cast<char*>(log_bin_index)); +#ifndef EMBEDDED_LIBRARY + my_free(const_cast<char*>(relay_log_basename)); + my_free(const_cast<char*>(relay_log_index)); +#endif free_list(opt_plugin_load_list_ptr); if (THR_THD) @@ -3999,6 +4005,42 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) } } +/** + Create a replication file name or base for file names. + + @param[in] opt Value of option, or NULL + @param[in] def Default value if option value is not set. + @param[in] ext Extension to use for the path + + @returns Pointer to string containing the full file path, or NULL if + it was not possible to create the path. + */ +static inline const char * +rpl_make_log_name(const char *opt, + const char *def, + const char *ext) +{ + DBUG_ENTER("rpl_make_log_name"); + DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt, def, ext)); + char buff[FN_REFLEN]; + const char *base= opt ? opt : def; + unsigned int options= + MY_REPLACE_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH; + + /* mysql_real_data_home_ptr may be null if no value of datadir has been + specified through command-line or througha cnf file. If that is the + case we make mysql_real_data_home_ptr point to mysql_real_data_home + which, in that case holds the default path for data-dir. + */ + if(mysql_real_data_home_ptr == NULL) + mysql_real_data_home_ptr= mysql_real_data_home; + + if (fn_format(buff, base, mysql_real_data_home_ptr, ext, options)) + DBUG_RETURN(my_strdup(buff, MYF(MY_WME))); + else + DBUG_RETURN(NULL); +} + static int init_common_variables() { umask(((~my_umask) & 0666)); @@ -5049,6 +5091,45 @@ static int init_server_components() } } + if (opt_bin_log) + { + log_bin_basename= + rpl_make_log_name(opt_bin_logname, pidfile_name, + opt_bin_logname ? "" : "-bin"); + log_bin_index= + rpl_make_log_name(opt_binlog_index_name, log_bin_basename, ".index"); + if (log_bin_basename == NULL || log_bin_index == NULL) + { + sql_print_error("Unable to create replication path names:" + " out of memory or path names too long" + " (path name exceeds " STRINGIFY_ARG(FN_REFLEN) + " or file name exceeds " STRINGIFY_ARG(FN_LEN) ")."); + unireg_abort(1); + } + } + +#ifndef EMBEDDED_LIBRARY + DBUG_PRINT("debug", + ("opt_bin_logname: %s, opt_relay_logname: %s, pidfile_name: %s", + opt_bin_logname, opt_relay_logname, pidfile_name)); + if (opt_relay_logname) + { + relay_log_basename= + rpl_make_log_name(opt_relay_logname, pidfile_name, + opt_relay_logname ? "" : "-relay-bin"); + relay_log_index= + rpl_make_log_name(opt_relaylog_index_name, relay_log_basename, ".index"); + if (relay_log_basename == NULL || relay_log_index == NULL) + { + sql_print_error("Unable to create replication path names:" + " out of memory or path names too long" + " (path name exceeds " STRINGIFY_ARG(FN_REFLEN) + " or file name exceeds " STRINGIFY_ARG(FN_LEN) ")."); + unireg_abort(1); + } + } +#endif /* !EMBEDDED_LIBRARY */ + /* call ha_init_key_cache() on all key caches to init them */ process_key_caches(&ha_init_key_cache, 0); @@ -7233,6 +7314,11 @@ struct my_option my_long_options[]= "File that holds the names for last binary log files.", &opt_binlog_index_name, &opt_binlog_index_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"relay-log-index", 0, + "The location and name to use for the file that keeps a list of the last " + "relay logs", + &opt_relaylog_index_name, &opt_relaylog_index_name, 0, GET_STR, + REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", &myisam_log_filename, &myisam_log_filename, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -8585,6 +8671,8 @@ static int mysql_init_variables(void) report_user= report_password = report_host= 0; /* TO BE DELETED */ opt_relay_logname= opt_relaylog_index_name= 0; slave_retried_transactions= 0; + log_bin_basename= NULL; + log_bin_index= NULL; /* Variables in libraries */ charsets_dir= 0; @@ -8807,9 +8895,13 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) if (log_error_file_ptr != disabled_my_option) SYSVAR_AUTOSIZE(log_error_file_ptr, opt_log_basename); + /* General log file */ make_default_log_name(&opt_logname, ".log", false); + /* Slow query log file */ make_default_log_name(&opt_slow_logname, "-slow.log", false); + /* Binary log file */ make_default_log_name(&opt_bin_logname, "-bin", true); + /* Binary log index file */ make_default_log_name(&opt_binlog_index_name, "-bin.index", true); mark_sys_var_value_origin(&opt_logname, sys_var::AUTO); mark_sys_var_value_origin(&opt_slow_logname, sys_var::AUTO); @@ -8818,15 +8910,17 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) return 1; #ifdef HAVE_REPLICATION + /* Relay log file */ make_default_log_name(&opt_relay_logname, "-relay-bin", true); + /* Relay log index file */ make_default_log_name(&opt_relaylog_index_name, "-relay-bin.index", true); mark_sys_var_value_origin(&opt_relay_logname, sys_var::AUTO); - mark_sys_var_value_origin(&opt_relaylog_index_name, sys_var::AUTO); if (!opt_relay_logname || !opt_relaylog_index_name) return 1; #endif SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name); + /* PID file */ strmake(pidfile_name, argument, sizeof(pidfile_name)-5); strmov(fn_ext(pidfile_name),".pid"); diff --git a/sql/slave.cc b/sql/slave.cc index e228033f15a..d834182a99a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -77,6 +77,10 @@ Master_info *active_mi= 0; Master_info_index *master_info_index; my_bool replicate_same_server_id; ulonglong relay_log_space_limit = 0; + +const char *relay_log_index= 0; +const char *relay_log_basename= 0; + LEX_STRING default_master_connection_name= { (char*) "", 0 }; /* diff --git a/sql/slave.h b/sql/slave.h index fc48476a6d8..15e320623cc 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -131,6 +131,8 @@ extern char *opt_slave_skip_errors; extern my_bool opt_replicate_annotate_row_events; extern ulonglong relay_log_space_limit; extern ulonglong slave_skipped_errors; +extern const char *relay_log_index; +extern const char *relay_log_basename; /* 3 possible values for Master_info::slave_running and diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 88e5f1b392b..971040a670e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4170,10 +4170,37 @@ static Sys_var_charptr Sys_relay_log( READ_ONLY GLOBAL_VAR(opt_relay_logname), CMD_LINE(REQUIRED_ARG), IN_FS_CHARSET, DEFAULT(0)); +/* + Uses NO_CMD_LINE since the --relay-log-index option set + opt_relaylog_index_name variable and computes a value for the + relay_log_index variable. +*/ static Sys_var_charptr Sys_relay_log_index( "relay_log_index", "The location and name to use for the file " "that keeps a list of the last relay logs", - READ_ONLY GLOBAL_VAR(opt_relaylog_index_name), CMD_LINE(REQUIRED_ARG), + READ_ONLY GLOBAL_VAR(relay_log_index), NO_CMD_LINE, + IN_FS_CHARSET, DEFAULT(0)); + +/* + Uses NO_CMD_LINE since the --log-bin-index option set + opt_binlog_index_name variable and computes a value for the + log_bin_index variable. +*/ +static Sys_var_charptr Sys_binlog_index( + "log_bin_index", "File that holds the names for last binary log files.", + READ_ONLY GLOBAL_VAR(log_bin_index), NO_CMD_LINE, + IN_FS_CHARSET, DEFAULT(0)); + +static Sys_var_charptr Sys_relay_log_basename( + "relay_log_basename", + "The full path of the relay log file names, excluding the extension.", + READ_ONLY GLOBAL_VAR(relay_log_basename), NO_CMD_LINE, + IN_FS_CHARSET, DEFAULT(0)); + +static Sys_var_charptr Sys_log_bin_basename( + "log_bin_basename", + "The full path of the binary log file names, excluding the extension.", + READ_ONLY GLOBAL_VAR(log_bin_basename), NO_CMD_LINE, IN_FS_CHARSET, DEFAULT(0)); static Sys_var_charptr Sys_relay_log_info_file( |