List:Commits« Previous MessageNext Message »
From:Nirbhay Choubey Date:June 20 2011 9:13am
Subject:bzr commit into mysql-trunk branch (nirbhay.choubey:3222) Bug#12368203
View as plain text  
#At file:///home/nirbhay/Project/mysql/repo/bugs/mysql-trunk.60878/ based on revid:inaam.rana@stripped

 3222 Nirbhay Choubey	2011-06-20
      Bug#12368203 - 60878: mysqladmin doesn't support flushing
                     specific logs
      
      mysqladmin currently supports a command 'flush-logs'
      to flush all log types. However, mysqladmin offered
      no support to flush specific logs.
      
      Added sub-commands to flush following (all) log types:
      binary, engine, error, general, relay, slow.
     @ client/mysqladmin.cc
        Bug#12368203 - 60878: mysqladmin doesn't support flushing
                       specific logs
        
        mysqladmin will now optionally accept sub-commands
        to flush logs of specific type.
        
        mysqladmin flush-logs [log_type]
     @ mysql-test/r/bug60878.result
        Bug#12368203 - 60878: mysqladmin doesn't support flushing
                       specific logs
        
        Added test for Bug#12368203.
     @ mysql-test/t/bug60878-master.opt
        Bug#12368203 - 60878: mysqladmin doesn't support flushing
                       specific logs
        
        Added test for Bug#12368203.
     @ mysql-test/t/bug60878.test
        Bug#12368203 - 60878: mysqladmin doesn't support flushing
                       specific logs
        
        Added test for Bug#12368203.

    added:
      mysql-test/r/bug60878.result
      mysql-test/t/bug60878-master.opt
      mysql-test/t/bug60878.test
    modified:
      client/mysqladmin.cc
=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2011-06-06 10:29:45 +0000
+++ b/client/mysqladmin.cc	2011-06-20 09:13:02 +0000
@@ -869,11 +869,32 @@ static int execute_commands(MYSQL *mysql
     }
     case ADMIN_FLUSH_LOGS:
     {
-      if (mysql_refresh(mysql,REFRESH_LOG))
+      if ((argc == 2) &&
+          ((!my_strcasecmp(&my_charset_latin1, argv[1], "binary")) ||
+           (!my_strcasecmp(&my_charset_latin1, argv[1], "engine")) ||
+           (!my_strcasecmp(&my_charset_latin1, argv[1], "error")) ||
+           (!my_strcasecmp(&my_charset_latin1, argv[1], "general")) ||
+           (!my_strcasecmp(&my_charset_latin1, argv[1], "relay")) ||
+           (!my_strcasecmp(&my_charset_latin1, argv[1], "slow"))))
+      {
+        char buff[42];
+        sprintf(buff, "FLUSH /*!50503 %s */ LOGS", argv[1]);
+        if (mysql_query(mysql, buff))
+        {
+          my_printf_error(0, "refresh failed; error: '%s'", error_flags,
+                          mysql_error(mysql));
+          return -1;
+        }
+        argc--; argv++;
+      }
+      else
       {
-	my_printf_error(0, "refresh failed; error: '%s'", error_flags,
-			mysql_error(mysql));
-	return -1;
+        if (mysql_refresh(mysql,REFRESH_LOG))
+        {
+          my_printf_error(0, "refresh failed; error: '%s'", error_flags,
+                          mysql_error(mysql));
+          return -1;
+        }
       }
       break;
     }

=== added file 'mysql-test/r/bug60878.result'
--- a/mysql-test/r/bug60878.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/bug60878.result	2011-06-20 09:13:02 +0000
@@ -0,0 +1,30 @@
+include/master-slave.inc
+[connection master]
+# Test if mysqladmin supports 'flush-logs error' command.
+# Make sure binary logs was not be flushed
+# after execute 'flush error logs' statement.
+# Make sure relay logs was not be flushed 
+# after execute 'flush error logs' statement.
+# Test if mysqladmin supports 'flush-logs relay' command.
+# Check if 'slave-relay-bin.000003' file is created
+# after executing 'flush-logs relay' command.
+# Make sure binary logs was not be flushed
+# after executeing 'flush-logs relay' command.
+# Test if mysqladmin supports 'flush-logs slow' command.
+# Make sure binary logs were not be flushed
+# after executing 'flush-logs slow' command.
+# Test if mysqladmin supports 'flush-logs general' command.
+# Make sure binary logs was not be flushed
+# after execute 'flush-logs general' command.
+# Test if mysqladmin supports 'flush-logs engine' command.
+# Make sure binary logs was not be flushed
+# after execute 'flush-logs engnine' statement.
+# Make sure the 'master-bin.000002' file does not
+# exist before execution of 'flush-logs binary' command.
+# Test if mysqladmin supports 'flush-logs binary' command.
+# Check if 'master-bin.000002' file is created
+# after execution of 'flush-logs binary' statement.
+# Test if 'flush-logs' command works fine and flush all the logs.
+# Check 'master-bin.000003' is created
+# after executing 'flush-logs' command.
+include/rpl_end.inc

