List:Commits« Previous MessageNext Message »
From:Andrew Hutchings Date:March 27 2010 1:18am
Subject:bzr commit into mysql-next-mr branch (Andrew.Hutchings:3128) Bug#44071
View as plain text  
#At file:///home/linuxjedi/Programming/Bzr/mysql/mysql-next-mr-bug-44071/ based on revid:alik@stripped

 3128 Andrew Hutchings	2010-03-27
      Bug #44071	Progress should be shown in mysqldump
      
      This new patch has an extra parameter --show-progress-size which by default is set to
      10,000.  So when --verbose is used, every 10,000 lines you will get a regular status 
      output of the number of rows for a particular table dumped.

    modified:
      client/client_priv.h
      client/mysqldump.c
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
=== modified file 'client/client_priv.h'
--- a/client/client_priv.h	2010-03-09 09:52:11 +0000
+++ b/client/client_priv.h	2010-03-27 01:18:11 +0000
@@ -85,6 +85,7 @@ enum options_client
   OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
   OPT_WRITE_BINLOG, OPT_DUMP_DATE,
   OPT_INIT_COMMAND,
+  OPT_SHOW_PROGRESS_SIZE,
   OPT_MAX_CLIENT_OPTION
 };
 

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-02-24 13:52:27 +0000
+++ b/client/mysqldump.c	2010-03-27 01:18:11 +0000
@@ -104,6 +104,7 @@ static my_bool  verbose= 0, opt_no_creat
                 opt_alltspcs=0, opt_notspcs= 0;
 static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
 static ulong opt_max_allowed_packet, opt_net_buffer_length;
+static ulong total_rows= 0, show_progress_size= 0;
 static MYSQL mysql_connection,*mysql=0;
 static DYNAMIC_STRING insert_pat;
 static char  *opt_password=0,*current_user=0,
