List:Commits« Previous MessageNext Message »
From:Ritheesh Vedire Date:October 21 2009 12:26pm
Subject:bzr commit into mysql-6.0-backup branch (ritheesh.vedire:2880)
Bug#47493
View as plain text  
#At file:///home/rith/Work/MySQl/bug47493/ based on revid:rafal.somla@stripped

 2880 Ritheesh Vedire	2009-10-21
      BUG#47493:  Add 'flush-backup-logs' to mysqladmin
     @ client/mysqladmin.cc
        used already existing sql command  'flush backup logs' .

    added:
      mysql-test/suite/backup/r/backup_logs_mysqladmin_flush.result
      mysql-test/suite/backup/t/backup_logs_mysqladmin_flush.test
    modified:
      client/mysqladmin.cc
=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2009-10-12 09:08:34 +0000
+++ b/client/mysqladmin.cc	2009-10-21 12:25:57 +0000
@@ -97,7 +97,7 @@ enum commands {
   ADMIN_FLUSH_HOSTS,      ADMIN_FLUSH_TABLES,    ADMIN_PASSWORD,
   ADMIN_PING,             ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS,
   ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE,     ADMIN_STOP_SLAVE,
-  ADMIN_FLUSH_THREADS,    ADMIN_OLD_PASSWORD
+  ADMIN_FLUSH_THREADS,    ADMIN_OLD_PASSWORD,    ADMIN_FLUSH_BACKUP_LOGS
 };
 static const char *command_names[]= {
   "create",               "drop",                "shutdown",
@@ -107,7 +107,7 @@ static const char *command_names[]= {
   "flush-hosts",          "flush-tables",        "password",
   "ping",                 "extended-status",     "flush-status",
   "flush-privileges",     "start-slave",         "stop-slave",
-  "flush-threads","old-password",
+  "flush-threads",        "old-password",        "flush-backup-logs",
   NullS
 };
 
@@ -885,6 +885,16 @@ static int execute_commands(MYSQL *mysql
       }
       break;
     }