=== added file 'mysql-test/t/bug60878-master.opt'
--- a/mysql-test/t/bug60878-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/bug60878-master.opt	2011-06-20 09:13:02 +0000
@@ -0,0 +1 @@
+--log-error=$MYSQLTEST_VARDIR/tmp/master_log.err

=== added file 'mysql-test/t/bug60878.test'
--- a/mysql-test/t/bug60878.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/bug60878.test	2011-06-20 09:13:02 +0000
@@ -0,0 +1,110 @@
+#
+# [ Based on ./suite/rpl/t/rpl_flush_logs.test ]
+# This test verifies if the 'flush individual logs' command
+# works fine with mysqladmin.  
+#
+
+--source include/master-slave.inc
+--source include/have_binlog_format_statement.inc
+
+connection master;
+#
+# Test 'flush-logs error' command.
+#
+--echo # Test if mysqladmin supports 'flush-logs error' command.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs error
+
+file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
+
+--echo # Make sure binary logs was not be flushed
+--echo # after execute 'flush error logs' statement.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+
+sync_slave_with_master;
+--echo # Make sure relay logs was not be flushed 
+--echo # after execute 'flush error logs' statement.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000003;
+
+connection master;
+#
+# Test 'flush-logs relay' command.
+#
+--echo # Test if mysqladmin supports 'flush-logs relay' command.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs relay
+
+sync_slave_with_master;
+--echo # Check if 'slave-relay-bin.000003' file is created
+--echo # after executing 'flush-logs relay' command.
+file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000003;
+
+connection master;
+--echo # Make sure binary logs was not be flushed
+--echo # after executeing 'flush-logs relay' command.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+
+#
+# Test 'flush-logs slow' command.
+#
+--echo # Test if mysqladmin supports 'flush-logs slow' command.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs slow
+
+--echo # Make sure binary logs were not be flushed
+--echo # after executing 'flush-logs slow' command.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+
+#
+# Test 'flush-logs general' command.
+#
+--echo # Test if mysqladmin supports 'flush-logs general' command.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs general
+
+--echo # Make sure binary logs was not be flushed
+--echo # after execute 'flush-logs general' command.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+
+#
+# Test 'flush-logs engine' command.
+#
+--echo # Test if mysqladmin supports 'flush-logs engine' command.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs engine
+
+--echo # Make sure binary logs was not be flushed
+--echo # after execute 'flush-logs engnine' statement.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+
+#
+# Test 'flush-logs binary' command.
+#
+--echo # Make sure the 'master-bin.000002' file does not
+--echo # exist before execution of 'flush-logs binary' command.
+--error 1
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+
+--echo # Test if mysqladmin supports 'flush-logs binary' command.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs binary
+
+--echo # Check if 'master-bin.000002' file is created
+--echo # after execution of 'flush-logs binary' statement.
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000001;
+
+#
+# Test 'flush-logs' command
+#
+connection master;
+
+--echo # Test if 'flush-logs' command works fine and flush all the logs.
+
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT flush-logs
+
+--echo # Check 'master-bin.000003' is created
+--echo # after executing 'flush-logs' command.
+file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000003;
+
+--source include/rpl_end.inc


Attachment: [text/bzr-bundle] bzr/nirbhay.choubey@oracle.com-20110620091302-xwhlcjn3m96bru20.bundle
Thread
bzr commit into mysql-trunk branch (nirbhay.choubey:3222) Bug#12368203Nirbhay Choubey20 Jun