From e3d0c1a7f1dffc515d018490b61383a2ae46dd7c Mon Sep 17 00:00:00 2001
From: "anozdrin@mysql.com" <>
Date: Mon, 22 May 2006 15:20:40 +0400
Subject: [PATCH] Merged.

---
 mysql-test/r/im_instance_conf.result              |  8 ++++----
 mysql-test/r/im_options.result                    | 14 +++++++-------
 server-tools/instance-manager/CMakeLists.txt      |  1 +
 server-tools/instance-manager/instance_options.cc | 14 +++++++++-----
 server-tools/instance-manager/mysqlmanager.cc     |  4 ++--
 server-tools/instance-manager/options.cc          | 10 +++++-----
 6 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/mysql-test/r/im_instance_conf.result b/mysql-test/r/im_instance_conf.result
index 3ea1e2bd824..efda9439f38 100644
--- a/mysql-test/r/im_instance_conf.result
+++ b/mysql-test/r/im_instance_conf.result
@@ -1,6 +1,6 @@
 --------------------------------------------------------------------
-server_id           =1
-server_id           =2
+server_id           = 1
+server_id           = 2
 --------------------------------------------------------------------
 SHOW INSTANCES;
 instance_name	state
@@ -20,8 +20,8 @@ mysqld3	offline
 mysqld2	offline
 mysqld1	online
 --------------------------------------------------------------------
-server_id           =1
-server_id           =2
+server_id           = 1
+server_id           = 2
 --------------------------------------------------------------------
 CREATE INSTANCE mysqld1;
 ERROR HY000: Instance already exists
diff --git a/mysql-test/r/im_options.result b/mysql-test/r/im_options.result
index ed5b2ee5091..8039333b7d9 100644
--- a/mysql-test/r/im_options.result
+++ b/mysql-test/r/im_options.result
@@ -1,6 +1,6 @@
 --------------------------------------------------------------------
-server_id           =1
-server_id           =2
+server_id           = 1
+server_id           = 2
 --------------------------------------------------------------------
 SHOW VARIABLES LIKE 'server_id';
 Variable_name	Value
@@ -99,13 +99,13 @@ ERROR HY000: The instance is active. Stop the instance first
 UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
 ERROR HY000: Bad instance name. Check that the instance with such a name exists
 --------------------------------------------------------------------
-server_id           =1
+server_id           = 1
 server_id=2
 --------------------------------------------------------------------
 UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc;
 ERROR HY000: The instance is active. Stop the instance first
 --------------------------------------------------------------------
-server_id           =1
+server_id           = 1
 server_id=2
 --------------------------------------------------------------------
 DROP INSTANCE mysqld3;
@@ -115,7 +115,7 @@ SET   mysqld2.server_id   =  222  ;
 SET   mysqld2  .  server_id  =  222  ;
 SET   mysqld2  .  server_id  =  222  , mysqld2  .  aaa  , mysqld2  .  bbb  ;
 --------------------------------------------------------------------
-server_id           =1
+server_id           = 1
 server_id=222
 --------------------------------------------------------------------
 aaa
@@ -124,13 +124,13 @@ bbb
 --------------------------------------------------------------------
 UNSET mysqld2  . aaa  ,  mysqld2  .  bbb ;
 --------------------------------------------------------------------
-server_id           =1
+server_id           = 1
 server_id=222
 --------------------------------------------------------------------
 --------------------------------------------------------------------
 --------------------------------------------------------------------
 --------------------------------------------------------------------
-server_id           =1
+server_id           = 1
 server_id=222
 --------------------------------------------------------------------
 SHOW VARIABLES LIKE 'server_id';
diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt
index c20b9c7f9df..1983d459ce2 100644
--- a/server-tools/instance-manager/CMakeLists.txt
+++ b/server-tools/instance-manager/CMakeLists.txt
@@ -9,6 +9,7 @@ ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instanc
                             instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc
                             mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc
                             thread_registry.cc user_map.cc imservice.cpp windowsservice.cpp
