mariadb/mysql-test/main/log_state.test

343 lines
9.9 KiB
Text
Raw Normal View History

### t/log_state.test ###
#
--source include/not_embedded.inc
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
--source include/have_csv.inc
call mtr.add_suppression("options .* --log_slow_queries is not set");
# Several subtests modify global variables. Save the initial values only here,
# but reset to the initial values per subtest.
SET @old_general_log= @@global.general_log;
SET @old_general_log_file= @@global.general_log_file;
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_slow_query_log_file= @@global.slow_query_log_file;
set @save_long_query_time=@@long_query_time;
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
--disable_ps_protocol
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
set global general_log= OFF;
truncate table mysql.general_log;
truncate table mysql.slow_log;
show global variables
where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
flush logs;
set global general_log= ON;
create table t1(f1 int);
--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
select * from mysql.general_log;
set global general_log= OFF;
drop table t1;
--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
select * from mysql.general_log;
set global general_log= ON;
flush logs;
show global variables
where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
connect (con1,localhost,root,,);
connection con1;
# Please increase @long_query_time if the corresponding selects show an
# additional unexpected entry like
# start_time ... sql_text
# TIMESTAMP ... set session long_query_time=...
# (Bug#40377 sporadic pushbuild failure in log_state: result mismatch)
--replace_result 2 <long_query_time>
set @long_query_time = 2;
set session long_query_time = @long_query_time;
select sleep(@long_query_time + 1);
--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
connection default;
set global slow_query_log= ON;
set local slow_query_log= ON;
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
connection con1;
set session long_query_time = @long_query_time;
select sleep(@long_query_time + 1);
--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
set local slow_query_log= ON;
select sleep(@long_query_time + 2);
--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
connection default;
show global variables
where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
set global general_log= ON;
set global general_log= OFF;
set global general_log= OFF;
set global slow_query_log= ON;
set global slow_query_log= OFF;
set global slow_query_log= OFF;
set local slow_query_log= ON;
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
set global general_log= ON;
truncate table mysql.general_log;
create table t1(f1 int);
drop table t1;
--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
select * from mysql.general_log;
set global general_log= OFF;
truncate table mysql.general_log;
--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
select * from mysql.general_log;
set global general_log= ON;
show global variables
where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
--replace_column 2 #
show variables like 'general_log_file';
--replace_column 2 #
show variables like 'slow_query_log_file';
show variables like 'log_output';
# Can't set general_log_file to a non existing file
--error ER_WRONG_VALUE_FOR_VAR
set global general_log_file='/not existing path/log.master';
# Can't set general_log_file to a directory
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error ER_WRONG_VALUE_FOR_VAR
eval set global general_log_file='$MYSQLTEST_VARDIR';
# Can't set general_log_file to empty string
--error ER_WRONG_VALUE_FOR_VAR
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
set global general_log_file='';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
--replace_column 2 #
show variables like 'general_log_file';
set global general_log= OFF;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval set global general_log_file='$MYSQLTEST_VARDIR/tmp/log.master';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
set global general_log= ON;
create table t1(f1 int);
drop table t1;
set global general_log= OFF;
set global general_log_file=default;
set global general_log= ON;
create table t1(f1 int);
drop table t1;
--replace_column 2 #
show variables like 'general_log_file';
--replace_column 2 #
show variables like 'slow_query_log_file';
set global general_log= default;
set global slow_query_log= default;
set global general_log_file= default;
set global slow_query_log_file= default;
show variables like 'general_log';
show variables like 'slow_query_log';
show global variables like 'slow_query_log';
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
set global general_log=ON;
set global log_output=default;
show variables like 'log_output';
set global general_log=OFF;
set global log_output=FILE;
truncate table mysql.general_log;
show variables like 'log_output';
set global general_log=ON;
create table t1(f1 int);
--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
select * from mysql.general_log;
set global general_log=OFF;
set global log_output="FILE,TABLE";
show variables like 'log_output';
set global general_log=ON;
drop table t1;
--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
select * from mysql.general_log;
# Reset to initial values
SET @@global.general_log = @old_general_log;
SET @@global.general_log_file = @old_general_log_file;
SET @@global.slow_query_log = @old_slow_query_log;
SET @@global.slow_query_log_file = @old_slow_query_log_file;
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log) Bug#25422 (Hang with log tables) Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the thread) Bug 23044 (Warnings on flush of a log table) Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes a deadlock) Prior to this fix, the server would hang when performing concurrent ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES, which are mysql.general_log and mysql.slow_log. The root cause traces to the following code: in sql_base.cc, open_table() if (table->in_use != thd) { /* wait_for_condition will unlock LOCK_open for us */ wait_for_condition(thd, &LOCK_open, &COND_refresh); } The problem with this code is that the current implementation of the LOGGER creates 'fake' THD objects, like - Log_to_csv_event_handler::general_log_thd - Log_to_csv_event_handler::slow_log_thd which are not associated to a real thread running in the server, so that waiting for these non-existing threads to release table locks cause the dead lock. In general, the design of Log_to_csv_event_handler does not fit into the general architecture of the server, so that the concept of general_log_thd and slow_log_thd has to be abandoned: - this implementation does not work with table locking - it will not work with commands like SHOW PROCESSLIST - having the log tables always opened does not integrate well with DDL operations / FLUSH TABLES / SET GLOBAL READ_ONLY With this patch, the fundamental design of the LOGGER has been changed to: - always open and close a log table when writing a log - remove totally the usage of fake THD objects - clarify how locking of log tables is implemented in general. See WL#3984 for details related to the new locking design. Additional changes (misc bugs exposed and fixed): 1) mysqldump which would ignore some tables in dump_all_tables_in_db(), but forget to ignore the same in dump_all_views_in_db(). 2) mysqldump would also issue an empty "LOCK TABLE" command when all the tables to lock are to be ignored (numrows == 0), instead of not issuing the query. 3) Internal errors handlers could intercept errors but not warnings (see sql_error.cc). 4) Implementing a nested call to open tables, for the performance schema tables, exposed an existing bug in remove_table_from_cache(), which would perform: in_use->some_tables_deleted=1; against another thread, without any consideration about thread locking. This call inside remove_table_from_cache() was not required anyway, since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads that might hold a lock on a table. This line (in_use->some_tables_deleted=1) has been removed. sql/handler.cc: Moved logic for system / log tables in the SQL layer. sql/handler.h: Moved logic for system / log tables in the SQL layer. sql/lock.cc: Revised locking of log tables sql/log.cc: Major cleanup: changed how log tables are locked / written to. sql/log.h: Major cleanup: changed how log tables are locked / written to. sql/mysql_priv.h: performance schema helpers sql/slave.cc: open_ltable() lock flags sql/sp.cc: open_ltable() lock flags sql/sql_acl.cc: open_ltable() lock flags sql/sql_class.h: performance schema helpers sql/sql_delete.cc: log tables cleanup in TRUNCATE sql/sql_error.cc: Internal handlers can also intercept warnings sql/sql_insert.cc: open_ltable() lock flags sql/sql_parse.cc: performance schema helpers sql/sql_plugin.cc: open_ltable() lock flags sql/sql_rename.cc: log tables cleanup in RENAME sql/sql_servers.cc: open_ltable() lock flags sql/sql_show.cc: Move INFORMATION_SCHEMA_NAME to table.cc sql/sql_table.cc: log tables cleanup (admin operations, ALTER TABLE) sql/sql_udf.cc: open_ltable() lock flags sql/table.cc: Implemented TABLE_CATEGORY. sql/share/errmsg.txt: Changed the wording and name of ER_CANT_READ_LOCK_LOG_TABLE sql/table.h: Implemented TABLE_CATEGORY. storage/csv/ha_tina.cc: Moved logic for system / log tables in the SQL layer. storage/csv/ha_tina.h: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.cc: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.h: Moved logic for system / log tables in the SQL layer. client/mysqldump.c: Don't lock tables in the ignore list. Don't issue empty LOCK TABLES queries. sql/sql_base.cc: log tables cleanup performance schema helpers mysql-test/r/ps.result: Adjust test results mysql-test/r/show_check.result: Adjust test results mysql-test/r/status.result: Adjust test results mysql-test/t/log_state.test: Added tests for Bug#29129 mysql-test/t/ps.test: Make the test output deterministic mysql-test/t/show_check.test: Make the test output deterministic mysql-test/r/log_state.result: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- Adjust test results mysql-test/r/log_tables.result: cleanup for -ps-protocol mysql-test/t/log_tables.test: cleanup for -ps-protocol sql/set_var.cc: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- log tables cleanup
2007-07-27 08:31:06 +02:00
###########################################################################
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log) Bug#25422 (Hang with log tables) Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the thread) Bug 23044 (Warnings on flush of a log table) Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes a deadlock) Prior to this fix, the server would hang when performing concurrent ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES, which are mysql.general_log and mysql.slow_log. The root cause traces to the following code: in sql_base.cc, open_table() if (table->in_use != thd) { /* wait_for_condition will unlock LOCK_open for us */ wait_for_condition(thd, &LOCK_open, &COND_refresh); } The problem with this code is that the current implementation of the LOGGER creates 'fake' THD objects, like - Log_to_csv_event_handler::general_log_thd - Log_to_csv_event_handler::slow_log_thd which are not associated to a real thread running in the server, so that waiting for these non-existing threads to release table locks cause the dead lock. In general, the design of Log_to_csv_event_handler does not fit into the general architecture of the server, so that the concept of general_log_thd and slow_log_thd has to be abandoned: - this implementation does not work with table locking - it will not work with commands like SHOW PROCESSLIST - having the log tables always opened does not integrate well with DDL operations / FLUSH TABLES / SET GLOBAL READ_ONLY With this patch, the fundamental design of the LOGGER has been changed to: - always open and close a log table when writing a log - remove totally the usage of fake THD objects - clarify how locking of log tables is implemented in general. See WL#3984 for details related to the new locking design. Additional changes (misc bugs exposed and fixed): 1) mysqldump which would ignore some tables in dump_all_tables_in_db(), but forget to ignore the same in dump_all_views_in_db(). 2) mysqldump would also issue an empty "LOCK TABLE" command when all the tables to lock are to be ignored (numrows == 0), instead of not issuing the query. 3) Internal errors handlers could intercept errors but not warnings (see sql_error.cc). 4) Implementing a nested call to open tables, for the performance schema tables, exposed an existing bug in remove_table_from_cache(), which would perform: in_use->some_tables_deleted=1; against another thread, without any consideration about thread locking. This call inside remove_table_from_cache() was not required anyway, since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads that might hold a lock on a table. This line (in_use->some_tables_deleted=1) has been removed. sql/handler.cc: Moved logic for system / log tables in the SQL layer. sql/handler.h: Moved logic for system / log tables in the SQL layer. sql/lock.cc: Revised locking of log tables sql/log.cc: Major cleanup: changed how log tables are locked / written to. sql/log.h: Major cleanup: changed how log tables are locked / written to. sql/mysql_priv.h: performance schema helpers sql/slave.cc: open_ltable() lock flags sql/sp.cc: open_ltable() lock flags sql/sql_acl.cc: open_ltable() lock flags sql/sql_class.h: performance schema helpers sql/sql_delete.cc: log tables cleanup in TRUNCATE sql/sql_error.cc: Internal handlers can also intercept warnings sql/sql_insert.cc: open_ltable() lock flags sql/sql_parse.cc: performance schema helpers sql/sql_plugin.cc: open_ltable() lock flags sql/sql_rename.cc: log tables cleanup in RENAME sql/sql_servers.cc: open_ltable() lock flags sql/sql_show.cc: Move INFORMATION_SCHEMA_NAME to table.cc sql/sql_table.cc: log tables cleanup (admin operations, ALTER TABLE) sql/sql_udf.cc: open_ltable() lock flags sql/table.cc: Implemented TABLE_CATEGORY. sql/share/errmsg.txt: Changed the wording and name of ER_CANT_READ_LOCK_LOG_TABLE sql/table.h: Implemented TABLE_CATEGORY. storage/csv/ha_tina.cc: Moved logic for system / log tables in the SQL layer. storage/csv/ha_tina.h: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.cc: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.h: Moved logic for system / log tables in the SQL layer. client/mysqldump.c: Don't lock tables in the ignore list. Don't issue empty LOCK TABLES queries. sql/sql_base.cc: log tables cleanup performance schema helpers mysql-test/r/ps.result: Adjust test results mysql-test/r/show_check.result: Adjust test results mysql-test/r/status.result: Adjust test results mysql-test/t/log_state.test: Added tests for Bug#29129 mysql-test/t/ps.test: Make the test output deterministic mysql-test/t/show_check.test: Make the test output deterministic mysql-test/r/log_state.result: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- Adjust test results mysql-test/r/log_tables.result: cleanup for -ps-protocol mysql-test/t/log_tables.test: cleanup for -ps-protocol sql/set_var.cc: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- log tables cleanup
2007-07-27 08:31:06 +02:00
#
# Bug#29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
# a deadlock)
#
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log) Bug#25422 (Hang with log tables) Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the thread) Bug 23044 (Warnings on flush of a log table) Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes a deadlock) Prior to this fix, the server would hang when performing concurrent ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES, which are mysql.general_log and mysql.slow_log. The root cause traces to the following code: in sql_base.cc, open_table() if (table->in_use != thd) { /* wait_for_condition will unlock LOCK_open for us */ wait_for_condition(thd, &LOCK_open, &COND_refresh); } The problem with this code is that the current implementation of the LOGGER creates 'fake' THD objects, like - Log_to_csv_event_handler::general_log_thd - Log_to_csv_event_handler::slow_log_thd which are not associated to a real thread running in the server, so that waiting for these non-existing threads to release table locks cause the dead lock. In general, the design of Log_to_csv_event_handler does not fit into the general architecture of the server, so that the concept of general_log_thd and slow_log_thd has to be abandoned: - this implementation does not work with table locking - it will not work with commands like SHOW PROCESSLIST - having the log tables always opened does not integrate well with DDL operations / FLUSH TABLES / SET GLOBAL READ_ONLY With this patch, the fundamental design of the LOGGER has been changed to: - always open and close a log table when writing a log - remove totally the usage of fake THD objects - clarify how locking of log tables is implemented in general. See WL#3984 for details related to the new locking design. Additional changes (misc bugs exposed and fixed): 1) mysqldump which would ignore some tables in dump_all_tables_in_db(), but forget to ignore the same in dump_all_views_in_db(). 2) mysqldump would also issue an empty "LOCK TABLE" command when all the tables to lock are to be ignored (numrows == 0), instead of not issuing the query. 3) Internal errors handlers could intercept errors but not warnings (see sql_error.cc). 4) Implementing a nested call to open tables, for the performance schema tables, exposed an existing bug in remove_table_from_cache(), which would perform: in_use->some_tables_deleted=1; against another thread, without any consideration about thread locking. This call inside remove_table_from_cache() was not required anyway, since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads that might hold a lock on a table. This line (in_use->some_tables_deleted=1) has been removed. sql/handler.cc: Moved logic for system / log tables in the SQL layer. sql/handler.h: Moved logic for system / log tables in the SQL layer. sql/lock.cc: Revised locking of log tables sql/log.cc: Major cleanup: changed how log tables are locked / written to. sql/log.h: Major cleanup: changed how log tables are locked / written to. sql/mysql_priv.h: performance schema helpers sql/slave.cc: open_ltable() lock flags sql/sp.cc: open_ltable() lock flags sql/sql_acl.cc: open_ltable() lock flags sql/sql_class.h: performance schema helpers sql/sql_delete.cc: log tables cleanup in TRUNCATE sql/sql_error.cc: Internal handlers can also intercept warnings sql/sql_insert.cc: open_ltable() lock flags sql/sql_parse.cc: performance schema helpers sql/sql_plugin.cc: open_ltable() lock flags sql/sql_rename.cc: log tables cleanup in RENAME sql/sql_servers.cc: open_ltable() lock flags sql/sql_show.cc: Move INFORMATION_SCHEMA_NAME to table.cc sql/sql_table.cc: log tables cleanup (admin operations, ALTER TABLE) sql/sql_udf.cc: open_ltable() lock flags sql/table.cc: Implemented TABLE_CATEGORY. sql/share/errmsg.txt: Changed the wording and name of ER_CANT_READ_LOCK_LOG_TABLE sql/table.h: Implemented TABLE_CATEGORY. storage/csv/ha_tina.cc: Moved logic for system / log tables in the SQL layer. storage/csv/ha_tina.h: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.cc: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.h: Moved logic for system / log tables in the SQL layer. client/mysqldump.c: Don't lock tables in the ignore list. Don't issue empty LOCK TABLES queries. sql/sql_base.cc: log tables cleanup performance schema helpers mysql-test/r/ps.result: Adjust test results mysql-test/r/show_check.result: Adjust test results mysql-test/r/status.result: Adjust test results mysql-test/t/log_state.test: Added tests for Bug#29129 mysql-test/t/ps.test: Make the test output deterministic mysql-test/t/show_check.test: Make the test output deterministic mysql-test/r/log_state.result: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- Adjust test results mysql-test/r/log_tables.result: cleanup for -ps-protocol mysql-test/t/log_tables.test: cleanup for -ps-protocol sql/set_var.cc: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- log tables cleanup
2007-07-27 08:31:06 +02:00
# Test ON->OFF transition under a GLOBAL READ LOCK
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log) Bug#25422 (Hang with log tables) Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the thread) Bug 23044 (Warnings on flush of a log table) Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes a deadlock) Prior to this fix, the server would hang when performing concurrent ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES, which are mysql.general_log and mysql.slow_log. The root cause traces to the following code: in sql_base.cc, open_table() if (table->in_use != thd) { /* wait_for_condition will unlock LOCK_open for us */ wait_for_condition(thd, &LOCK_open, &COND_refresh); } The problem with this code is that the current implementation of the LOGGER creates 'fake' THD objects, like - Log_to_csv_event_handler::general_log_thd - Log_to_csv_event_handler::slow_log_thd which are not associated to a real thread running in the server, so that waiting for these non-existing threads to release table locks cause the dead lock. In general, the design of Log_to_csv_event_handler does not fit into the general architecture of the server, so that the concept of general_log_thd and slow_log_thd has to be abandoned: - this implementation does not work with table locking - it will not work with commands like SHOW PROCESSLIST - having the log tables always opened does not integrate well with DDL operations / FLUSH TABLES / SET GLOBAL READ_ONLY With this patch, the fundamental design of the LOGGER has been changed to: - always open and close a log table when writing a log - remove totally the usage of fake THD objects - clarify how locking of log tables is implemented in general. See WL#3984 for details related to the new locking design. Additional changes (misc bugs exposed and fixed): 1) mysqldump which would ignore some tables in dump_all_tables_in_db(), but forget to ignore the same in dump_all_views_in_db(). 2) mysqldump would also issue an empty "LOCK TABLE" command when all the tables to lock are to be ignored (numrows == 0), instead of not issuing the query. 3) Internal errors handlers could intercept errors but not warnings (see sql_error.cc). 4) Implementing a nested call to open tables, for the performance schema tables, exposed an existing bug in remove_table_from_cache(), which would perform: in_use->some_tables_deleted=1; against another thread, without any consideration about thread locking. This call inside remove_table_from_cache() was not required anyway, since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads that might hold a lock on a table. This line (in_use->some_tables_deleted=1) has been removed. sql/handler.cc: Moved logic for system / log tables in the SQL layer. sql/handler.h: Moved logic for system / log tables in the SQL layer. sql/lock.cc: Revised locking of log tables sql/log.cc: Major cleanup: changed how log tables are locked / written to. sql/log.h: Major cleanup: changed how log tables are locked / written to. sql/mysql_priv.h: performance schema helpers sql/slave.cc: open_ltable() lock flags sql/sp.cc: open_ltable() lock flags sql/sql_acl.cc: open_ltable() lock flags sql/sql_class.h: performance schema helpers sql/sql_delete.cc: log tables cleanup in TRUNCATE sql/sql_error.cc: Internal handlers can also intercept warnings sql/sql_insert.cc: open_ltable() lock flags sql/sql_parse.cc: performance schema helpers sql/sql_plugin.cc: open_ltable() lock flags sql/sql_rename.cc: log tables cleanup in RENAME sql/sql_servers.cc: open_ltable() lock flags sql/sql_show.cc: Move INFORMATION_SCHEMA_NAME to table.cc sql/sql_table.cc: log tables cleanup (admin operations, ALTER TABLE) sql/sql_udf.cc: open_ltable() lock flags sql/table.cc: Implemented TABLE_CATEGORY. sql/share/errmsg.txt: Changed the wording and name of ER_CANT_READ_LOCK_LOG_TABLE sql/table.h: Implemented TABLE_CATEGORY. storage/csv/ha_tina.cc: Moved logic for system / log tables in the SQL layer. storage/csv/ha_tina.h: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.cc: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.h: Moved logic for system / log tables in the SQL layer. client/mysqldump.c: Don't lock tables in the ignore list. Don't issue empty LOCK TABLES queries. sql/sql_base.cc: log tables cleanup performance schema helpers mysql-test/r/ps.result: Adjust test results mysql-test/r/show_check.result: Adjust test results mysql-test/r/status.result: Adjust test results mysql-test/t/log_state.test: Added tests for Bug#29129 mysql-test/t/ps.test: Make the test output deterministic mysql-test/t/show_check.test: Make the test output deterministic mysql-test/r/log_state.result: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- Adjust test results mysql-test/r/log_tables.result: cleanup for -ps-protocol mysql-test/t/log_tables.test: cleanup for -ps-protocol sql/set_var.cc: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- log tables cleanup
2007-07-27 08:31:06 +02:00
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
UNLOCK TABLES;
# Test OFF->ON transition under a GLOBAL READ LOCK
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
UNLOCK TABLES;
# Test ON->OFF transition under a GLOBAL READ_ONLY
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
SET GLOBAL READ_ONLY = OFF;
# Test OFF->ON transition under a GLOBAL READ_ONLY
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
SET GLOBAL READ_ONLY = OFF;
# Reset to initial values
SET GLOBAL general_log = @old_general_log;
SET GLOBAL slow_query_log = @old_slow_query_log;
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log) Bug#25422 (Hang with log tables) Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the thread) Bug 23044 (Warnings on flush of a log table) Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes a deadlock) Prior to this fix, the server would hang when performing concurrent ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES, which are mysql.general_log and mysql.slow_log. The root cause traces to the following code: in sql_base.cc, open_table() if (table->in_use != thd) { /* wait_for_condition will unlock LOCK_open for us */ wait_for_condition(thd, &LOCK_open, &COND_refresh); } The problem with this code is that the current implementation of the LOGGER creates 'fake' THD objects, like - Log_to_csv_event_handler::general_log_thd - Log_to_csv_event_handler::slow_log_thd which are not associated to a real thread running in the server, so that waiting for these non-existing threads to release table locks cause the dead lock. In general, the design of Log_to_csv_event_handler does not fit into the general architecture of the server, so that the concept of general_log_thd and slow_log_thd has to be abandoned: - this implementation does not work with table locking - it will not work with commands like SHOW PROCESSLIST - having the log tables always opened does not integrate well with DDL operations / FLUSH TABLES / SET GLOBAL READ_ONLY With this patch, the fundamental design of the LOGGER has been changed to: - always open and close a log table when writing a log - remove totally the usage of fake THD objects - clarify how locking of log tables is implemented in general. See WL#3984 for details related to the new locking design. Additional changes (misc bugs exposed and fixed): 1) mysqldump which would ignore some tables in dump_all_tables_in_db(), but forget to ignore the same in dump_all_views_in_db(). 2) mysqldump would also issue an empty "LOCK TABLE" command when all the tables to lock are to be ignored (numrows == 0), instead of not issuing the query. 3) Internal errors handlers could intercept errors but not warnings (see sql_error.cc). 4) Implementing a nested call to open tables, for the performance schema tables, exposed an existing bug in remove_table_from_cache(), which would perform: in_use->some_tables_deleted=1; against another thread, without any consideration about thread locking. This call inside remove_table_from_cache() was not required anyway, since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads that might hold a lock on a table. This line (in_use->some_tables_deleted=1) has been removed. sql/handler.cc: Moved logic for system / log tables in the SQL layer. sql/handler.h: Moved logic for system / log tables in the SQL layer. sql/lock.cc: Revised locking of log tables sql/log.cc: Major cleanup: changed how log tables are locked / written to. sql/log.h: Major cleanup: changed how log tables are locked / written to. sql/mysql_priv.h: performance schema helpers sql/slave.cc: open_ltable() lock flags sql/sp.cc: open_ltable() lock flags sql/sql_acl.cc: open_ltable() lock flags sql/sql_class.h: performance schema helpers sql/sql_delete.cc: log tables cleanup in TRUNCATE sql/sql_error.cc: Internal handlers can also intercept warnings sql/sql_insert.cc: open_ltable() lock flags sql/sql_parse.cc: performance schema helpers sql/sql_plugin.cc: open_ltable() lock flags sql/sql_rename.cc: log tables cleanup in RENAME sql/sql_servers.cc: open_ltable() lock flags sql/sql_show.cc: Move INFORMATION_SCHEMA_NAME to table.cc sql/sql_table.cc: log tables cleanup (admin operations, ALTER TABLE) sql/sql_udf.cc: open_ltable() lock flags sql/table.cc: Implemented TABLE_CATEGORY. sql/share/errmsg.txt: Changed the wording and name of ER_CANT_READ_LOCK_LOG_TABLE sql/table.h: Implemented TABLE_CATEGORY. storage/csv/ha_tina.cc: Moved logic for system / log tables in the SQL layer. storage/csv/ha_tina.h: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.cc: Moved logic for system / log tables in the SQL layer. storage/myisam/ha_myisam.h: Moved logic for system / log tables in the SQL layer. client/mysqldump.c: Don't lock tables in the ignore list. Don't issue empty LOCK TABLES queries. sql/sql_base.cc: log tables cleanup performance schema helpers mysql-test/r/ps.result: Adjust test results mysql-test/r/show_check.result: Adjust test results mysql-test/r/status.result: Adjust test results mysql-test/t/log_state.test: Added tests for Bug#29129 mysql-test/t/ps.test: Make the test output deterministic mysql-test/t/show_check.test: Make the test output deterministic mysql-test/r/log_state.result: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- Adjust test results mysql-test/r/log_tables.result: cleanup for -ps-protocol mysql-test/t/log_tables.test: cleanup for -ps-protocol sql/set_var.cc: Changed the default location of the log output to LOG_FILE, for backward compatibility with MySQL 5.0 --- log tables cleanup
2007-07-27 08:31:06 +02:00
###########################################################################
#
# Bug#31604: server crash when setting slow_query_log_file/general_log_file
#
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r');
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL general_log_file= NULL;
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r');
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL slow_query_log_file= NULL;
# Reset to initial values in case a setting above was successful.
SET GLOBAL general_log_file= @old_general_log_file;
SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
###########################################################################
--echo
--echo # --
--echo # -- Bug#32748: Inconsistent handling of assignments to
--echo # -- general_log_file/slow_query_log_file.
--echo # --
--echo
SET GLOBAL general_log_file = 'bug32748.query.log';
SET GLOBAL slow_query_log_file = 'bug32748.slow.log';
--echo
SHOW VARIABLES LIKE '%log_file';
# Reset to initial values
--echo
SET GLOBAL general_log_file = @old_general_log_file;
SET GLOBAL slow_query_log_file = @old_slow_query_log_file;
--echo
--echo # -- End of Bug#32748.
###########################################################################
--echo #
--echo # Bug #49756 Rows_examined is always 0 in the slow query log
--echo # for update statements
--echo #
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = "TABLE";
SET GLOBAL slow_query_log = ON;
SET GLOBAL long_query_time = 0.001;
# clear slow_log of any residual slow queries
TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT, PRIMARY KEY (b));
INSERT INTO t2 VALUES (3),(4);
connect (con2,localhost,root,,);
INSERT INTO t1 VALUES (1+sleep(.02)),(2);
INSERT INTO t1 SELECT b+sleep(.02) from t2;
UPDATE t1 SET a=a+sleep(.02) WHERE a>2;
UPDATE t1 SET a=a+sleep(.02) ORDER BY a DESC;
UPDATE t2 set b=b+sleep(.02) limit 1;
UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2);
DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2;
SELECT rows_examined,sql_text FROM mysql.slow_log;
disconnect con2;
connection default;
DROP TABLE t1,t2;
TRUNCATE TABLE mysql.slow_log;
--echo # end of bug#49756
--echo End of 5.1 tests
###########################################################################
--echo
--echo # --
--echo # -- Bug#38124: "general_log_file" variable silently unset when
--echo # -- using expression
--echo # --
# Store away the special DEFAULT value so we
# can compare it later, then try to set the
# general_log_file using different functions
# and expressions.
SET GLOBAL general_log_file = DEFAULT;
SELECT @@general_log_file INTO @my_glf;
SET GLOBAL general_log_file = 'BUG38124.LOG';
SELECT @@general_log_file;
SET GLOBAL general_log_file = concat('BUG38124-2.LOG');
SELECT @@general_log_file;
SET GLOBAL general_log_file = substr('BUG38124-2.LOG',3,6);
SELECT @@general_log_file;
SET GLOBAL general_log_file = DEFAULT;
SELECT @@general_log_file = @my_glf;
## Reset to initial values
SET GLOBAL general_log_file = @old_general_log_file;
WL#3015: Logging Improvements - No Restarts(ver N4) Added slow_query_log & general_log global upadatable variables. Added slow-query-log & general-log startup options. Added log_output, general_log_file, slow_query_log_file global updatable variables. mysql-test/r/show_check.result: WL#3015: Logging Improvements - No Restarts result fix sql/log.cc: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/log.h: WL#3015: Logging Improvements - No Restarts added methods to LOGGER class void deactivate_log_handlers(THD* thd, uint log_type); bool activate_log_handlers(THD* thd, uint log_type); added methods to Log_to_file_event_handler: TABLE_LIST *get_mysql_slow_log() TABLE_LIST *get_mysql_log() sql/mysql_priv.h: WL#3015: Logging Improvements - No Restarts sql/mysqld.cc: WL#3015: Logging Improvements - No Restarts added 'slow-query-log' & 'general-log' options sql/set_var.cc: WL#3015: Logging Improvements - No Restarts added 'slow_query_log' & 'general_log' updatable variables added 'log_output', 'general_log_file', 'slow_query_log_file' updatable variables sql/set_var.h: WL#3015: Logging Improvements - No Restarts new class sys_var_log_state new class sys_var_log_output sql/share/errmsg.txt: WL#3015: Logging Improvements - No Restarts added error message sql/sql_delete.cc: WL#3015: Logging Improvements - No Restarts 'truncate table slow_log|general', keep status of logs
2006-06-19 15:30:55 +02:00
--enable_ps_protocol
#
# Cleanup
#
# Disconnect must be done last to avoid delayed 'Quit' message in general log
disconnect con1;
# set back the saved default values
connection default;
# Reset global system variables to initial values if forgotten somewhere above.
SET GLOBAL long_query_time = @save_long_query_time;
SET GLOBAL log_output = @old_log_output;
SET global general_log = @old_general_log;
SET global general_log_file = @old_general_log_file;
SET global slow_query_log = @old_slow_query_log;
SET global slow_query_log_file = @old_slow_query_log_file;
# Remove the log file that was created in the "default location"
# i.e var/run
--remove_file $MYSQLTEST_VARDIR/tmp/log.master