[MDEV-6056] [PATCH] mysqldump writes usage to stdout even when not explicitly requested Created: 2014-04-09  Updated: 2014-05-11  Resolved: 2014-05-11

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.10
Fix Version/s: 10.0.11

Type: Bug Priority: Minor
Reporter: MG Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: upstream

Attachments: Text File mdev6056.txt    

 Description   

Upstream bug http://bugs.mysql.com/bug.php?id=51975 was errantly classified as a duplicate of non-bug http://bugs.mysql.com/bug.php?id=44848

mysqldump should never write usage to stdout unless --help was passed as an argument.

This change seems to correct the behavior:

 
--- mysql-5.6.16/client/mysqldump.c	2014-01-14 15:38:00.000000000 +0000
+++ mysql-5.6.16_modified/client/mysqldump.c	2014-02-14 02:56:28.000000000 +0000
@@ -621,31 +621,31 @@
 } /* print_version */
 
 
-static void short_usage_sub(void)
+static void short_usage_sub(FILE *stream)
 {
-  printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
-  printf("OR     %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
+  fprintf(stream, "Usage: %s [OPTIONS] database [tables]\n", my_progname);
+  fprintf(stream, "OR     %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
          my_progname);
-  printf("OR     %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname);
+  fprintf(stream, "OR     %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname);
 }
 
 
-static void usage(void)
+static void usage(FILE *stream)
 {
   print_version();
   puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   puts("Dumping structure and contents of MySQL databases and tables.");
-  short_usage_sub();
+  short_usage_sub(stream);
   print_defaults("my",load_default_groups);
   my_print_help(my_long_options);
   my_print_variables(my_long_options);
 } /* usage */
 
 
-static void short_usage(void)
+static void short_usage(FILE *stream)
 {
-  short_usage_sub();
-  printf("For more options, use %s --help\n", my_progname);
+  short_usage_sub(stream);
+  fprintf(stream, "For more options, use %s --help\n", my_progname);
 }
 
 
@@ -824,7 +824,7 @@
     break;
   case 'I':
   case '?':
-    usage();
+    usage(stdout);
     exit(0);
   case (int) OPT_MASTER_DATA:
     if (!argument) /* work like in old versions */
@@ -1020,7 +1020,7 @@
     exit(1);
   if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
   {
-    short_usage();
+    short_usage(stderr);
     return EX_USAGE;
   }
   if (tty_password)


Generated at Thu Feb 08 07:09:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.