From 657ef27076d5536f7c17e0643ea5e6829678b6df Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Mar 2008 12:25:55 +0200 Subject: [PATCH] Bug #28780 report_host is not available through SELECT @@report_host There was no way to see if report-{host,port,user,password} were set up. Fixed with introducing new global variables. The variables are made read-only because of a possible need to change them most probably require the slave server restart. Todo: transform the startup options to be CHANGE master parameters - i.e to deprecate `report-' options, and to change the new vars to be updatable at time of CHANGE master executes with new values. sql/set_var.cc: Adding associations of the server init arguments with the new global read-only variables. mysql-test/suite/rpl/r/rpl_report.result: new results file mysql-test/suite/rpl/t/rpl_report-slave.opt: options initialize the new global variables. mysql-test/suite/rpl/t/rpl_report.test: The new test to check SHOW-ability and SELECT-ablity for the report global vars. --- mysql-test/suite/rpl/r/rpl_report.result | 27 +++++++++++++++++++++ mysql-test/suite/rpl/t/rpl_report-slave.opt | 2 ++ mysql-test/suite/rpl/t/rpl_report.test | 18 ++++++++++++++ sql/set_var.cc | 13 ++++++++++ 4 files changed, 60 insertions(+) create mode 100644 mysql-test/suite/rpl/r/rpl_report.result create mode 100644 mysql-test/suite/rpl/t/rpl_report-slave.opt create mode 100644 mysql-test/suite/rpl/t/rpl_report.test diff --git a/mysql-test/suite/rpl/r/rpl_report.result b/mysql-test/suite/rpl/r/rpl_report.result new file mode 100644 index 00000000000..cc9c989dc80 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_report.result @@ -0,0 +1,27 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +select * from Information_schema.GLOBAL_VARIABLES where variable_name regexp 'report_\(host\|port\|user\|password\)'; +VARIABLE_NAME VARIABLE_VALUE +REPORT_HOST 127.0.0.1 +REPORT_PORT 9308 +REPORT_PASSWORD my_password +REPORT_USER my_user +show global variables like 'report_host'; +Variable_name Value +report_host 127.0.0.1 +show global variables like 'report_port'; +Variable_name Value +report_port 9308 +show global variables like 'report_user'; +Variable_name Value +report_user my_user +show global variables like 'report_password'; +Variable_name Value +report_password my_password +set @@global.report_host='my.new.address.net'; +ERROR HY000: Variable 'report_host' is a read only variable +end of tests diff --git a/mysql-test/suite/rpl/t/rpl_report-slave.opt b/mysql-test/suite/rpl/t/rpl_report-slave.opt new file mode 100644 index 00000000000..123e5c272b9 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_report-slave.opt @@ -0,0 +1,2 @@ +--report-host=127.0.0.1 --report-user='my_user' --report-password='my_password' --report-port=9308 + diff --git a/mysql-test/suite/rpl/t/rpl_report.test b/mysql-test/suite/rpl/t/rpl_report.test new file mode 100644 index 00000000000..ae7eea26d89 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_report.test @@ -0,0 +1,18 @@ +# Verify that mysqld init time --report-{host,port,user,password} parameters +# are SHOW-able and SELECT-able FROM INFORMATION_SCHEMA.global_variables + +source include/master-slave.inc; + +connection slave; +select * from Information_schema.GLOBAL_VARIABLES where variable_name regexp 'report_\(host\|port\|user\|password\)'; +show global variables like 'report_host'; +show global variables like 'report_port'; +show global variables like 'report_user'; +show global variables like 'report_password'; + +# to demonstrate that report global variables are read-only +error ER_INCORRECT_GLOBAL_LOCAL_VAR; +set @@global.report_host='my.new.address.net'; + + +--echo end of tests diff --git a/sql/set_var.cc b/sql/set_var.cc index 410608f154f..d44bfe4ae47 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -648,6 +648,19 @@ sys_var_thd_time_zone sys_time_zone(&vars, "time_zone"); /* Global read-only variable containing hostname */ static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname); +static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host); +static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user); +static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password); + +static uchar *slave_get_report_port(THD *thd) +{ + thd->sys_var_tmp.long_value= report_port; + return (uchar*) &thd->sys_var_tmp.long_value; +} + +static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port); + + sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create", &SV::keep_files_on_create);