+                            user_management_commands.cc
                             ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c
                             ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c
                             ../../libmysql/errmsg.c)
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index 290741359c4..b05e40734b7 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -89,6 +89,9 @@ Instance_options::Instance_options()
   mysqld_path.str= NULL;
   mysqld_path.length= 0;
 
+  mysqld_real_path.str= NULL;
+  mysqld_real_path.length= 0;
+
   memset(logs, 0, sizeof(logs));
 }
 
@@ -206,12 +209,12 @@ int Instance_options::fill_instance_version()
 int Instance_options::fill_mysqld_real_path()
 {
   char result[FN_REFLEN];
-  char help_option[]= " --no-defaults --help";
+  LEX_STRING help_option=
+    { C_STRING_WITH_SIZE(" --no-defaults --help") };
   int rc= 1;
-  Buffer cmd(mysqld_path_len + sizeof(help_option));
+  Buffer cmd(mysqld_path.length + help_option.length);
 
-  if (create_mysqld_command(&cmd, mysqld_path, mysqld_path_len,
-                            help_option, sizeof(help_option)))
+  if (create_mysqld_command(&cmd, &mysqld_path, &help_option))
     goto err;
 
   bzero(result, FN_REFLEN);
@@ -226,7 +229,8 @@ int Instance_options::fill_mysqld_real_path()
     /* chop the path of at [OPTIONS] */
     if ((options_str= strstr(result, "[OPTIONS]")))
       *options_str= '\0';
-    mysqld_real_path= strdup_root(&alloc, result);
+    mysqld_real_path.str= strdup_root(&alloc, result);
+    mysqld_real_path.length= strlen(mysqld_real_path.str);
   }
 err:
   if (rc)
diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc
index 7dac7bcc994..177b761b419 100644
--- a/server-tools/instance-manager/mysqlmanager.cc
+++ b/server-tools/instance-manager/mysqlmanager.cc
@@ -365,10 +365,10 @@ static void angel()
     pid= getpid(); /* Get our pid. */
 
     log_info("Angel pid file: '%s'; PID: %d.",
-             (const char *) options.angel_pid_file_name,
+             (const char *) Options::Daemon::angel_pid_file_name,
              (int) pid);
 
-    create_pid_file(Options::angel_pid_file_name, pid);
+    create_pid_file(Options::Daemon::angel_pid_file_name, pid);
 
     while (child_status == CHILD_OK && is_terminated == 0)
       sigsuspend(&zeromask);
diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc
index c8870a1ac39..31ce5b00190 100644
--- a/server-tools/instance-manager/options.cc
+++ b/server-tools/instance-manager/options.cc
@@ -67,7 +67,7 @@ static int setup_windows_defaults();
 my_bool Options::Daemon::run_as_service= FALSE;
 const char *Options::Daemon::log_file_name= QUOTE(DEFAULT_LOG_FILE_NAME);
 const char *Options::Daemon::user= NULL; /* No default value */
-const char *Options::angel_pid_file_name= NULL;
+const char *Options::Daemon::angel_pid_file_name= NULL;
 
 const char *Options::Main::config_file= QUOTE(DEFAULT_CONFIG_FILE);
 const char *
@@ -155,8 +155,8 @@ static struct my_option my_long_options[] =
 
 #ifndef __WIN__
   { "angel-pid-file", OPT_ANGEL_PID_FILE, "Pid file for angel process.",
-    (gptr *) &Options::angel_pid_file_name,
-    (gptr *) &Options::angel_pid_file_name,
+    (gptr *) &Options::Daemon::angel_pid_file_name,
+    (gptr *) &Options::Daemon::angel_pid_file_name,
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
 #endif
 
@@ -507,8 +507,8 @@ void Options::cleanup()
   delete User_management::cmd;
 
 #ifndef __WIN__
-  if (Options::run_as_service)
-    free((void *) Options::angel_pid_file_name);
+  if (Options::Daemon::run_as_service)
+    free((void *) Options::Daemon::angel_pid_file_name);
 #endif
 }
 
-- 
2.30.9