From d99fbf4867db99b79385565f2b8ac9f164462240 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 3 Feb 2011 18:56:30 +0100 Subject: [PATCH] MWL#55 : Add banner text to command line utilities (Philip's review) --- sql/mysql_install_db.cc | 7 +++++++ sql/mysql_upgrade_service.cc | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 3f712b196d4..4541d48dcd1 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -13,6 +13,12 @@ #include #include +#define USAGETEXT \ +"mysql_install_db.exe Ver 1.42 for Windows\n" \ +"This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n" \ +"and you are welcome to modify and redistribute it under the GPL v2 license\n" \ +"Usage: mysql_install_db.exe [OPTIONS]\n" \ +"OPTIONS:" extern "C" const char mysql_bootstrap_sql[]; @@ -69,6 +75,7 @@ get_one_option(int optid, DBUG_ENTER("get_one_option"); switch (optid) { case '?': + printf("%s\n", USAGETEXT); my_print_help(my_long_options); exit(0); break; diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc index 1d1e8ea099d..0a77608f710 100644 --- a/sql/mysql_upgrade_service.cc +++ b/sql/mysql_upgrade_service.cc @@ -35,6 +35,13 @@ /* We're using version APIs */ #pragma comment(lib, "version") +#define USAGETEXT \ +"mysql_upgrade_service.exe Ver 1.42 for Windows\n" \ +"This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n" \ +"and you are welcome to modify and redistribute it under the GPL v2 license\n" \ +"Usage: mysql_upgrade_service.exe [OPTIONS]\n" \ +"OPTIONS:" + static char mysqld_path[MAX_PATH]; static char mysqladmin_path[MAX_PATH]; static char mysqlupgrade_path[MAX_PATH]; @@ -73,6 +80,7 @@ get_one_option(int optid, DBUG_ENTER("get_one_option"); switch (optid) { case '?': + printf("%s\n", USAGETEXT); my_print_help(my_long_options); exit(0); break; @@ -410,7 +418,13 @@ int main(int argc, char **argv) char bindir[FN_REFLEN]; char *p; - /* + /* Parse options */ + if ((error= handle_options(&argc, &argv, my_long_options, get_one_option))) + die(""); + if(!opt_service) + die("service parameter is mandatory"); + + /* Get full path to mysqld, we need it when changing service configuration. Assume installation layout, i.e mysqld.exe, mysqladmin.exe, mysqlupgrade.exe and mysql_upgrade_service.exe are in the same directory. @@ -432,13 +446,6 @@ int main(int argc, char **argv) die("File %s does not exist", paths[i]); } - - /* Parse options */ - if ((error= handle_options(&argc, &argv, my_long_options, get_one_option))) - die(""); - if(!opt_service) - die("service parameter is mandatory"); - /* Messages written on stdout should not be buffered, GUI upgrade program read them from pipe and uses as progress indicator. @@ -451,6 +458,7 @@ int main(int argc, char **argv) log("Phase 2/8: Stopping service"); stop_mysqld_service(); + /* Start mysqld.exe as non-service skipping privileges (so we do not care about the password). But disable networking and enable pipe