STATUS
======
Patch approved.
SUGGESTIONS
===========
1. Since variables were set to off before the below statement, remove
'still'.
> +--echo After set default still should show 'ON'
2. Would be good to also test what happens if logging is ON when set to
default.
3. I do not think it is tested whether logging is on when variables has
not been set, but I guess that is difficult since prior tests may
already have set the variables.
--
Øystein
Chuck Bell wrote:
> #At file:///C:/source/bzr/mysql-6.0-bug-40218/
>
> 2727 Chuck Bell 2008-11-04
> BUG#40218 : Setting backup_{history,progress}_log to DEFAULT turns them OFF
>
> The problem is the code is shared with the slow and query log (intentionally)
> and the
> default for these is OFF (deactivate), but the default for the backup logs is
> ON
> (activate).
>
> This patch correctly sets the default for the backup logs.
> modified:
> mysql-test/suite/backup/r/backup_logs_output.result
> mysql-test/suite/backup/t/backup_logs_output.test
> sql/set_var.cc
>
> per-file messages:
> mysql-test/suite/backup/r/backup_logs_output.result
> Corrected test result.
> mysql-test/suite/backup/t/backup_logs_output.test
> Added test to test setting default values for backup log variables
> 'backup_history_log' and 'backup_progress_log'.
> Refactored test removing TRUNCATES and use PURGE BACKUP LOGS instead.
> sql/set_var.cc
> Added code to reflect the opposite default settings for the backup logs.
> === modified file 'mysql-test/suite/backup/r/backup_logs_output.result'
> --- a/mysql-test/suite/backup/r/backup_logs_output.result 2008-10-07 17:15:44 +0000
> +++ b/mysql-test/suite/backup/r/backup_logs_output.result 2008-11-04 19:59:47 +0000
> @@ -1,4 +1,9 @@
> con1
> +Clear the logs.
> +SET @@global.backup_history_log = 'ON';
> +SET @@global.backup_progress_log = 'ON';
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> Display backup variables
> SHOW VARIABLES LIKE 'backup_history_log';
> Variable_name Value
> @@ -24,8 +29,6 @@ backup_progress_log OFF
> SHOW VARIABLES LIKE 'log_backup_output';
> Variable_name Value
> log_backup_output NONE
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> Show the size of the logs
> SELECT count(*) FROM mysql.backup_history;
> count(*)
> @@ -64,8 +67,8 @@ backup_progress_log ON
> SHOW VARIABLES LIKE 'log_backup_output';
> Variable_name Value
> log_backup_output TABLE
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> BACKUP DATABASE bup_log TO 'bup_log.bak';
> backup_id
> #
> @@ -79,6 +82,11 @@ count(*)
> FLUSH BACKUP LOGS;
> '---Checking backup logs when log_backup_output is TABLE---'
> '---and the progress log is turned off ---'
> +Clear the logs.
> +SET @@global.backup_history_log = 'ON';
> +SET @@global.backup_progress_log = 'ON';
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> SET @@global.backup_history_log = 'ON';
> SET @@global.backup_progress_log = 'OFF';
> Display backup variables
> @@ -91,8 +99,6 @@ backup_progress_log OFF
> SHOW VARIABLES LIKE 'log_backup_output';
> Variable_name Value
> log_backup_output TABLE
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> Show the size of the logs
> SELECT count(*) FROM mysql.backup_history;
> count(*)
> @@ -113,6 +119,11 @@ count(*)
> FLUSH BACKUP LOGS;
> '---Checking backup logs when log_backup_output is TABLE---'
> '---and the history log is turned off ---'
> +Clear the logs.
> +SET @@global.backup_history_log = 'ON';
> +SET @@global.backup_progress_log = 'ON';
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> SET @@global.backup_history_log = 'OFF';
> SET @@global.backup_progress_log = 'ON';
> Display backup variables
> @@ -125,8 +136,6 @@ backup_progress_log ON
> SHOW VARIABLES LIKE 'log_backup_output';
> Variable_name Value
> log_backup_output TABLE
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> Show the size of the logs
> SELECT count(*) FROM mysql.backup_history;
> count(*)
> @@ -145,6 +154,14 @@ SELECT count(*) FROM mysql.backup_progre
> count(*)
> 6
> FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> +Show the size of the logs
> +SELECT count(*) FROM mysql.backup_history;
> +count(*)
> +0
> +SELECT count(*) FROM mysql.backup_progress;
> +count(*)
> +0
> '---Checking backup logs when log_backup_output is FILE---'
> SET @@global.log_backup_output = 'FILE';
> turning backup logs back on
> @@ -160,8 +177,6 @@ backup_progress_log ON
> SHOW VARIABLES LIKE 'log_backup_output';
> Variable_name Value
> log_backup_output FILE
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> BACKUP DATABASE bup_log TO 'bup_log.bak';
> backup_id
> #
> @@ -173,6 +188,7 @@ SELECT count(*) FROM mysql.backup_progre
> count(*)
> 0
> FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> '---Checking backup logs when log_backup_output is TABLE, FILE---'
> SET @@global.log_backup_output = 'TABLE,FILE';
> Display backup variables
> @@ -185,8 +201,6 @@ backup_progress_log ON
> SHOW VARIABLES LIKE 'log_backup_output';
> Variable_name Value
> log_backup_output FILE,TABLE
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> BACKUP DATABASE bup_log TO 'bup_log.bak';
> backup_id
> #
> @@ -198,6 +212,34 @@ SELECT count(*) FROM mysql.backup_progre
> count(*)
> 6
> FLUSH BACKUP LOGS;
> +SET GLOBAL backup_history_log=0;
> +SET GLOBAL backup_progress_log=0;
> +Should show 'OFF'
> +SHOW VARIABLES LIKE 'backup%log';
> +Variable_name Value
> +backup_history_log OFF
> +backup_progress_log OFF
> +SET GLOBAL backup_history_log=1;
> +SET GLOBAL backup_progress_log=1;
> +Should show 'ON'
> +SHOW VARIABLES LIKE 'backup%log';
> +Variable_name Value
> +backup_history_log ON
> +backup_progress_log ON
> +SET GLOBAL backup_history_log=OFF;
> +SET GLOBAL backup_progress_log=OFF;
> +Should show 'OFF'
> +SHOW VARIABLES LIKE 'backup%log';
> +Variable_name Value
> +backup_history_log OFF
> +backup_progress_log OFF
> +SET GLOBAL backup_history_log=DEFAULT;
> +SET GLOBAL backup_progress_log=DEFAULT;
> +After set default still should show 'ON'
> +SHOW VARIABLES LIKE 'backup%log';
> +Variable_name Value
> +backup_history_log ON
> +backup_progress_log ON
> Cleanup
> DROP DATABASE bup_log;
> SET @@global.log_backup_output = 'TABLE';
>
> === modified file 'mysql-test/suite/backup/t/backup_logs_output.test'
> --- a/mysql-test/suite/backup/t/backup_logs_output.test 2008-10-07 17:15:44 +0000
> +++ b/mysql-test/suite/backup/t/backup_logs_output.test 2008-11-04 19:59:47 +0000
> @@ -11,6 +11,12 @@ connect (con1,localhost,root,,,,);
> --echo con1
> connection con1;
>
> +--echo Clear the logs.
> +SET @@global.backup_history_log = 'ON';
> +SET @@global.backup_progress_log = 'ON';
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> +
> --echo Display backup variables
> SHOW VARIABLES LIKE 'backup_history_log';
> SHOW VARIABLES LIKE 'backup_progress_log';
> @@ -28,9 +34,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
> SHOW VARIABLES LIKE 'backup_progress_log';
> SHOW VARIABLES LIKE 'log_backup_output';
>
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> -
> --echo Show the size of the logs
> SELECT count(*) FROM mysql.backup_history;
> SELECT count(*) FROM mysql.backup_progress;
> @@ -71,8 +74,8 @@ SHOW VARIABLES LIKE 'backup_history_log'
> SHOW VARIABLES LIKE 'backup_progress_log';
> SHOW VARIABLES LIKE 'log_backup_output';
>
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
>
> --replace_column 1 #
> BACKUP DATABASE bup_log TO 'bup_log.bak';
> @@ -91,6 +94,12 @@ FLUSH BACKUP LOGS;
> --echo '---Checking backup logs when log_backup_output is TABLE---'
> --echo '---and the progress log is turned off ---'
>
> +--echo Clear the logs.
> +SET @@global.backup_history_log = 'ON';
> +SET @@global.backup_progress_log = 'ON';
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> +
> SET @@global.backup_history_log = 'ON';
> SET @@global.backup_progress_log = 'OFF';
>
> @@ -99,9 +108,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
> SHOW VARIABLES LIKE 'backup_progress_log';
> SHOW VARIABLES LIKE 'log_backup_output';
>
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> -
> --echo Show the size of the logs
> SELECT count(*) FROM mysql.backup_history;
> SELECT count(*) FROM mysql.backup_progress;
> @@ -123,6 +129,12 @@ FLUSH BACKUP LOGS;
> --echo '---Checking backup logs when log_backup_output is TABLE---'
> --echo '---and the history log is turned off ---'
>
> +--echo Clear the logs.
> +SET @@global.backup_history_log = 'ON';
> +SET @@global.backup_progress_log = 'ON';
> +FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> +
> SET @@global.backup_history_log = 'OFF';
> SET @@global.backup_progress_log = 'ON';
>
> @@ -131,9 +143,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
> SHOW VARIABLES LIKE 'backup_progress_log';
> SHOW VARIABLES LIKE 'log_backup_output';
>
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> -
> --echo Show the size of the logs
> SELECT count(*) FROM mysql.backup_history;
> SELECT count(*) FROM mysql.backup_progress;
> @@ -146,6 +155,12 @@ SELECT count(*) FROM mysql.backup_histor
> SELECT count(*) FROM mysql.backup_progress;
>
> FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> +
> +--echo Show the size of the logs
> +SELECT count(*) FROM mysql.backup_history;
> +SELECT count(*) FROM mysql.backup_progress;
> +
> --file_exists $MYSQLTEST_VARDIR/master-data/backup_history.log
> --file_exists $MYSQLTEST_VARDIR/master-data/backup_progress.log
>
> @@ -165,15 +180,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
> SHOW VARIABLES LIKE 'backup_progress_log';
> SHOW VARIABLES LIKE 'log_backup_output';
>
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> -
> -#
> -# BUG#33364 - uncomment when purge command is implemented
> -#
> -# Purge the backup logs
> -#PURGE BACKUP LOGS;
> -
> --replace_column 1 #
> BACKUP DATABASE bup_log TO 'bup_log.bak';
>
> @@ -182,12 +188,11 @@ SELECT count(*) FROM mysql.backup_histor
> SELECT count(*) FROM mysql.backup_progress;
>
> FLUSH BACKUP LOGS;
> +PURGE BACKUP LOGS;
> +
> --file_exists $MYSQLTEST_VARDIR/master-data/backup_history.log
> --file_exists $MYSQLTEST_VARDIR/master-data/backup_progress.log
>
> -#
> -# BUG#33364 - uncomment when purge command is implemented
> -#
> # Check contents of logs for data.
> #--error 0
> #--exec grep -q "BACKUP DATABASE bup_log TO 'bup_log.bak'"
> $MYSQLTEST_VARDIR/master-data/backup_history.log
> @@ -206,15 +211,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
> SHOW VARIABLES LIKE 'backup_progress_log';
> SHOW VARIABLES LIKE 'log_backup_output';
>
> -TRUNCATE TABLE mysql.backup_history;
> -TRUNCATE TABLE mysql.backup_progress;
> -
> -#
> -# BUG#33364 - uncomment when purge command is implemented
> -#
> -# Purge the backup logs
> -#PURGE BACKUP LOGS;
> -
> --replace_column 1 #
> BACKUP DATABASE bup_log TO 'bup_log.bak';
>
> @@ -237,6 +233,34 @@ FLUSH BACKUP LOGS;
>
> --error 0,1
> --remove_file $MYSQLTEST_VARDIR/master-data/bup_log.bak
> +
> +#
> +# BUG#40218 Default setting incorrect
> +#
> +
> +SET GLOBAL backup_history_log=0;
> +SET GLOBAL backup_progress_log=0;
> +
> +--echo Should show 'OFF'
> +SHOW VARIABLES LIKE 'backup%log';
> +
> +SET GLOBAL backup_history_log=1;
> +SET GLOBAL backup_progress_log=1;
> +
> +--echo Should show 'ON'
> +SHOW VARIABLES LIKE 'backup%log';
> +
> +SET GLOBAL backup_history_log=OFF;
> +SET GLOBAL backup_progress_log=OFF;
> +
> +--echo Should show 'OFF'
> +SHOW VARIABLES LIKE 'backup%log';
> +
> +SET GLOBAL backup_history_log=DEFAULT;
> +SET GLOBAL backup_progress_log=DEFAULT;
> +
> +--echo After set default still should show 'ON'
> +SHOW VARIABLES LIKE 'backup%log';
>
> --echo Cleanup
> DROP DATABASE bup_log;
>
> === modified file 'sql/set_var.cc'
> --- a/sql/set_var.cc 2008-10-28 18:14:14 +0000
> +++ b/sql/set_var.cc 2008-11-04 19:59:47 +0000
> @@ -2489,7 +2489,15 @@ void sys_var_log_state::set_default(THD
> WARN_DEPRECATED(thd, 7,0, "@@log_slow_queries", "'@@slow_query_log'");
>
> pthread_mutex_lock(&LOCK_global_system_variables);
> - logger.deactivate_log_handler(thd, log_type);
> + /*
> + Default for general and slow log is OFF.
> + Default for backup logs is ON.
> + */
> + if ((this == &sys_var_backup_history_log) ||
> + (this == &sys_var_backup_progress_log))
> + logger.activate_log_handler(thd, log_type);
> + else
> + logger.deactivate_log_handler(thd, log_type);
> pthread_mutex_unlock(&LOCK_global_system_variables);
> }
>
>
>
--
Øystein Grøvlen, Senior Staff Engineer
Sun Microsystems, Database Group
Trondheim, Norway