List:Commits« Previous MessageNext Message »
From:Chuck Bell Date:November 13 2009 3:01pm
Subject:bzr commit into mysql-6.0-backup branch (charles.bell:2891) Bug#48353
View as plain text  
#At file:///Users/cbell/source/bzr/mysql-6.0-bug-48353/ based on revid:charles.bell@stripped

 2891 Chuck Bell	2009-11-13
      BUG#48353 : Add PURGE BACKUPLOGS to mysqladmin
      
      It has been decided the PURGE BACKUP LOGS is a companion 
      to the FLUSH BACKUP LOGS command and should be added to 
      the options for mysqladmin.
      
      This patch adds the PURGE BACKUP LOGS command. There are
      three forms of this command:
      
        PURGE BACKUP LOGS
        PURGE BACKUP LOGS TO <id>
        PURGE BACKUP LOGS BEFORE <date>
      
      This patch adds the following options to mysqladmin:
      
        purge-backup-logs       Purge backup logs
        purge-backup-logs-id    Purge backup logs up to a given backup_id
        purge-backup-logs-date  Purge backup logs before a given date
      
      Note: WL#5165  was created to provide more advanced testing of
            FLUSH/PURGE BACKUP LOGS.
     @ client/mysqladmin.cc
        Added new commands to mysqladmin.
     @ mysql-test/suite/backup/r/backup_logs_output.result
        Corrected result file.
     @ mysql-test/suite/backup/t/backup_logs_output.test
        Added tests for new commands.

    modified:
      client/mysqladmin.cc
      mysql-test/suite/backup/r/backup_logs_output.result
      mysql-test/suite/backup/t/backup_logs_output.test
=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2009-11-13 01:54:16 +0000
+++ b/client/mysqladmin.cc	2009-11-13 15:01:28 +0000
@@ -98,7 +98,7 @@ enum commands {
   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_BACKUP_LOGS,
-  ADMIN_PURGE_BACKUP_LOGS
+  ADMIN_PURGE_BUP_LOGS,   ADMIN_PURGE_BUP_LOGS_ID, ADMIN_PURGE_BUP_LOGS_DATE
 };
 static const char *command_names[]= {
   "create",               "drop",                "shutdown",
@@ -109,7 +109,7 @@ static const char *command_names[]= {
   "ping",                 "extended-status",     "flush-status",
   "flush-privileges",     "start-slave",         "stop-slave",
   "flush-threads",        "old-password",        "flush-backup-logs",
-  "purge-backup-logs",
+  "purge-backup-logs",    "purge-backup-logs-id", "purge-backup-logs-date",
   NullS
 };
 
@@ -897,7 +897,14 @@ static int execute_commands(MYSQL *mysql
       }
       break;
     }
