diff options
author | unknown <hf@deer.(none)> | 2005-01-03 19:21:54 +0400 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2005-01-03 19:21:54 +0400 |
commit | d3be3cbcfdf74f4131e16b201c7eb5dfde0a8257 (patch) | |
tree | 96a377282ba249c3076ed502ea0325733639fff9 | |
parent | a77d4ce2725a0d8e2310b3d7e1c3aed7908ea143 (diff) | |
download | mariadb-git-d3be3cbcfdf74f4131e16b201c7eb5dfde0a8257.tar.gz |
fix for bug #5920 (embedded-server mysql doesn't handle --defaults-file)
client/mysql.cc:
bug #5920 (embedded-server mysql doesn't handle --defaults-file)
defaults files handled
include/my_sys.h:
bug #5920 (embedded-server mysql doesn't handle --defaults-file)
get_defaults_file interface added
libmysqld/libmysqld.c:
just small fix, not related to the bug.
mysys/default.c:
bug #5920 (embedded-server mysql doesn't handle --defaults-file)
get_defaults_files implementation
-rw-r--r-- | client/mysql.cc | 12 | ||||
-rw-r--r-- | include/my_sys.h | 2 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 3 | ||||
-rw-r--r-- | mysys/default.c | 55 |
4 files changed, 55 insertions, 17 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 0ea0f10f5d7..5739d3203e7 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -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); diff --git a/include/my_sys.h b/include/my_sys.h index a8e21ea2f98..5e56f0bdc2c 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -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); diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index a2c4be1a078..6fa41fb3fd0 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -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))) diff --git a/mysys/default.c b/mysys/default.c index ea23bbb6693..5f554ac36f6 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -79,6 +79,36 @@ 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 SYNOPSIS @@ -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"; |