| 1 |
# WL#12393: Logging: Add new command line option for richer slow query logging |
| 2 |
|
| 3 |
# test global variable "log_slow_extra" |
| 4 |
|
| 5 |
SELECT @@global.log_slow_extra INTO @old_lse; |
| 6 |
SELECT @@global.log_output INTO @old_lo; |
| 7 |
SELECT @@global.slow_query_log INTO @old_sql; |
| 8 |
# invalid values / types |
| 9 |
SET GLOBAL log_slow_extra=symbol; |
| 10 |
ERROR 42000: Variable 'log_slow_extra' can't be set to the value of 'symbol' |
| 11 |
SET GLOBAL log_slow_extra="string"; |
| 12 |
ERROR 42000: Variable 'log_slow_extra' can't be set to the value of 'string' |
| 13 |
SET GLOBAL log_slow_extra=99; |
| 14 |
ERROR 42000: Variable 'log_slow_extra' can't be set to the value of '99' |
| 15 |
SET GLOBAL log_slow_extra=0.5; |
| 16 |
ERROR 42000: Incorrect argument type to variable 'log_slow_extra' |
| 17 |
|
| 18 |
# only GLOBAL scope is valid |
| 19 |
SET SESSION log_slow_extra=0; |
| 20 |
ERROR HY000: Variable 'log_slow_extra' is a GLOBAL variable and should be set with SET GLOBAL |
| 21 |
|
| 22 |
# valid values |
| 23 |
SET GLOBAL slow_query_log=0; |
| 24 |
SET GLOBAL log_slow_extra=0; |
| 25 |
SELECT @@global.log_slow_extra; |
| 26 |
@@global.log_slow_extra |
| 27 |
0 |
| 28 |
SET GLOBAL log_slow_extra=1; |
| 29 |
SELECT @@global.log_slow_extra; |
| 30 |
@@global.log_slow_extra |
| 31 |
1 |
| 32 |
SET GLOBAL log_slow_extra=DEFAULT; |
| 33 |
SELECT @@global.log_slow_extra; |
| 34 |
@@global.log_slow_extra |
| 35 |
0 |
| 36 |
|
| 37 |
# warnings and errors |
| 38 |
SET GLOBAL slow_query_log=1; |
| 39 |
|
| 40 |
# Switching slow query log file format while target is not FILE is legal, |
| 41 |
# but does nothing. Throw a warning! |
| 42 |
SET GLOBAL log_output="TABLE"; |
| 43 |
SELECT @@global.log_slow_extra INTO @old; |
| 44 |
SET GLOBAL log_slow_extra=1; |
| 45 |
Warnings: |
| 46 |
Warning 3795 slow query log file format changed as requested, but setting will have no effect when not actually logging to a file. |
| 47 |
# Value must have changed: |
| 48 |
SELECT @@global.log_slow_extra!=@old; |
| 49 |
@@global.log_slow_extra!=@old |
| 50 |
1 |
| 51 |
SET GLOBAL log_slow_extra=DEFAULT; |
| 52 |
Warnings: |
| 53 |
Warning 3795 slow query log file format changed as requested, but setting will have no effect when not actually logging to a file. |
| 54 |
|
| 55 |
# Switching slow query log file format while target is not FILE is legal, |
| 56 |
# but does nothing. Throw a warning! |
| 57 |
SET GLOBAL log_output="NONE"; |
| 58 |
SELECT @@global.log_slow_extra INTO @old; |
| 59 |
SET GLOBAL log_slow_extra=1; |
| 60 |
Warnings: |
| 61 |
Warning 3795 slow query log file format changed as requested, but setting will have no effect when not actually logging to a file. |
| 62 |
# Value must have changed: |
| 63 |
SELECT @@global.log_slow_extra!=@old; |
| 64 |
@@global.log_slow_extra!=@old |
| 65 |
1 |
| 66 |
SET GLOBAL log_slow_extra=DEFAULT; |
| 67 |
Warnings: |
| 68 |
Warning 3795 slow query log file format changed as requested, but setting will have no effect when not actually logging to a file. |
| 69 |
|
| 70 |
# clean up |
| 71 |
SET GLOBAL log_slow_extra=@old_lse; |
| 72 |
Warnings: |
| 73 |
Warning 3795 slow query log file format changed as requested, but setting will have no effect when not actually logging to a file. |
| 74 |
SET GLOBAL log_output=@old_lo; |
| 75 |
SET GLOBAL slow_query_log=@old_sql; |
| 76 |
TRUNCATE TABLE mysql.general_log; |
| 77 |
TRUNCATE TABLE mysql.slow_log; |
| 78 |
|
| 79 |
# READY |