-    case ADMIN_PURGE_BACKUP_LOGS:
+    /*
+      We have three forms of this command:
+      
+      PURGE BACKUP LOGS
+      PURGE BACKUP LOGS TO <id>
+      PURGE BACKUP LOGS BEFORE <date>
+    */
+    case ADMIN_PURGE_BUP_LOGS:
     {
       if (mysql_query(mysql,"purge backup logs"))
       {
@@ -907,6 +914,43 @@ static int execute_commands(MYSQL *mysql
       }
       break;
     }
+    case ADMIN_PURGE_BUP_LOGS_ID:
+    {
+      char buff[FN_REFLEN+20];
+      if (argc < 2)
+      {
+	      my_printf_error(0, "Too few arguments to purge backup logs to", 
+                        error_flags);
+	      return 1;
+      }
+      sprintf(buff,"PURGE BACKUP LOGS TO %s", argv[1]);
+      if (mysql_query(mysql, buff))
+      {
+        my_printf_error(0,"refresh failed; error: '%s'", error_flags,
+                        mysql_error(mysql));
+        return -1;
+      }
+      argc--; argv++;
+      break;
+    }
+    case ADMIN_PURGE_BUP_LOGS_DATE:
+    {
+      char buff[FN_REFLEN+20];
+      if (argc < 2)
+      {
+	      my_printf_error(0, "Too few arguments to purge backup logs before", 
+                        error_flags);
+      }
+      sprintf(buff,"PURGE BACKUP LOGS BEFORE '%s'", argv[1]);
+      if (mysql_query(mysql, buff))
+      {
+        my_printf_error(0,"refresh failed; error: '%s'", error_flags,
+                        mysql_error(mysql));
+        return -1;
+      }
+      argc--; argv++;
+      break;
+    }
     case ADMIN_FLUSH_STATUS:
     {
       if (mysql_query(mysql,"flush status"))
@@ -1118,8 +1162,10 @@ 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\
-  purge-backup-logs     Purge backup logs\n\
+  flush-backup-logs       Flush backup logs\n\
+  purge-backup-logs       Purge backup logs\n\
+  purge-backup-logs-id    Purge backup logs up to a given backup_id\n\
+  purge-backup-logs-date  Purge backup logs before a given date\n\
   flush-status		Clear status variables\n\
   flush-tables          Flush all tables\n\
   flush-threads         Flush the thread cache\n\

=== modified file 'mysql-test/suite/backup/r/backup_logs_output.result'
--- a/mysql-test/suite/backup/r/backup_logs_output.result	2009-11-13 01:54:16 +0000
+++ b/mysql-test/suite/backup/r/backup_logs_output.result	2009-11-13 15:01:28 +0000
@@ -241,6 +241,24 @@ Test flush-backup-logs from mysqladmin
 #
 # Test purge-backup-logs from mysqladmin
 #
+#
+# Do another backup here then try next version of purge backup logs 
+#
+BACKUP DATABASE bup_log TO 'bup_log.bak';
+backup_id
+#
+#
+# Test purge-backup-logs-to from mysqladmin
+#
+#
+# Do another backup here then try next version of purge backup logs 
+#
+BACKUP DATABASE bup_log TO 'bup_log.bak';
+backup_id
+#
+#
+# Test purge-backup-logs-date from mysqladmin
+#
 SET GLOBAL backup_history_log=0;
 SET GLOBAL backup_progress_log=0;
 Should show 'OFF'

=== modified file 'mysql-test/suite/backup/t/backup_logs_output.test'
--- a/mysql-test/suite/backup/t/backup_logs_output.test	2009-11-13 01:54:16 +0000
+++ b/mysql-test/suite/backup/t/backup_logs_output.test	2009-11-13 15:01:28 +0000
@@ -276,6 +276,30 @@ FLUSH BACKUP LOGS;
 --echo #
 --exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT  -u root --password= purge-backup-logs 2>&1
 
+--echo #
+--echo # Do another backup here then try next version of purge backup logs 
+--echo #
+--remove_file $MYSQLD_BACKUPDIR/bup_log.bak
+--replace_column 1 #
+BACKUP DATABASE bup_log TO 'bup_log.bak';
+
+--echo #
+--echo # Test purge-backup-logs-to from mysqladmin
+--echo #
+--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT  -u root --password= purge-backup-logs-id 99999 2>&1
+
+--echo #
+--echo # Do another backup here then try next version of purge backup logs 
+--echo #
+--remove_file $MYSQLD_BACKUPDIR/bup_log.bak
+--replace_column 1 #
+BACKUP DATABASE bup_log TO 'bup_log.bak';
+
+--echo #
+--echo # Test purge-backup-logs-date from mysqladmin
+--echo #
+--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT  -u root --password= purge-backup-logs-date '2024-12-31 23:15:10' 2>&1
+
 --file_exists $MYSQLD_DATADIR/backup_history.log
 --file_exists $MYSQLD_DATADIR/backup_progress.log
 


Attachment: [text/bzr-bundle] bzr/charles.bell@sun.com-20091113150128-fgh4n9x09v3dmw1h.bundle
Thread
bzr commit into mysql-6.0-backup branch (charles.bell:2891) Bug#48353Chuck Bell13 Nov
  • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2891)Bug#48353Thava Alagu16 Nov
    • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2891)Bug#48353Ritheesh Vedire16 Nov
    • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2891)Bug#48353Charles Bell16 Nov
      • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2891)Bug#48353Thava Alagu16 Nov