Commit 8b3b3648 authored by hf@deer.(none)'s avatar hf@deer.(none)

Merge bk@192.168.21.1:/usr/home/bk/mysql-4.1

into deer.(none):/home/hf/work/mysql-4.1.5920
parents 33795908 5eb5fd12
......@@ -330,6 +330,16 @@ static sig_handler mysql_end(int sig);
int main(int argc,char *argv[])
{
char buff[80];
char *defaults, *extra_defaults;
char *emb_argv[3];
int emb_argc= 1;
emb_argv[0]= argv[0];
get_defaults_files(argc, argv, &defaults, &extra_defaults);
if (defaults)
emb_argv[emb_argc++]= defaults;
if (extra_defaults)
emb_argv[emb_argc++]= extra_defaults;
MY_INIT(argv[0]);
DBUG_ENTER("main");
......@@ -375,7 +385,7 @@ int main(int argc,char *argv[])
my_end(0);
exit(1);
}
if (mysql_server_init(0, NULL, (char**) server_default_groups))
if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups))
{
free_defaults(defaults_argv);
my_end(0);
......
......@@ -738,6 +738,8 @@ extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
extern void get_defaults_files(int argc, char **argv,
char **defaults, char **extra_defaults);
extern int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
extern void free_defaults(char **argv);
......
......@@ -143,6 +143,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
db ? db : "(Null)",
user ? user : "(Null)"));
if (!host || !host[0])
host= mysql->options.host;
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION ||
(mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION &&
host && *host && strcmp(host,LOCAL_HOST)))
......
......@@ -78,6 +78,36 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
static char *remove_end_comment(char *ptr);
/*
Gets --defaults-file and --defaults-extra-file options from command line.
SYNOPSIS
get_defaults_files()
argc Pointer to argc of original program
argv Pointer to argv of original program
defaults --defaults-file option
extra_defaults --defaults-extra-file option
RETURN
defaults and extra_defaults will be set to appropriate items
of argv array, or to NULL if there are no such options
*/
void get_defaults_files(int argc, char **argv,
char **defaults, char **extra_defaults)
{
*defaults=0;
*extra_defaults=0;
if (argc >= 2)
{
if (is_prefix(argv[1],"--defaults-file="))
*defaults= argv[1];
else if (is_prefix(argv[1],"--defaults-extra-file="))
*extra_defaults= argv[1];
}
}
/*
Read options from configurations files
......@@ -111,7 +141,7 @@ static char *remove_end_comment(char *ptr);
int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv)
int *argc, char ***argv)
{
DYNAMIC_ARRAY args;
const char **dirs, *forced_default_file;
......@@ -143,21 +173,14 @@ int load_defaults(const char *conf_file, const char **groups,
DBUG_RETURN(0);
}
/* Check if we want to force the use a specific default file */
forced_default_file=0;
if (*argc >= 2)
{
if (is_prefix(argv[0][1],"--defaults-file="))
{
forced_default_file=strchr(argv[0][1],'=')+1;
args_used++;
}
else if (is_prefix(argv[0][1],"--defaults-extra-file="))
{
defaults_extra_file=strchr(argv[0][1],'=')+1;
args_used++;
}
}
get_defaults_files(*argc, *argv,
(char **)&forced_default_file, &defaults_extra_file);
if (forced_default_file)
forced_default_file= strchr(forced_default_file,'=')+1;
if (defaults_extra_file)
defaults_extra_file= strchr(defaults_extra_file,'=')+1;
args_used+= (forced_default_file ? 1 : 0) + (defaults_extra_file ? 1 : 0);
group.count=0;
group.name= "defaults";
......
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