diff options
author | unknown <tim@black.box> | 2001-08-10 12:37:36 -0400 |
---|---|---|
committer | unknown <tim@black.box> | 2001-08-10 12:37:36 -0400 |
commit | b538ff90dad25d5975b68182bd064bc7a95ebfc2 (patch) | |
tree | 0b1bf2d0aed5c3d69b112448bb146dcc526f9890 /libmysqld/lib_sql.cc | |
parent | 4bb40187438bdfb8b1d8b091399bd01e0e3425c1 (diff) | |
download | mariadb-git-b538ff90dad25d5975b68182bd064bc7a95ebfc2.tar.gz |
Embedded mysql fixes.
There is now a mysql_server_init() function which needs to be
called at the beginning of the program (and _end() for the end
of the program). This routine handles argument parsing for the
embedded server.
Use the embedded version of mysql_load_file() (ignore the LOCAL
argument, since the client and server are the same program).
There are now mysql_thread_init/end() functions for the client
to use in a multi-threaded app. They are just wrappers for
my_thread_init/end().
BitKeeper/deleted/.del-README~434e9cae5fa9a4c4:
Delete: libmysqld/README
libmysqld/lib_load.cc:
minor cleanup
include/mysql.h:
add mysql_server/thread_init/end()
libmysql/libmysql.c:
add mysql_server/thread_init/end()
libmysqld/lib_sql.cc:
add mysql_server/thread_init/end()
libmysqld/libmysqld.c:
add mysql_server/thread_init/end()
sql/mysqld.cc:
allow get_options() to be called more than once
libmysqld/Makefile.am:
use lib_load.cc instead of sql_load.cc
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'libmysqld/lib_sql.cc')
-rw-r--r-- | libmysqld/lib_sql.cc | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index a633d6f583b..e924c1da4c1 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -29,6 +29,7 @@ extern "C" { #include "mysql_com.h" +#include "lib_vio.c" } @@ -50,7 +51,6 @@ void free_defaults_internal(char ** argv){if (argv) free_defaults(argv);} char mysql_data_home[FN_REFLEN]; char * get_mysql_data_home(){return mysql_data_home;}; #define mysql_data_home mysql_data_home_internal -#include "lib_vio.c" #include "../sql/mysqld.cc" #define SCRAMBLE_LENGTH 8 @@ -317,16 +317,30 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, extern "C"{ -void start_embedded_connection(NET * net) -{ - start_embedded_conn1(net); -} -//==================================================================== -void embedded_srv_init(void) +void mysql_server_init(int argc, char **argv, const char **groups) { - DEBUGGER_OFF; char hostname[FN_REFLEN]; + /* This mess is to allow people to call the init function without + * having to mess with a fake argv */ + int *argcp; + char ***argvp; + int fake_argc = 1; + char *fake_argv[] = { (char *)"", 0 }; + const char *fake_groups[] = { "server", 0 }; + if (argc) + { + argcp = &argc; + argvp = &argv; + } + else + { + argcp = &fake_argc; + argvp = (char ***)&fake_argv; + } + if (!groups) + groups = fake_groups; + my_umask=0660; // Default umask for new files my_umask_dir=0700; // Default umask for new directories MY_INIT((char *)"mysqld"); // init my_sys library & pthreads @@ -370,8 +384,8 @@ void embedded_srv_init(void) exit( 1 ); } #endif - // load_defaults("my",load_default_groups,&d_argc, (char***)&d_argv); - defaults_argv=0; + load_defaults("my", groups, argcp, argvp); + defaults_argv=*argvp; mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */ #ifdef __WIN__ if (!mysql_tmpdir) @@ -382,7 +396,7 @@ void embedded_srv_init(void) if (!mysql_tmpdir || !mysql_tmpdir[0]) mysql_tmpdir=strdup((char*) P_tmpdir); set_options(); - fix_paths(); + get_options(*argcp, *argvp); if (opt_log || opt_update_log || opt_slow_log || opt_bin_log) strcat(server_version,"-log"); @@ -607,14 +621,10 @@ void embedded_srv_init(void) //printf(ER(ER_READY),my_progname,server_version,""); //printf("%s initialized.\n", server_version); fflush(stdout); - - } - -void embedded_srv_deinit() +void mysql_server_end() { - /* (void) pthread_attr_destroy(&connection_attrib); */ DBUG_PRINT("quit",("Exiting main thread")); @@ -638,8 +648,29 @@ void embedded_srv_deinit() } (void) pthread_mutex_unlock(&LOCK_thread_count); my_thread_end(); +} + +my_bool mysql_thread_init() +{ +#ifdef THREAD + return my_thread_init(); +#else + return 0; +#endif +} +void mysql_thread_end() +{ +#ifdef THREAD + my_thread_end(); +#endif +} + +void start_embedded_connection(NET * net) +{ + start_embedded_conn1(net); } +//==================================================================== } int embedded_do_command(NET * net) { |