Commit 02f2ea3e authored by unknown's avatar unknown

Merge mysqldev@production.mysql.com:my/mysql-5.0-release

into  mysql.com:/home/cps/mysql/trees/mysql-5.0

parents 98f8091d a38f5cd5
......@@ -34,6 +34,7 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \
-DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
-DDEFAULT_MONITORING_INTERVAL="20" \
-DDEFAULT_PORT="2273" \
-DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
-DPROTOCOL_VERSION=@PROTOCOL_VERSION@
liboptions_a_SOURCES= options.h options.cc priv.h priv.cc
......
......@@ -22,6 +22,7 @@
#include "mysql_manager_error.h"
#include "protocol.h"
#include "buffer.h"
#include "options.h"
#include <m_string.h>
#include <mysql.h>
......@@ -643,6 +644,7 @@ Set_option::Set_option(Instance_map *instance_map_arg,
if ((instance= instance_map->find(name, len)))
{
instance_name= instance->options.instance_name;
/* add prefix for add_option */
if ((option_len_arg < MAX_OPTION_LEN - 1) ||
(option_value_len_arg < MAX_OPTION_LEN - 1))
......@@ -689,15 +691,22 @@ int Set_option::correct_file(int skip)
{
int error;
error= modify_defaults_file("/etc/my.cnf", option,
error= modify_defaults_file(Options::config_file, option,
option_value, instance_name, skip);
if (error > 0)
switch (error)
{
case 0:
return 0; /* everything was fine */
case 1:
return ER_OUT_OF_RESOURCES;
else if (error < 0)
case 2:
return ER_ACCESS_OPTION_FILE;
default:
DBUG_ASSERT(0); /* should never get here */
}
/* everything was fine */
return 0;
return 0; /* keep compiler happy */
}
......
......@@ -22,6 +22,8 @@
#include "buffer.h"
#include "instance.h"
#include "log.h"
#include "options.h"
#include <m_ctype.h>
#include <mysql_com.h>
......@@ -111,9 +113,8 @@ err_new_instance:
C_MODE_END
Instance_map::Instance_map(const char *default_mysqld_path_arg,
const char *first_option_arg):
mysqld_path(default_mysqld_path_arg), first_option(first_option_arg)
Instance_map::Instance_map(const char *default_mysqld_path_arg):
mysqld_path(default_mysqld_path_arg)
{
pthread_mutex_init(&LOCK_instance_map, 0);
}
......@@ -202,7 +203,8 @@ int Instance_map::complete_initialization()
hash_free should handle it's deletion => goto err, not
err_instance.
*/
if (instance->complete_initialization(this, mysqld_path, DEFAULT_SINGLE_INSTANCE))
if (instance->complete_initialization(this, mysqld_path,
DEFAULT_SINGLE_INSTANCE))
goto err;
}
else
......@@ -236,18 +238,18 @@ int Instance_map::load()
/* the name of the program may be orbitrary here in fact */
argv_options[0]= "mysqlmanager";
if (first_option != NULL)
{
argc= 2;
argv_options[1]= first_option;
argv_options[2]= '\0';
}
else
argv_options[1]= '\0';
if (my_search_option_files("my", &argc, (char ***) &argv, &args_used,
process_option, (void*) this) ||
complete_initialization())
/*
If the routine failed, we'll simply fallback to defaults in
complete_initialization().
*/
if (my_search_option_files(Options::config_file, &argc,
(char ***) &argv, &args_used,
process_option, (void*) this))
log_info("Falling back to compiled-in defaults");
if (complete_initialization())
return 1;
return 0;
......
......@@ -64,8 +64,7 @@ public:
int unlock();
int init();
Instance_map(const char *default_mysqld_path_arg,
const char *first_option_arg);
Instance_map(const char *default_mysqld_path_arg);
~Instance_map();
/* loads options from config files */
......@@ -80,7 +79,6 @@ public:
Guardian_thread *guardian;
private:
const char *first_option;
enum { START_HASH_SIZE = 16 };
pthread_mutex_t LOCK_instance_map;
HASH hash;
......
......@@ -68,7 +68,7 @@ void manager(const Options &options)
*/
User_map user_map;
Instance_map instance_map(options.default_mysqld_path, options.first_option);
Instance_map instance_map(options.default_mysqld_path);
Guardian_thread guardian_thread(thread_registry,
&instance_map,
options.monitoring_interval);
......
......@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
if (set_user(options.user, user_info))
{
options.cleanup();
return 1;
goto err;
}
}
......
......@@ -36,7 +36,7 @@ const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
const char *Options::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
const char *Options::password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME);
const char *Options::default_mysqld_path= QUOTE(DEFAULT_MYSQLD_PATH);
const char *Options::first_option= 0; /* No default value */
const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
const char *Options::bind_address= 0; /* No default value */
const char *Options::user= 0; /* No default value */
uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
......@@ -143,7 +143,12 @@ static void usage()
printf("Usage: %s [OPTIONS] \n", my_progname);
my_print_help(my_long_options);
print_defaults("my", default_groups);
printf("\nThe following options may be given as the first argument:\n"
"--print-defaults Print the program argument list and exit\n"
"--defaults-file=# Only read manager configuration and instance\n"
" setings from the given file #. The same file\n"
" will be used to modify configuration of instances\n"
" with SET commands.\n");
my_print_variables(my_long_options);
}
......@@ -204,31 +209,48 @@ C_MODE_END
/*
- call load_defaults to load configuration file section
- Process argv of original program: get tid of --defaults-extra-file
and print a message if met there.
- call load_defaults to load configuration file section and save the pointer
for free_defaults.
- call handle_options to assign defaults and command-line arguments
to the class members
if either of these function fail, exit the program
May not return.
to the class members.
if either of these function fail, return the error code.
*/
int Options::load(int argc, char **argv)
{
int rc;
saved_argv= argv;
if (argc >= 2)
{
if (is_prefix(argv[1],"--defaults-file=") ||
is_prefix(argv[1],"--defaults-extra-file="))
Options::first_option= argv[1];
if (is_prefix(argv[1], "--defaults-file="))
{
Options::config_file= strchr(argv[1], '=') + 1;
}
if (is_prefix(argv[1], "--defaults-extra-file=") ||
is_prefix(argv[1], "--no-defaults"))
{
/* the log is not enabled yet */
fprintf(stderr, "The --defaults-extra-file and --no-defaults options"
" are not supported by\n"
"Instance Manager. Program aborted.\n");
goto err;
}
}
/* config-file options are prepended to command-line ones */
load_defaults("my", default_groups, &argc, &argv);
Options::saved_argv= argv;
load_defaults(config_file, default_groups, &argc,
&saved_argv);
if ((handle_options(&argc, &saved_argv, my_long_options,
get_one_option)) != 0)
goto err;
if ((rc= handle_options(&argc, &argv, my_long_options, get_one_option)) != 0)
return rc;
return 0;
err:
return 1;
}
void Options::cleanup()
......
......@@ -36,11 +36,12 @@ struct Options
static const char *default_mysqld_path;
static const char *user;
/* the option which should be passed to process_default_option_files */
static const char *first_option;
static uint monitoring_interval;
static uint port_number;
static const char *bind_address;
static const char *config_file;
/* argv pointer returned by load_defaults() to be used by free_defaults() */
static char **saved_argv;
static int load(int argc, char **argv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment