• Tatiana A. Nurnberg's avatar
    WL#4403 deprecate @log and @slow_log_queries variables · 07953513
    Tatiana A. Nurnberg authored
    Adds --general_log_file, --slow_query_log_file command-
    line options to match system variables of the same names.
    
    Deprecates --log, --log-slow-queries command-line options
    and log, log_slow_queries system-variables for v7.0; they
    are superseded by general_log/general_log_file and
    slow_query_log/slow_query_log_file, respectively.
    
    mysql-test/r/log_basic.result:
      Change deprecated system variable "log" to
      general log.
    mysql-test/r/log_state.result:
      Show that all log-related server variables that
      should throw deprecation warnings do, and the
      others don't.
    mysql-test/t/log_basic.test:
      Change deprecated system variable "log" to
      general log.
    mysql-test/t/log_state.test:
      Show that all log-related server variables that
      should throw deprecation warnings do, and the
      others don't.
    sql/mysqld.cc:
      Add command-line options --general_log_file and
      --slow_query_log_file to match server options of
      the same name.
      
      Deprecated --log and --log-slow-queries command-line
      options; they are superseded by --general-log/
      --general-log-file and --slow-query-log/--slow-query-log-file,
      respectively
    sql/set_var.cc:
      Deprecate system-variables log in favour of general_log,
      log_slow_queries in favour of slow_query_log for 7.0,
      both for value- and DEFAULT-setting.
    07953513
log_state.result 10.1 KB
set global general_log= OFF;
truncate table mysql.general_log;
truncate table mysql.slow_log;
show global variables
where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
Variable_name = 'general_log' or Variable_name = 'slow_query_log';
Variable_name	Value
general_log	OFF
log	OFF
log_slow_queries	OFF
slow_query_log	OFF
flush logs;
set global general_log= ON;
create table t1(f1 int);
select * from mysql.general_log;
event_time	user_host	thread_id	server_id	command_type	argument
TIMESTAMP	USER_HOST	#	1	Query	create table t1(f1 int)
TIMESTAMP	USER_HOST	#	1	Query	select * from mysql.general_log
set global general_log= OFF;
drop table t1;
select * from mysql.general_log;
event_time	user_host	thread_id	server_id	command_type	argument
TIMESTAMP	USER_HOST	#	1	Query	create table t1(f1 int)
TIMESTAMP	USER_HOST	#	1	Query	select * from mysql.general_log
TIMESTAMP	USER_HOST	#	1	Query	set global general_log= OFF
set global general_log= ON;
flush logs;
show global variables
where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
Variable_name = 'general_log' or Variable_name = 'slow_query_log';
Variable_name	Value
general_log	ON
log	ON
log_slow_queries	OFF
slow_query_log	OFF
set session long_query_time=1;
select sleep(2);
sleep(2)
0
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
set global slow_query_log= ON;
set session long_query_time=1;
select sleep(2);
sleep(2)
0
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	select sleep(2)
show global variables
where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
Variable_name = 'general_log' or Variable_name = 'slow_query_log';
Variable_name	Value
general_log	ON
log	ON
log_slow_queries	ON
slow_query_log	ON
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 global general_log= ON;
truncate table mysql.general_log;
create table t1(f1 int);
drop table t1;
select * from mysql.general_log;
event_time	user_host	thread_id	server_id	command_type	argument
TIMESTAMP	USER_HOST	#	1	Query	create table t1(f1 int)
TIMESTAMP	USER_HOST	#	1	Query	drop table t1
TIMESTAMP	USER_HOST	#	1	Query	select * from mysql.general_log
set global general_log= OFF;
truncate table mysql.general_log;
select * from mysql.general_log;
event_time	user_host	thread_id	server_id	command_type	argument
set global general_log= ON;
show global variables
where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
Variable_name = 'general_log' or Variable_name = 'slow_query_log';
Variable_name	Value
general_log	ON
log	ON
log_slow_queries	OFF
slow_query_log	OFF
show variables like 'general_log_file';
Variable_name	Value
general_log_file	#
show variables like 'slow_query_log_file';
Variable_name	Value
slow_query_log_file	#
show variables like 'log_output';
Variable_name	Value
log_output	FILE,TABLE
set global general_log_file='/not exiting path/log.master';
ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master'
set global general_log_file='MYSQLTEST_VARDIR';
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'MYSQLTEST_VARDIR'
set global general_log_file='';
ERROR 42000: Variable 'general_log_file' can't be set to the value of ''
show variables like 'general_log_file';
Variable_name	Value
general_log_file	#
set global general_log= OFF;
set global general_log_file='MYSQLTEST_VARDIR/tmp/log.master';
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;
show variables like 'general_log_file';
Variable_name	Value
general_log_file	#
show variables like 'slow_query_log_file';
Variable_name	Value
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';
Variable_name	Value
general_log	OFF
show variables like 'slow_query_log';
Variable_name	Value
slow_query_log	OFF
set global general_log=ON;
set global log_output=default;
show variables like 'log_output';
Variable_name	Value
log_output	FILE
set global general_log=OFF;
set global log_output=FILE;
truncate table mysql.general_log;
show variables like 'log_output';
Variable_name	Value
log_output	FILE
set global general_log=ON;
create table t1(f1 int);
select * from mysql.general_log;
event_time	user_host	thread_id	server_id	command_type	argument
set global general_log=OFF;
set global log_output="FILE,TABLE";
show variables like 'log_output';
Variable_name	Value
log_output	FILE,TABLE
set global general_log=ON;
drop table t1;
select * from mysql.general_log;
event_time	user_host	thread_id	server_id	command_type	argument
TIMESTAMP	USER_HOST	#	1	Query	drop table t1
TIMESTAMP	USER_HOST	#	1	Query	select * from mysql.general_log
SET @old_general_log_state = @@global.general_log;
SET @old_slow_log_state = @@global.slow_query_log;
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;
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
UNLOCK TABLES;
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
SET GLOBAL READ_ONLY = OFF;
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
SET GLOBAL READ_ONLY = OFF;
SET GLOBAL general_log = @old_general_log_state;
SET GLOBAL slow_query_log = @old_slow_log_state;
SET @old_general_log_state = @@global.general_log;
SET @old_slow_log_state = @@global.slow_query_log;
SHOW VARIABLES LIKE 'general_log';
Variable_name	Value
general_log	ON
SHOW VARIABLES LIKE 'log';
Variable_name	Value
log	ON
SELECT @@general_log, @@log;
@@general_log	@@log
1	1
SET GLOBAL log = 0;
Warnings:
Warning	1287	The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead
SHOW VARIABLES LIKE 'general_log';
Variable_name	Value
general_log	OFF
SHOW VARIABLES LIKE 'log';
Variable_name	Value
log	OFF
SELECT @@general_log, @@log;
@@general_log	@@log
0	0
SET GLOBAL general_log = 1;
SHOW VARIABLES LIKE 'general_log';
Variable_name	Value
general_log	ON
SHOW VARIABLES LIKE 'log';
Variable_name	Value
log	ON
SELECT @@general_log, @@log;
@@general_log	@@log
1	1
SHOW VARIABLES LIKE 'slow_query_log';
Variable_name	Value
slow_query_log	OFF
SHOW VARIABLES LIKE 'log_slow_queries';
Variable_name	Value
log_slow_queries	OFF
SELECT @@slow_query_log, @@log_slow_queries;
@@slow_query_log	@@log_slow_queries
0	0
SET GLOBAL log_slow_queries = 0;
Warnings:
Warning	1287	The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead
SHOW VARIABLES LIKE 'slow_query_log';
Variable_name	Value
slow_query_log	OFF
SHOW VARIABLES LIKE 'log_slow_queries';
Variable_name	Value
log_slow_queries	OFF
SELECT @@slow_query_log, @@log_slow_queries;
@@slow_query_log	@@log_slow_queries
0	0
SET GLOBAL slow_query_log = 1;
SHOW VARIABLES LIKE 'slow_query_log';
Variable_name	Value
slow_query_log	ON
SHOW VARIABLES LIKE 'log_slow_queries';
Variable_name	Value
log_slow_queries	ON
SELECT @@slow_query_log, @@log_slow_queries;
@@slow_query_log	@@log_slow_queries
1	1
SET GLOBAL general_log = @old_general_log_state;
SET GLOBAL slow_query_log = @old_slow_log_state;
set @old_general_log_file= @@global.general_log_file;
set @old_slow_query_log_file= @@global.slow_query_log_file;
set global general_log_file= concat('/not exiting path/log.maste', 'r');
ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master'
set global general_log_file= NULL;
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'NULL'
set global slow_query_log_file= concat('/not exiting path/log.maste', 'r');
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not exiting path/log.master'
set global slow_query_log_file= NULL;
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL'
set global general_log_file= @old_general_log_file;
set global slow_query_log_file= @old_slow_query_log_file;