@@ -448,6 +449,9 @@ static struct my_option my_long_options[
     will give bullet-proof binlog position only if server >=4.1.3. That's the
     old "FLUSH TABLES WITH READ LOCK does not block commit" fixed bug.
   */
+  {"show-progress-size", OPT_SHOW_PROGRESS_SIZE, "Number of rows before each output progress report (requires --verbose).",
+   (uchar**) &show_progress_size, (uchar**) &show_progress_size, 0, GET_ULONG, REQUIRED_ARG,
+   10000, 0, 0, 0, 0, 0},
   {"single-transaction", OPT_TRANSACTION,
    "Creates a consistent snapshot by dumping all tables in a single "
    "transaction. Works ONLY for tables stored in storage engines which "
@@ -508,6 +512,7 @@ static void write_header(FILE *sql_file,
 static void print_value(FILE *file, MYSQL_RES  *result, MYSQL_ROW row,
                         const char *prefix,const char *name,
                         int string_value);
+static const char* fetch_named_row(MYSQL_RES *result, MYSQL_ROW row, const char* name);
 static int dump_selected_tables(char *db, char **table_names, int tables);
 static int dump_all_tables_in_db(char *db);
 static int init_dumping_views(char *);
@@ -3282,6 +3287,10 @@ static void dump_table(char *table, char
       uint i;
       ulong *lengths= mysql_fetch_lengths(res);
       rownr++;
+      if ((rownr % show_progress_size) == 0)
+      {
+        verbose_msg("-- %d of ~%d rows dumped for table %s\r", rownr, total_rows, opt_quoted_table);
+      }
       if (!extended_insert && !opt_xml)
       {
         fputs(insert_pat.str,md_result_file);
@@ -4680,6 +4689,29 @@ static void print_value(FILE *file, MYSQ
   return;                                       /* This shouldn't happen */
 } /* print_value */
 
+/**
+ * Fetches a row from a result based on a field name
+ * Returns const char* of the data in that row or NULL if not found
+ */
+
+static const char* fetch_named_row(MYSQL_RES *result, MYSQL_ROW row, const char *name)
+{
+  MYSQL_FIELD   *field;
+  mysql_field_seek(result, 0);
+  for ( ; (field= mysql_fetch_field(result)) ; row++)
+  {
+    if (!strcmp(field->name,name))
+    {
+      if (row[0] && row[0][0] && strcmp(row[0],"0")) /* Skip default */
+      {
+        mysql_field_seek(result, 0);
+        return row[0];
+      }
+    }
+  }
+  mysql_field_seek(result, 0);
+  return NULL;
+}
 
 /*
   SYNOPSIS
@@ -4709,6 +4741,7 @@ char check_if_ignore_table(const char *t
 {
   char result= IGNORE_NONE;
   char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
+  const char *number_of_rows= NULL;
   MYSQL_RES *res= NULL;
   MYSQL_ROW row;
   DBUG_ENTER("check_if_ignore_table");
@@ -4734,6 +4767,13 @@ char check_if_ignore_table(const char *t
     mysql_free_result(res);
     DBUG_RETURN(result);                         /* assume table is ok */
   }
+  else
+  {
+    if ((number_of_rows= fetch_named_row(res, row, "Rows")) != NULL)
+    {
+      total_rows= strtoul(number_of_rows, NULL, 10);
+    }
+  }
   if (!(row[1]))
     strmake(table_type, "VIEW", NAME_LEN-1);
   else

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2010-02-20 10:07:32 +0000
+++ b/mysql-test/r/mysqldump.result	2010-03-27 01:18:11 +0000
@@ -4560,6 +4560,26 @@ a	b	c
 2	NULL	NULL
 SET NAMES default;
 DROP TABLE t1, t2;
+# test --show-progress-size
+create table t2 (id int not null);
+load data infile '../../std_data/bug30435_10k_items.txt' into table t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+-- Connecting to localhost...
+-- Retrieving table structure for table t2...
+-- Sending SELECT query...
+-- Retrieving rows...
+-- 10000 of ~640000 rows dumped for table `t2`
-- 20000 of ~640000 rows dumped for table `t2`
-- 30000 of ~640000 rows dumped for table `t2`
-- 40000 of ~640000 rows dumped for table `t2`
-- 50000 of ~640000 rows dumped for table `t2`
-- 60000 of ~640000 rows dumped for table `t2`
-- 70000 of ~640000 rows dumped for table `t2`
-- 80000 of ~640000 rows dumped for table `t2`
-- 90000 of ~640000 rows dumped for table `t2`
-- 100000 of ~640000 rows dumped for table `t2`
-- 110000 of ~640000 rows dumped for table `t2`
-- 120000 of ~640000 rows dumped for table `t2`
-- 130000 of ~640000 rows dumped for table `t2`
-- 140000 of ~640000 rows dumped for table `t2`
-- 150000 of ~640000 rows dumped for table `t2`
-- 160000 of ~640000 rows dumped for table `t2`
-- 170000 of ~640000 rows dumped for table `t2`
-- 180000 of ~640000 rows dumped for table `t2`
-- 190000 of ~640000 rows dumped for table `t2`
-- 200000 of ~640000 rows dumped for table `t2`
-- 210000 of ~640000 rows dumped for t
 able `t2`
-- 220000 of ~640000 rows dumped for table `t2`
-- 230000 of ~640000 rows dumped for table `t2`
-- 240000 of ~640000 rows dumped for table `t2`
-- 250000 of ~640000 rows dumped for table `t2`
-- 260000 of ~640000 rows dumped for table `t2`
-- 270000 of ~640000 rows dumped for table `t2`
-- 280000 of ~640000 rows dumped for table `t2`
-- 290000 of ~640000 rows dumped for table `t2`
-- 300000 of ~640000 rows dumped for table `t2`
-- 310000 of ~640000 rows dumped for table `t2`
-- 320000 of ~640000 rows dumped for table `t2`
-- 330000 of ~640000 rows dumped for table `t2`
-- 340000 of ~640000 rows dumped for table `t2`
-- 350000 of ~640000 rows dumped for table `t2`
-- 360000 of ~640000 rows dumped for table `t2`
-- 370000 of ~640000 rows dumped for table `t2`
-- 380000 of ~640000 rows dumped for table `t2`
-- 390000 of ~640000 rows dumped for table `t2`
-- 400000 of ~640000 rows dumped for table `t2`
-- 410000 of ~640000 rows dumped for table `t2`
-- 420000 of ~64000
 0 rows dumped for table `t2`
-- 430000 of ~640000 rows dumped for table `t2`
-- 440000 of ~640000 rows dumped for table `t2`
-- 450000 of ~640000 rows dumped for table `t2`
-- 460000 of ~640000 rows dumped for table `t2`
-- 470000 of ~640000 rows dumped for table `t2`
-- 480000 of ~640000 rows dumped for table `t2`
-- 490000 of ~640000 rows dumped for table `t2`
-- 500000 of ~640000 rows dumped for table `t2`
-- 510000 of ~640000 rows dumped for table `t2`
-- 520000 of ~640000 rows dumped for table `t2`
-- 530000 of ~640000 rows dumped for table `t2`
-- 540000 of ~640000 rows dumped for table `t2`
-- 550000 of ~640000 rows dumped for table `t2`
-- 560000 of ~640000 rows dumped for table `t2`
-- 570000 of ~640000 rows dumped for table `t2`
-- 580000 of ~640000 rows dumped for table `t2`
-- 590000 of ~640000 rows dumped for table `t2`
-- 600000 of ~640000 rows dumped for table `t2`
-- 610000 of ~640000 rows dumped for table `t2`
-- 620000 of ~640000 rows dumped for table `t2`
 -- 630000 of ~640000 rows dumped for table `t2`
-- 640000 of ~640000 rows dumped for table `t2`
-- Disconnecting from localhost...
+-- Connecting to localhost...
+-- Retrieving table structure for table t2...
+-- Sending SELECT query...
+-- Retrieving rows...
+-- 5000 of ~640000 rows dumped for table `t2`
-- 10000 of ~640000 rows dumped for table `t2`
-- 15000 of ~640000 rows dumped for table `t2`
-- 20000 of ~640000 rows dumped for table `t2`
-- 25000 of ~640000 rows dumped for table `t2`
-- 30000 of ~640000 rows dumped for table `t2`
-- 35000 of ~640000 rows dumped for table `t2`
-- 40000 of ~640000 rows dumped for table `t2`
-- 45000 of ~640000 rows dumped for table `t2`
-- 50000 of ~640000 rows dumped for table `t2`
-- 55000 of ~640000 rows dumped for table `t2`
-- 60000 of ~640000 rows dumped for table `t2`
-- 65000 of ~640000 rows dumped for table `t2`
-- 70000 of ~640000 rows dumped for table `t2`
-- 75000 of ~640000 rows dumped for table `t2`
-- 80000 of ~640000 rows dumped for table `t2`
-- 85000 of ~640000 rows dumped for table `t2`
-- 90000 of ~640000 rows dumped for table `t2`
-- 95000 of ~640000 rows dumped for table `t2`
-- 100000 of ~640000 rows dumped for table `t2`
-- 105000 of ~640000 rows dumped for table `t2`
-
 - 110000 of ~640000 rows dumped for table `t2`
-- 115000 of ~640000 rows dumped for table `t2`
-- 120000 of ~640000 rows dumped for table `t2`
-- 125000 of ~640000 rows dumped for table `t2`
-- 130000 of ~640000 rows dumped for table `t2`
-- 135000 of ~640000 rows dumped for table `t2`
-- 140000 of ~640000 rows dumped for table `t2`
-- 145000 of ~640000 rows dumped for table `t2`
-- 150000 of ~640000 rows dumped for table `t2`
-- 155000 of ~640000 rows dumped for table `t2`
-- 160000 of ~640000 rows dumped for table `t2`
-- 165000 of ~640000 rows dumped for table `t2`
-- 170000 of ~640000 rows dumped for table `t2`
-- 175000 of ~640000 rows dumped for table `t2`
-- 180000 of ~640000 rows dumped for table `t2`
-- 185000 of ~640000 rows dumped for table `t2`
-- 190000 of ~640000 rows dumped for table `t2`
-- 195000 of ~640000 rows dumped for table `t2`
-- 200000 of ~640000 rows dumped for table `t2`
-- 205000 of ~640000 rows dumped for table `t2`
-- 210000 of ~640000 rows dump
 ed for table `t2`
-- 215000 of ~640000 rows dumped for table `t2`
-- 220000 of ~640000 rows dumped for table `t2`
-- 225000 of ~640000 rows dumped for table `t2`
-- 230000 of ~640000 rows dumped for table `t2`
-- 235000 of ~640000 rows dumped for table `t2`
-- 240000 of ~640000 rows dumped for table `t2`
-- 245000 of ~640000 rows dumped for table `t2`
-- 250000 of ~640000 rows dumped for table `t2`
-- 255000 of ~640000 rows dumped for table `t2`
-- 260000 of ~640000 rows dumped for table `t2`
-- 265000 of ~640000 rows dumped for table `t2`
-- 270000 of ~640000 rows dumped for table `t2`
-- 275000 of ~640000 rows dumped for table `t2`
-- 280000 of ~640000 rows dumped for table `t2`
-- 285000 of ~640000 rows dumped for table `t2`
-- 290000 of ~640000 rows dumped for table `t2`
-- 295000 of ~640000 rows dumped for table `t2`
-- 300000 of ~640000 rows dumped for table `t2`
-- 305000 of ~640000 rows dumped for table `t2`
-- 310000 of ~640000 rows dumped for table `t2`
-- 315000 o
 f ~640000 rows dumped for table `t2`
-- 320000 of ~640000 rows dumped for table `t2`
-- 325000 of ~640000 rows dumped for table `t2`
-- 330000 of ~640000 rows dumped for table `t2`
-- 335000 of ~640000 rows dumped for table `t2`
-- 340000 of ~640000 rows dumped for table `t2`
-- 345000 of ~640000 rows dumped for table `t2`
-- 350000 of ~640000 rows dumped for table `t2`
-- 355000 of ~640000 rows dumped for table `t2`
-- 360000 of ~640000 rows dumped for table `t2`
-- 365000 of ~640000 rows dumped for table `t2`
-- 370000 of ~640000 rows dumped for table `t2`
-- 375000 of ~640000 rows dumped for table `t2`
-- 380000 of ~640000 rows dumped for table `t2`
-- 385000 of ~640000 rows dumped for table `t2`
-- 390000 of ~640000 rows dumped for table `t2`
-- 395000 of ~640000 rows dumped for table `t2`
-- 400000 of ~640000 rows dumped for table `t2`
-- 405000 of ~640000 rows dumped for table `t2`
-- 410000 of ~640000 rows dumped for table `t2`
-- 415000 of ~640000 rows dumped for tab
 le `t2`
-- 420000 of ~640000 rows dumped for table `t2`
-- 425000 of ~640000 rows dumped for table `t2`
-- 430000 of ~640000 rows dumped for table `t2`
-- 435000 of ~640000 rows dumped for table `t2`
-- 440000 of ~640000 rows dumped for table `t2`
-- 445000 of ~640000 rows dumped for table `t2`
-- 450000 of ~640000 rows dumped for table `t2`
-- 455000 of ~640000 rows dumped for table `t2`
-- 460000 of ~640000 rows dumped for table `t2`
-- 465000 of ~640000 rows dumped for table `t2`
-- 470000 of ~640000 rows dumped for table `t2`
-- 475000 of ~640000 rows dumped for table `t2`
-- 480000 of ~640000 rows dumped for table `t2`
-- 485000 of ~640000 rows dumped for table `t2`
-- 490000 of ~640000 rows dumped for table `t2`
-- 495000 of ~640000 rows dumped for table `t2`
-- 500000 of ~640000 rows dumped for table `t2`
-- 505000 of ~640000 rows dumped for table `t2`
-- 510000 of ~640000 rows dumped for table `t2`
-- 515000 of ~640000 rows dumped for table `t2`
-- 520000 of ~640000 
 rows dumped for table `t2`
-- 525000 of ~640000 rows dumped for table `t2`
-- 530000 of ~640000 rows dumped for table `t2`
-- 535000 of ~640000 rows dumped for table `t2`
-- 540000 of ~640000 rows dumped for table `t2`
-- 545000 of ~640000 rows dumped for table `t2`
-- 550000 of ~640000 rows dumped for table `t2`
-- 555000 of ~640000 rows dumped for table `t2`
-- 560000 of ~640000 rows dumped for table `t2`
-- 565000 of ~640000 rows dumped for table `t2`
-- 570000 of ~640000 rows dumped for table `t2`
-- 575000 of ~640000 rows dumped for table `t2`
-- 580000 of ~640000 rows dumped for table `t2`
-- 585000 of ~640000 rows dumped for table `t2`
-- 590000 of ~640000 rows dumped for table `t2`
-- 595000 of ~640000 rows dumped for table `t2`
-- 600000 of ~640000 rows dumped for table `t2`
-- 605000 of ~640000 rows dumped for table `t2`
-- 610000 of ~640000 rows dumped for table `t2`
-- 615000 of ~640000 rows dumped for table `t2`
-- 620000 of ~640000 rows dumped for table `t2`
--
  625000 of ~640000 rows dumped for table `t2`
-- 630000 of ~640000 rows dumped for table `t2`
-- 635000 of ~640000 rows dumped for table `t2`
-- 640000 of ~640000 rows dumped for table `t2`
-- Disconnecting from localhost...
+DROP TABLE t2;
 #
 # End of 5.1 tests
 #

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2010-01-12 12:07:09 +0000
+++ b/mysql-test/t/mysqldump.test	2010-03-27 01:18:11 +0000
@@ -2138,6 +2138,25 @@ SET NAMES default;
 
 DROP TABLE t1, t2;
 
+--echo # test --show-progress-size
+
+create table t2 (id int not null);
+
+load data infile '../../std_data/bug30435_10k_items.txt' into table t2;
+
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t2;
+
+--exec $MYSQL_DUMP --verbose test t2 2>&1 > /dev/null
+
+--exec $MYSQL_DUMP --show-progress-size=5000 --verbose test t2 2>&1 > /dev/null
+
+DROP TABLE t2;
+
 ###########################################################################
 --echo #
 --echo # End of 5.1 tests


Attachment: [text/bzr-bundle] bzr/andrew.hutchings@sun.com-20100327011811-jj3di3spz2kyy2bf.bundle
Thread
bzr commit into mysql-next-mr branch (Andrew.Hutchings:3128) Bug#44071Andrew Hutchings27 Mar