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 | |
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')
-rw-r--r-- | libmysqld/Makefile.am | 6 | ||||
-rw-r--r-- | libmysqld/README | 26 | ||||
-rw-r--r-- | libmysqld/lib_load.cc | 14 | ||||
-rw-r--r-- | libmysqld/lib_sql.cc | 63 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 6 |
5 files changed, 57 insertions, 58 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index d19029e31f6..02d2d007b5d 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -33,7 +33,7 @@ INCLUDES = @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include -I../include \ LDADD = @CLIENT_EXTRA_LDFLAGS@ libmysqld.la pkglib_LTLIBRARIES = libmysqld.la -libmysqld_la_SOURCES = libmysqld.c lib_sql.cc +libmysqld_la_SOURCES = libmysqld.c lib_sql.cc lib_load.cc libmysqlsources = errmsg.c get_password.c password.c ## XXX: we should not have to duplicate info from the sources list @@ -50,7 +50,7 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \ opt_sum.cc procedure.cc records.cc slave.cc sql_acl.cc \ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \ sql_crypt.cc sql_db.cc sql_delete.cc sql_insert.cc sql_lex.cc \ - sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc \ + sql_list.cc sql_manager.cc sql_map.cc sql_parse.cc \ sql_rename.cc sql_repl.cc sql_select.cc sql_show.cc \ sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \ sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \ @@ -68,7 +68,7 @@ sqlobjects = convert.lo derror.lo field.lo field_conv.lo filesort.lo \ opt_sum.lo procedure.lo records.lo slave.lo sql_acl.lo \ sql_analyse.lo sql_base.lo sql_cache.lo sql_class.lo \ sql_crypt.lo sql_db.lo sql_delete.lo sql_insert.lo sql_lex.lo \ - sql_list.lo sql_load.lo sql_manager.lo sql_map.lo sql_parse.lo \ + sql_list.lo sql_manager.lo sql_map.lo sql_parse.lo \ sql_rename.lo sql_repl.lo sql_select.lo sql_show.lo \ sql_string.lo sql_table.lo sql_test.lo sql_udf.lo \ sql_update.lo sql_yacc.lo table.lo thr_malloc.lo time.lo \ diff --git a/libmysqld/README b/libmysqld/README deleted file mode 100644 index c2febf3f19c..00000000000 --- a/libmysqld/README +++ /dev/null @@ -1,26 +0,0 @@ -LIBRARY (ONE_PROCESS VERSION) OF MYSQL CLIENT - -Installation steps: - - -1) unpack mysql-3.23.27-beta.tar tarball source version (get from www.mysql.com.sg) -2) patch mysql-3.23.27-beta with lbver-3.23.27-beta.diff: - patch -p0 <lbver-3.23.27-beta.diff -3) cd mysql-3.23.27-beta -4) autoconf -7) ./configure --prefix=/usr/local/mysql --with-library-version -8) make -9) make install (should have the root privileges) -10)mkdir /usr/local/mysql/var (if not already) -15) cd ../client -19) ./mysql (start libarary version mysql) -mysql> create database db1; -mysql> use db1; -mysql> create table a123(i integer) -...... now you can work with library version.... - - - - - - diff --git a/libmysqld/lib_load.cc b/libmysqld/lib_load.cc index 7bdc8837878..37bd611b483 100644 --- a/libmysqld/lib_load.cc +++ b/libmysqld/lib_load.cc @@ -21,19 +21,17 @@ int mysql_load_internal(THD * thd, sql_exchange * ex, TABLE_LIST * table_list, -List<Item> & fields, enum enum_duplicates handle_duplicates, -bool read_file_from_client, thr_lock_type lock_type); + List<Item> & fields, enum enum_duplicates handle_duplicates, + bool read_file_from_client, thr_lock_type lock_type); int mysql_load(THD * thd, sql_exchange * ex, TABLE_LIST * table_list, -List<Item> & fields, enum enum_duplicates handle_duplicates, -bool read_file_from_client, thr_lock_type lock_type) + List<Item> & fields, enum enum_duplicates handle_duplicates, + bool read_file_from_client, thr_lock_type lock_type) { - printf("SWSOFT_MYSQL load: \n"); read_file_from_client = 0; //server is always in the same process - return mysql_load_internal(thd, ex, table_list, fields, handle_duplicates, - read_file_from_client, lock_type); - + return mysql_load_internal(thd, ex, table_list, fields, handle_duplicates, + read_file_from_client, lock_type); } #define mysql_load mysql_load_internal 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) { diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 216261e220d..0e66ceb2f40 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -75,14 +75,12 @@ my_string mysql_unix_port=0; #endif /* XXX: this is real ugly... */ -static void mysql_once_init(void); -extern void embedded_srv_init(void); -extern void embedded_srv_deinit(void); extern void start_embedded_connection(NET * net); extern void lib_connection_phase(NET *net, int phase); extern bool lib_dispatch_command(enum enum_server_command command, NET *net, const char *arg, ulong length); +static void mysql_once_init(void); static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields, uint field_count); static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, @@ -791,10 +789,8 @@ static void mysql_once_init() { mysql_client_init=1; my_init(); /* Will init threads */ - embedded_srv_init(); init_client_errs(); mysql_port = MYSQL_PORT; - DEBUGGER_ON; mysql_debug(NullS); } #ifdef THREAD |