2009-01-13 14:09:24 +01:00
|
|
|
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;
|
2006-06-19 18:30:55 +05:00
|
|
|
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
|
2006-06-22 19:20:29 +05:00
|
|
|
TIMESTAMP USER_HOST # 1 Query create table t1(f1 int)
|
|
|
|
TIMESTAMP USER_HOST # 1 Query select * from mysql.general_log
|
2006-06-19 18:30:55 +05:00
|
|
|
set global general_log= OFF;
|
|
|
|
drop table t1;
|
|
|
|
select * from mysql.general_log;
|
|
|
|
event_time user_host thread_id server_id command_type argument
|
2006-06-22 19:20:29 +05:00
|
|
|
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
|
2006-06-19 18:30:55 +05:00
|
|
|
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
|
2009-01-13 14:09:24 +01:00
|
|
|
# Establish connection con1 (user=root)
|
|
|
|
# Switch to connection con1
|
|
|
|
set @long_query_time = <long_query_time>;
|
|
|
|
set session long_query_time = @long_query_time;
|
|
|
|
select sleep(@long_query_time + 1);
|
|
|
|
sleep(@long_query_time + 1)
|
2006-06-19 18:30:55 +05:00
|
|
|
0
|
2007-08-08 15:49:19 +04:00
|
|
|
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
|
2006-06-19 18:30:55 +05:00
|
|
|
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
|
2009-01-13 14:09:24 +01:00
|
|
|
# Switch to connection default
|
2006-06-19 18:30:55 +05:00
|
|
|
set global slow_query_log= ON;
|
2009-01-13 14:09:24 +01:00
|
|
|
# Switch to connection con1
|
|
|
|
set session long_query_time = @long_query_time;
|
|
|
|
select sleep(@long_query_time + 1);
|
|
|
|
sleep(@long_query_time + 1)
|
2006-06-19 18:30:55 +05:00
|
|
|
0
|
2007-08-08 15:49:19 +04:00
|
|
|
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
|
2006-06-19 18:30:55 +05:00
|
|
|
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
|
2009-01-13 14:09:24 +01:00
|
|
|
TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(@long_query_time + 1)
|
|
|
|
# Switch to connection default
|
2006-06-19 18:30:55 +05:00
|
|
|
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
|
2006-06-22 19:20:29 +05:00
|
|
|
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
|
2006-06-19 18:30:55 +05:00
|
|
|
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
|
2009-01-13 14:09:24 +01:00
|
|
|
set global general_log_file='/not existing path/log.master';
|
|
|
|
ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not existing path/log.master'
|
2007-02-20 21:00:05 +01:00
|
|
|
set global general_log_file='MYSQLTEST_VARDIR';
|
|
|
|
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'MYSQLTEST_VARDIR'
|
2006-06-19 18:30:55 +05:00
|
|
|
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;
|
2006-07-04 22:37:32 +02:00
|
|
|
set global general_log_file='MYSQLTEST_VARDIR/tmp/log.master';
|
2006-06-19 18:30:55 +05: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;
|
|
|
|
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
|
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 00:31:06 -06:00
|
|
|
log_output FILE
|
2006-06-19 18:30:55 +05:00
|
|
|
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
|
2006-06-22 19:20:29 +05:00
|
|
|
TIMESTAMP USER_HOST # 1 Query drop table t1
|
|
|
|
TIMESTAMP USER_HOST # 1 Query select * from mysql.general_log
|
2009-01-13 14:09:24 +01:00
|
|
|
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 00:31:06 -06: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;
|
|
|
|
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;
|
2009-01-13 14:09:24 +01:00
|
|
|
SET GLOBAL general_log = @old_general_log;
|
|
|
|
SET GLOBAL slow_query_log = @old_slow_query_log;
|
|
|
|
SET GLOBAL general_log = ON;
|
2007-10-25 14:03:24 +04:00
|
|
|
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;
|
2008-10-06 11:29:42 +02:00
|
|
|
Warnings:
|
|
|
|
Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead
|
2007-10-25 14:03:24 +04:00
|
|
|
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;
|
2008-10-06 11:29:42 +02:00
|
|
|
Warnings:
|
|
|
|
Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead
|
2007-10-25 14:03:24 +04:00
|
|
|
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
|
2009-01-13 14:09:24 +01:00
|
|
|
SET GLOBAL general_log = @old_general_log;
|
|
|
|
SET GLOBAL slow_query_log = @old_slow_query_log;
|
|
|
|
SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r');
|
|
|
|
ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not existing path/log.master'
|
|
|
|
SET GLOBAL general_log_file= NULL;
|
2007-10-16 17:19:07 +05:00
|
|
|
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'NULL'
|
2009-01-13 14:09:24 +01:00
|
|
|
SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r');
|
|
|
|
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not existing path/log.master'
|
|
|
|
SET GLOBAL slow_query_log_file= NULL;
|
2007-10-16 17:19:07 +05:00
|
|
|
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL'
|
2009-01-13 14:09:24 +01:00
|
|
|
SET GLOBAL general_log_file= @old_general_log_file;
|
|
|
|
SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
|
2008-03-28 21:46:18 +03:00
|
|
|
|
|
|
|
# --
|
|
|
|
# -- Bug#32748: Inconsistent handling of assignments to
|
2009-01-13 14:09:24 +01:00
|
|
|
# -- general_log_file/slow_query_log_file.
|
2008-03-28 21:46:18 +03:00
|
|
|
# --
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2009-01-13 14:09:24 +01:00
|
|
|
SET GLOBAL general_log_file = @old_general_log_file;
|
|
|
|
SET GLOBAL slow_query_log_file = @old_slow_query_log_file;
|
2008-03-28 21:46:18 +03:00
|
|
|
|
|
|
|
# -- End of Bug#32748.
|
2008-10-06 11:29:42 +02:00
|
|
|
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;
|
2009-01-13 14:09:24 +01:00
|
|
|
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;
|
2010-05-12 13:19:12 +02:00
|
|
|
#
|
|
|
|
# Bug #49756 Rows_examined is always 0 in the slow query log
|
|
|
|
# for update statements
|
|
|
|
#
|
|
|
|
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;
|
|
|
|
TRUNCATE TABLE mysql.slow_log;
|
|
|
|
CREATE TABLE t1 (a INT);
|
|
|
|
CREATE TABLE t2 (b INT, PRIMARY KEY (b));
|
|
|
|
INSERT INTO t2 VALUES (3),(4);
|
|
|
|
INSERT INTO t1 VALUES (1+sleep(.01)),(2);
|
|
|
|
INSERT INTO t1 SELECT b+sleep(.01) from t2;
|
|
|
|
UPDATE t1 SET a=a+sleep(.01) WHERE a>2;
|
|
|
|
UPDATE t1 SET a=a+sleep(.01) ORDER BY a DESC;
|
|
|
|
UPDATE t2 set b=b+sleep(.01) limit 1;
|
|
|
|
UPDATE t1 SET a=a+sleep(.01) WHERE a in (SELECT b from t2);
|
|
|
|
DELETE FROM t1 WHERE a=a+sleep(.01) ORDER BY a LIMIT 2;
|
|
|
|
SELECT rows_examined,sql_text FROM mysql.slow_log;
|
|
|
|
rows_examined sql_text
|
|
|
|
0 INSERT INTO t1 VALUES (1+sleep(.01)),(2)
|
|
|
|
2 INSERT INTO t1 SELECT b+sleep(.01) from t2
|
|
|
|
4 UPDATE t1 SET a=a+sleep(.01) WHERE a>2
|
|
|
|
8 UPDATE t1 SET a=a+sleep(.01) ORDER BY a DESC
|
Bug #30584: delete with order by and limit clauses does not
use limit efficiently
Bug #36569: UPDATE ... WHERE ... ORDER BY... always does a
filesort even if not required
Also two bugs reported after QA review (before the commit
of bugs above to public trees, no documentation needed):
Bug #53737: Performance regressions after applying patch
for bug 36569
Bug #53742: UPDATEs have no effect after applying patch
for bug 36569
Execution of single-table UPDATE and DELETE statements did not use the
same optimizer as was used in the compilation of SELECT statements.
Instead, it had an optimizer of its own that did not take into account
that you can omit sorting by retrieving rows using an index.
Extra optimization has been added: when applicable, single-table
UPDATE/DELETE statements use an existing index instead of filesort. A
corresponding SELECT query would do the former.
Also handling of the DESC ordering expression has been added when
reverse index scan is applicable.
From now on most single table UPDATE and DELETE statements show the
same disk access patterns as the corresponding SELECT query. We verify
this by comparing the result of SHOW STATUS LIKE 'Sort%
Currently the get_index_for_order function
a) checks quick select index (if any) for compatibility with the
ORDER expression list or
b) chooses the cheapest available compatible index, but only if
the index scan is cheaper than filesort.
Second way is implemented by the new test_if_cheaper_ordering
function (extracted part the test_if_skip_sort_order()).
mysql-test/r/log_state.result:
Updated result for optimized query, bug #36569.
mysql-test/r/single_delete_update.result:
Test case for bug #30584, bug #36569 and bug #53742.
mysql-test/r/update.result:
Updated result for optimized query, bug #30584.
Note:
"Handler_read_last 1" omitted, see bug 52312:
lost Handler_read_last status variable.
mysql-test/t/single_delete_update.test:
Test case for bug #30584, bug #36569 and bug #53742.
sql/opt_range.cc:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
* get_index_for_order() has been rewritten entirely and moved
to sql_select.cc
New QUICK_RANGE_SELECT::make_reverse method has been added.
sql/opt_range.h:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
* get_index_for_order() has been rewritten entirely and moved
to sql_select.cc
New functions:
* QUICK_SELECT_I::make_reverse()
* SQL_SELECT::set_quick()
sql/records.cc:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
* init_read_record_idx() has been modified to allow reverse index scan
New functions:
* rr_index_last()
* rr_index_desc()
sql/records.h:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
init_read_record_idx() has been modified to allow reverse index scan
sql/sql_delete.cc:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
mysql_delete: an optimization has been added to skip
unnecessary sorting with ORDER BY clause where select
result ordering is acceptable.
sql/sql_select.cc:
Bug #30584, bug #36569, bug #53737, bug #53742:
UPDATE/DELETE ... WHERE ... ORDER BY... always does a filesort
even if not required
The const_expression_in_where function has been modified
to accept both Item and Field pointers.
New functions:
* get_index_for_order()
* test_if_cheaper_ordering() has been extracted from
test_if_skip_sort_order() to share with get_index_for_order()
* simple_remove_const()
sql/sql_select.h:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
New functions:
* test_if_cheaper_ordering()
* simple_remove_const()
* get_index_for_order()
sql/sql_update.cc:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
mysql_update: an optimization has been added to skip
unnecessary sorting with ORDER BY clause where a select
result ordering is acceptable.
sql/table.cc:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
New functions:
* TABLE::update_const_key_parts()
* is_simple_order()
sql/table.h:
Bug #30584, bug #36569: UPDATE/DELETE ... WHERE ... ORDER BY...
always does a filesort even if not required
New functions:
* TABLE::update_const_key_parts()
* is_simple_order()
2010-06-23 00:32:29 +04:00
|
|
|
1 UPDATE t2 set b=b+sleep(.01) limit 1
|
2010-05-12 13:19:12 +02:00
|
|
|
4 UPDATE t1 SET a=a+sleep(.01) WHERE a in (SELECT b from t2)
|
|
|
|
6 DELETE FROM t1 WHERE a=a+sleep(.01) ORDER BY a LIMIT 2
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
TRUNCATE TABLE mysql.slow_log;
|
|
|
|
# end of bug#49756
|
2007-10-25 14:03:24 +04:00
|
|
|
End of 5.1 tests
|
2009-10-15 11:09:31 +02:00
|
|
|
|
|
|
|
# --
|
|
|
|
# -- Bug#38124: "general_log_file" variable silently unset when
|
|
|
|
# -- using expression
|
|
|
|
# --
|
|
|
|
SET GLOBAL general_log_file = DEFAULT;
|
|
|
|
SELECT @@general_log_file INTO @my_glf;
|
|
|
|
SET GLOBAL general_log_file = 'BUG38124.LOG';
|
|
|
|
SELECT @@general_log_file;
|
|
|
|
@@general_log_file
|
|
|
|
BUG38124.LOG
|
|
|
|
SET GLOBAL general_log_file = concat('BUG38124-2.LOG');
|
|
|
|
SELECT @@general_log_file;
|
|
|
|
@@general_log_file
|
|
|
|
BUG38124-2.LOG
|
|
|
|
SET GLOBAL general_log_file = substr('BUG38124-2.LOG',3,6);
|
|
|
|
SELECT @@general_log_file;
|
|
|
|
@@general_log_file
|
|
|
|
G38124
|
|
|
|
SET GLOBAL general_log_file = DEFAULT;
|
|
|
|
SELECT @@general_log_file = @my_glf;
|
|
|
|
@@general_log_file = @my_glf
|
|
|
|
1
|
|
|
|
SET GLOBAL general_log_file = @old_general_log_file;
|
2009-01-13 14:09:24 +01:00
|
|
|
# Close connection con1
|
2010-05-12 13:19:12 +02:00
|
|
|
SET GLOBAL long_query_time = DEFAULT;
|
|
|
|
SET GLOBAL log_output = @old_log_output;
|
2009-01-13 14:09:24 +01:00
|
|
|
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;
|