# --
# -- Bug#32748: Inconsistent handling of assignments to
# -- general_log_file/slow_query_log_file.
# --

SET @general_log_file_saved = @@global.general_log_file;
SET @slow_query_log_file_saved = @@global.slow_query_log_file;

SET GLOBAL general_log_file = 'bug32748.query.log';
SET GLOBAL slow_query_log_file = 'bug32748.slow.log';

SHOW VARIABLES LIKE '%log_file';
Variable_name	Value
general_log_file	bug32748.query.log
slow_query_log_file	bug32748.slow.log

SET GLOBAL general_log_file = @general_log_file_saved;
SET GLOBAL slow_query_log_file = @slow_query_log_file_saved;

# -- End of Bug#32748.
deprecated:
SET GLOBAL log = 0;
Warnings:
Warning	1287	The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead
SET GLOBAL log_slow_queries = 0;
Warnings:
Warning	1287	The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead
SET GLOBAL log = DEFAULT;
Warnings:
Warning	1287	The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead
SET GLOBAL log_slow_queries = DEFAULT;
Warnings:
Warning	1287	The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead
not deprecated:
SELECT @@global.general_log_file INTO @my_glf;
SELECT @@global.slow_query_log_file INTO @my_sqlf;
SET GLOBAL general_log = 0;
SET GLOBAL slow_query_log = 0;
SET GLOBAL general_log_file = 'WL4403_G.log';
SET GLOBAL slow_query_log_file = 'WL4403_SQ.log';
SET GLOBAL general_log_file = @my_glf;
SET GLOBAL slow_query_log_file = @my_sqlf;
SET GLOBAL general_log = DEFAULT;
SET GLOBAL slow_query_log = DEFAULT;
End of 5.1 tests