diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-08-11 17:08:21 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-08-11 17:08:21 -0600 |
commit | fa7bf21835ef154ef3ab477ee3fa8e9f40bb4e7b (patch) | |
tree | 52622ae9741cd2f7d41b4acdd139ece525f58430 | |
parent | a2579e699909c08213d96f5fa6dabc5ac417ed36 (diff) | |
parent | 4e416338ccf755af2e63db489b208e0b35e417f6 (diff) | |
download | mariadb-git-fa7bf21835ef154ef3ab477ee3fa8e9f40bb4e7b.tar.gz |
Merge work:/home/bk/mysql-4.0
into mysql.sashanet.com:/home/sasha/src/bk/mysql-4.0
BitKeeper/etc/logging_ok:
auto-union
libmysql/libmysql.c:
Auto merged
sql/mysqld.cc:
Auto merged
-rw-r--r-- | BitKeeper/etc/logging_ok | 1 | ||||
-rw-r--r-- | include/mysql.h | 20 | ||||
-rw-r--r-- | libmysql/libmysql.c | 22 | ||||
-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 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 |
9 files changed, 97 insertions, 63 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index c6322c3ac81..d1f33a8ff39 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -17,6 +17,7 @@ paul@teton.kitebird.com root@x3.internalnet sasha@mysql.sashanet.com serg@serg.mysql.com +tim@black.box tim@hundin.mysql.fi tim@threads.polyesthetic.msg tim@white.box diff --git a/include/mysql.h b/include/mysql.h index b4a7f977cd5..9578336a945 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -15,8 +15,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -/* defines for the libmysql library */ - #ifndef _mysql_h #define _mysql_h @@ -222,6 +220,20 @@ typedef struct st_mysql_res { my_bool eof; /* Used my mysql_fetch_row */ } MYSQL_RES; + +/* Set up and bring down the server; to ensure that applications will + * work when linked against either the standard client library or the + * embedded server library, these functions should be called. */ +void mysql_server_init(int argc, char **argv, const char **groups); +void mysql_server_end(); + +/* Set up and bring down a thread; these function should be called + * for each thread in an application which opens at least one MySQL + * connection. All uses of the connection(s) should be between these + * function calls. */ +my_bool mysql_thread_init(); +void mysql_thread_end(); + /* Functions to get information from the MYSQL and MYSQL_RES structures */ /* Should definitely be used if one uses shared libraries */ @@ -359,15 +371,13 @@ unsigned int STDCALL mysql_thread_safe(void); #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) -#ifndef USE_OLD_FUNCTIONS +#ifdef USE_OLD_FUNCTIONS MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd); int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); #endif -/* new api functions */ - #define HAVE_MYSQL_REAL_CONNECT #ifndef MYSQL_SERVER diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 378744b9f1b..a23fa732fb6 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -94,6 +94,28 @@ static sig_handler pipe_sig_handler(int sig); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, const char *from, ulong length); +void mysql_server_init(int argc __attribute__((unused)), + char **argv __attribute__((unused)), + const char **groups __attribute__((unused))) {} + +void mysql_server_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 +} + /* Let the user specify that we don't want SIGPIPE; This doesn't however work with threaded applications as we can have multiple read in progress. 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 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 09c464dd15b..d368050feaf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3275,6 +3275,7 @@ static void get_options(int argc,char **argv) myisam_delay_key_write=1; // Allow use of this my_use_symdir=1; // Use internal symbolic links + optind = 0; // setup in case getopt() was called previously while ((c=getopt_long(argc,argv,"ab:C:h:#::T::?l::L:O:P:sS::t:u:noVvWI?", long_options, &option_index)) != EOF) { @@ -3869,6 +3870,7 @@ static void get_options(int argc,char **argv) use_help(); exit(1); } + optind = 0; // setup so that getopt_long() can be called again fix_paths(); default_table_type_name=ha_table_typelib.type_names[default_table_type-1]; default_tx_isolation_name=tx_isolation_typelib.type_names[default_tx_isolation]; |