+    case ADMIN_FLUSH_BACKUP_LOGS:
+      {
+	if (mysql_query(mysql,"flush backup logs"))
+	  {
+	    my_printf_error(0,"refresh failed; error: '%s'", error_flags,
+			   mysql_error(mysql));
+	    return -1;
+	  }
+	break;
+      }
     case ADMIN_FLUSH_STATUS:
     {
       if (mysql_query(mysql,"flush status"))
@@ -1096,6 +1106,7 @@ static void usage(void)
   extended-status       Gives an extended status message from the server\n\
   flush-hosts           Flush all cached hosts\n\
   flush-logs            Flush all logs\n\
+  flush-backup-logs     Flush backup logs\n\
   flush-status		Clear status variables\n\
   flush-tables          Flush all tables\n\
   flush-threads         Flush the thread cache\n\

=== added file 'mysql-test/suite/backup/r/backup_logs_mysqladmin_flush.result'
--- a/mysql-test/suite/backup/r/backup_logs_mysqladmin_flush.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_logs_mysqladmin_flush.result	2009-10-21 12:25:57 +0000
@@ -0,0 +1,85 @@
+SET @@global.log_backup_output = 'FILE,TABLE';
+turning backup logs  on
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+Display backup variables
+SHOW VARIABLES LIKE 'backup_history_log';
+Variable_name	Value
+backup_history_log	ON
+SHOW VARIABLES LIKE 'backup_progress_log';
+Variable_name	Value
+backup_progress_log	ON
+SHOW VARIABLES LIKE 'log_backup_output';
+Variable_name	Value
+log_backup_output	FILE,TABLE
+
+Now starting real tests
+
+DROP DATABASE IF EXISTS backup_logs;
+CREATE DATABASE backup_logs;
+Create table and populate with data.
+CREATE TABLE backup_logs.t1 (a char(30));
+CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
+CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("04 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("05 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("06 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("07 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("01 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("02 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("03 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("04 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("05 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("06 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("01 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("02 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("03 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("04 Test #1 - progress");
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup1.bak';
+backup_id
+#
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup2.bak';
+backup_id
+#
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup3.bak';
+backup_id
+#
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup4.bak';
+backup_id
+#
+Do restore of database
+RESTORE from 'backup1.bak' OVERWRITE;
+backup_id
+#
+Do restore of database
+RESTORE from 'backup2.bak' OVERWRITE;
+backup_id
+#
+Do restore of database
+RESTORE from 'backup3.bak' OVERWRITE;
+backup_id
+#
+Do restore of database
+RESTORE from 'backup4.bak' OVERWRITE;
+backup_id
+#
+Show the size of the logs
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+8
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+36
+ping mysqld
+mysqld is alive
+Use 'mysqladmin flush-backup-logs'
+DROP DATABASE backup_logs;
+SET @@global.log_backup_output = 'TABLE';
+PURGE BACKUP LOGS;

=== added file 'mysql-test/suite/backup/t/backup_logs_mysqladmin_flush.test'
--- a/mysql-test/suite/backup/t/backup_logs_mysqladmin_flush.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_logs_mysqladmin_flush.test	2009-10-21 12:25:57 +0000
@@ -0,0 +1,149 @@
+#
+# Test flush-backup-logs from mysql admin
+
+# This test Tests if flush-backup-logs command of mysqladmin works properly
+# The choice is FILE 
+
+--source include/not_embedded.inc
+--source include/have_debug_sync.inc
+--source include/have_debug.inc
+--source include/have_innodb.inc
+
+
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $MYSQLD_BACKUPDIR=`select @@backupdir`;
+
+
+
+
+
+SET @@global.log_backup_output = 'FILE,TABLE'; 
+
+--echo turning backup logs  on
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+
+--echo Display backup variables
+SHOW VARIABLES LIKE 'backup_history_log';
+SHOW VARIABLES LIKE 'backup_progress_log';
+SHOW VARIABLES LIKE 'log_backup_output';
+
+
+--echo 
+--echo Now starting real tests
+--echo 
+
+#Create a database and some data to work with 
+
+--disable_warnings
+DROP DATABASE IF EXISTS backup_logs;
+--enable_warnings
+CREATE DATABASE backup_logs;
+
+--echo Create table and populate with data.
+
+CREATE TABLE backup_logs.t1 (a char(30));
+CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
+CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
+
+INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("04 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("05 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("06 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("07 Test #1 - progress"); 
+
+INSERT INTO backup_logs.t2 VALUES ("01 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("02 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("03 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("04 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("05 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("06 Test #1 - progress"); 
+
+INSERT INTO backup_logs.t3 VALUES ("01 Test #1 - progress"); 
+INSERT INTO backup_logs.t3 VALUES ("02 Test #1 - progress"); 
+INSERT INTO backup_logs.t3 VALUES ("03 Test #1 - progress"); 
+INSERT INTO backup_logs.t3 VALUES ("04 Test #1 - progress"); 
+
+--echo Do backup of database
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup1.bak';
+
+--echo Do backup of database
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup2.bak';
+
+--echo Do backup of database
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup3.bak';
+
+--echo Do backup of database
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup4.bak';
+
+--echo Do restore of database
+--replace_column 1 #
+RESTORE from 'backup1.bak' OVERWRITE;
+
+--echo Do restore of database
+--replace_column 1 #
+RESTORE from 'backup2.bak' OVERWRITE;
+
+--echo Do restore of database
+--replace_column 1 #
+RESTORE from 'backup3.bak' OVERWRITE;
+
+--echo Do restore of database
+--replace_column 1 #
+RESTORE from 'backup4.bak' OVERWRITE;
+
+--file_exists $MYSQLD_DATADIR/backup_history.log
+--file_exists $MYSQLD_DATADIR/backup_progress.log
+
+
+--echo Show the size of the logs
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+# BUG#47493 : use flush-backup-logs feature from mysqladmin
+
+
+--echo ping mysqld
+
+--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT  -u root --password= ping   2>&1 
+
+#Execute 'mysqladmin flush-backup-logs' 
+
+--echo Use 'mysqladmin flush-backup-logs'
+
+--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT  -u root --password= flush-backup-logs  2>&1 
+
+
+
+
+# Cleanup.
+
+DROP DATABASE backup_logs;
+--error 0,1
+--remove_file $MYSQLD_BACKUPDIR/backup1.bak
+--error 0,1
+--remove_file $MYSQLD_BACKUPDIR/backup2.bak
+--error 0,1
+--remove_file $MYSQLD_BACKUPDIR/backup3.bak
+--error 0,1
+--remove_file $MYSQLD_BACKUPDIR/backup4.bak
+--error 0,1
+--remove_file $MYSQLD_DATADIR/backup_history.log
+--error 0,1
+--remove_file $MYSQLD_DATADIR/backup_progress.log
+
+
+SET @@global.log_backup_output = 'TABLE'; 
+
+PURGE BACKUP LOGS;
+
+exit;
+
+


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-6.0-backup branch (ritheesh.vedire:2880)Bug#47493Ritheesh Vedire21 Oct