summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-10-02 05:53:00 +0300
committerunknown <monty@hundin.mysql.fi>2001-10-02 05:53:00 +0300
commit9e72e1ef534384ab53a0c5943399c946856bef76 (patch)
treeb029d516fe4b48e540f64b01492d64cf5d68ad2f /libmysqld
parent003ed4cfaecf0c80dc2ced8593e869076cd8c34d (diff)
downloadmariadb-git-9e72e1ef534384ab53a0c5943399c946856bef76.tar.gz
Cleaned up SSL documentation
Fixes for embedded server Made key_cache more configurable Fixed that one can change key blocksize in MyISAM A lot of optimizations to make MyISAM slightly faster Docs/manual.texi: Cleaned up SSL documentation client/mysql.cc: Fixes for embedded server client/mysqltest.c: Fixes for embedded server Removed memory and file leaks include/my_global.h: Added C_MODE_START / C_MODE_END macros include/my_sys.h: Made key_cache more configurable include/myisam.h: Fixed that one can change MyISAM key block size include/mysql.h: Fixes for embedded server libmysql/libmysql.c: Cleanup libmysqld/Makefile.am: Cleanup libmysqld/examples/test-run: Added --debug libmysqld/lib_sql.cc: Cleanup libmysqld/libmysqld.c: Cleanup myisam/ft_boolean_search.c: Optimized mi_key_cmp to be faster myisam/ft_nlq_search.c: Optimized mi_key_cmp to be faster myisam/ft_search.c: Optimized mi_key_cmp to be faster myisam/mi_changed.c: Optimized mi_key_cmp to be faster myisam/mi_check.c: Optimized mi_key_cmp to be faster myisam/mi_create.c: Fixed that one can change blocksize by changing myisam_block_size myisam/mi_delete.c: Optimized mi_key_cmp to be faster myisam/mi_delete_all.c: Optimized mi_key_cmp to be faster myisam/mi_dynrec.c: Speed optimizations myisam/mi_info.c: Speed optimizations myisam/mi_key.c: Speed optimizations myisam/mi_locking.c: Speed optimizations myisam/mi_open.c: Fixed that one can change blocksize by changing myisam_block_size myisam/mi_page.c: Fixed that one can change blocksize by changing myisam_block_size myisam/mi_range.c: Speed optimizations myisam/mi_rkey.c: Speed optimizations myisam/mi_rnext.c: Speed optimizations myisam/mi_rnext_same.c: Speed optimizations myisam/mi_rprev.c: Speed optimizations myisam/mi_rsame.c: Speed optimizations myisam/mi_search.c: Speed optimizations myisam/mi_static.c: Fixed that one can change blocksize by changing myisam_block_size myisam/mi_statrec.c: Speed optimizations myisam/mi_test2.c: Added more test options myisam/mi_test_all.res: Added more test options myisam/mi_test_all.sh: Added more test options myisam/mi_write.c: Speed optimizations myisam/myisamchk.c: Added options to change block size and repair checksums myisam/myisamdef.h: Speed optimizations mysys/Makefile.am: Added bit handling functions mysys/mf_keycache.c: Made key_cache more configurable mysys/my_init.c: made my_init_done global scripts/mysql_fix_privilege_tables.sh: Fixes for SSL scripts/mysql_install_db.sh: Fixes for SSL sql/derror.cc: Don't call exit, call unireg_abort() sql/item_cmpfunc.cc: Speed optimizations sql/item_cmpfunc.h: Speed optimizations sql/mysql_priv.h: Fixes for embedded server sql/mysqld.cc: Fixes for embedded server
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/Makefile.am2
-rw-r--r--libmysqld/embedded_priv.h32
-rwxr-xr-xlibmysqld/examples/test-run4
-rw-r--r--libmysqld/lib_sql.cc230
-rw-r--r--libmysqld/libmysqld.c42
5 files changed, 123 insertions, 187 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 1f0b15d15b6..e39cebff04a 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -39,6 +39,8 @@ libmysqlsources = errmsg.c get_password.c password.c
## XXX: we should not have to duplicate info from the sources list
libmysqlobjects = errmsg.lo get_password.lo password.lo
+noinst_HEADERS = embedded_priv.h
+
sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
ha_innobase.cc ha_berkeley.cc ha_heap.cc ha_isam.cc ha_isammrg.cc \
ha_myisam.cc ha_myisammrg.cc handler.cc sql_handler.cc \
diff --git a/libmysqld/embedded_priv.h b/libmysqld/embedded_priv.h
new file mode 100644
index 00000000000..96d2c96ed0b
--- /dev/null
+++ b/libmysqld/embedded_priv.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/* Prototypes for the embedded version of MySQL */
+
+#include <my_global.h>
+#include <mysql_embed.h>
+#include <mysql.h>
+#include <mysql_version.h>
+#include <mysqld_error.h>
+#include <my_pthread.h>
+
+C_MODE_START
+extern void start_embedded_connection(NET * net);
+extern void end_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);
+C_MODE_END
diff --git a/libmysqld/examples/test-run b/libmysqld/examples/test-run
index 1e15126b126..58c21349519 100755
--- a/libmysqld/examples/test-run
+++ b/libmysqld/examples/test-run
@@ -43,6 +43,7 @@ usage: $0 [-g|-h|-r] [test-name ...]
EOF
}
+init_args=""
while test $# -gt 0
do
arg=
@@ -56,6 +57,7 @@ do
-h | --help | -\? ) usage; exit 0;;
-l | --list ) list=1 ; shift ;;
-r | --run ) run="${cr}run"; shift;;
+ --debug) init_args="$init_args --debug" ; shift ;;
-s | --start=* )
test $argset -eq 0 && { shift; arg="$1"; }
start="$arg"
@@ -103,7 +105,7 @@ do
echo "test '$b' doesn't exist" >&2
continue
}
- args="-v -S /tmp/mysql.sock -R $r -x $t test"
+ args="$init_args -v -S /tmp/mysql.sock -R $r -x $t test"
echo "set args $args$run" > test-gdbinit
#if false && test -n "$run"
if test -n "$run" -o $gdb -eq 1
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index f2599fe4016..5641e920c9d 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -12,9 +12,7 @@
* modified is included with the above copyright notice.
*
*/
-#include "my_global.h"
-#include "mysql_embed.h"
-#include "my_pthread.h"
+#include "embedded_priv.h"
#include "sys/types.h"
#include "../regex/regex.h"
#include "my_sys.h"
@@ -47,13 +45,11 @@ static bool check_user(THD *thd, enum_server_command command,
void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
#define free_defaults free_defaults_internal
-char mysql_data_home[FN_REFLEN];
-char * get_mysql_data_home() { return mysql_data_home; }
-#define mysql_data_home mysql_data_home_internal
#include "../sql/mysqld.cc"
#define SCRAMBLE_LENGTH 8
-extern "C" {
+C_MODE_START
+
char * get_mysql_home(){ return mysql_home;};
char * get_mysql_real_data_home(){ return mysql_real_data_home;};
@@ -85,7 +81,7 @@ void lib_connection_phase(NET * net, int phase)
}
}
}
-} /* extern "C" */
+C_MODE_END
void start_embedded_conn1(NET * net)
@@ -105,7 +101,6 @@ void start_embedded_conn1(NET * net)
if (v)
{
v -> dest_thd = thd;
- /* v -> dest_net = &thd->net; XXX: Probably not needed? */
}
thd->net.vio = v;
if (thd->store_globals())
@@ -296,10 +291,14 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
}
-extern "C"{
-void mysql_server_init(int argc, const char **argv, const char **groups)
+extern "C"
+{
+
+static my_bool inited, org_my_init_done;
+
+int mysql_server_init(int argc, const char **argv, const char **groups)
{
- char hostname[FN_REFLEN];
+ char glob_hostname[FN_REFLEN];
/* This mess is to allow people to call the init function without
* having to mess with a fake argv */
@@ -323,7 +322,16 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
my_umask=0660; // Default umask for new files
my_umask_dir=0700; // Default umask for new directories
- MY_INIT((char *)"mysqld_server"); // init my_sys library & pthreads
+
+ /* Only call MY_INIT() if it hasn't been called before */
+ if (!inited)
+ {
+ inited=1;
+ org_my_init_done=my_init_done;
+ }
+ if (!org_my_init_done)
+ MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
+
tzset(); // Set tzname
start_time=time((time_t*) 0);
@@ -332,49 +340,34 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
{
struct tm tm_tmp;
localtime_r(&start_time,&tm_tmp);
- strmov(time_zone,tzname[tm_tmp.tm_isdst == 1 ? 1 : 0]);
+ strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
}
#else
{
struct tm *start_tm;
start_tm=localtime(&start_time);
- strmov(time_zone=tzname[start_tm->tm_isdst == 1 ? 1 : 0]);
+ strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]);
}
#endif
#endif
- if (gethostname(hostname,sizeof(hostname)-4) < 0)
- strmov(hostname,"mysql");
- strmov(pidfile_name,hostname);
- strmov(strcend(pidfile_name,'.'),".pid"); // Add extension
-#ifdef DEMO_VERSION
- strcat(server_version,"-demo");
-#endif
-#ifdef SHAREWARE_VERSION
- strcat(server_version,"-shareware");
-#endif
+ if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
+ strmov(glob_hostname,"mysql");
#ifndef DBUG_OFF
strcat(server_version,"-debug");
#endif
- strcat(server_version,"-library-ver");
-#ifdef _CUSTOMSTARTUPCONFIG_
- if (_cust_check_startup())
- {
- /* _cust_check_startup will report startup failure error */
- exit( 1 );
- }
-#endif
+ strcat(server_version,"-embedded");
load_defaults("my", groups, argcp, argvp);
defaults_argv=*argvp;
mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
if (!mysql_tmpdir)
mysql_tmpdir=getenv("TEMP");
if (!mysql_tmpdir)
mysql_tmpdir=getenv("TMP");
#endif
if (!mysql_tmpdir || !mysql_tmpdir[0])
- mysql_tmpdir=strdup((char*) P_tmpdir);
+ mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
set_options();
get_options(*argcp, *argvp);
@@ -415,23 +408,20 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
(void) pthread_cond_init(&COND_slave_start, NULL);
if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
- unireg_abort(1);
+ {
+ mysql_server_end();
+ return 1;
+ }
charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS));
-
- if (!(opt_specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
/* Parameter for threads created for connections */
(void) pthread_attr_init(&connection_attrib);
(void) pthread_attr_setdetachstate(&connection_attrib,
PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&connection_attrib,thread_stack);
-
- if (!(opt_specialflag & SPECIAL_NO_PRIOR))
- my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
-#ifdef SET_RLIMIT_NOFILE
+#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
/* connections and databases neads lots of files */
{
uint wanted_files=10+(uint) max(max_connections*5,
@@ -456,64 +446,57 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
#ifdef USE_REGEX
regex_init();
#endif
- select_thread=pthread_self();
- select_thread_in_use=1;
+ if (use_temp_pool && bitmap_init(&temp_pool,1024))
+ {
+ mysql_server_end();
+ return 1;
+ }
/*
** We have enough space for fiddling with the argv, continue
*/
umask(((~my_umask) & 0666));
-// strcpy(mysql_real_data_home, "/usr/local");
- //if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
- //{
- // unireg_abort(1); /* purecov: inspected */
- //}
- //mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
- //mysql_data_home[1]=0;
-
- strcpy(get_mysql_data_home(), mysql_real_data_home);
-
- //server_init();
table_cache_init();
hostname_cache_init();
sql_cache_init();
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions();
init_thr_lock();
+ init_slave_list();
/* Setup log files */
if (opt_log)
- open_log(&mysql_log, hostname, opt_logname, ".log", LOG_NORMAL);
+ open_log(&mysql_log, glob_hostname, opt_logname, ".log", LOG_NORMAL);
if (opt_update_log)
- open_log(&mysql_update_log, hostname, opt_update_logname, "",
+ {
+ open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW);
+ using_update_log=1;
+ }
if (opt_bin_log)
{
- if(server_id)
- {
- if (!opt_bin_logname)
- {
- char tmp[FN_REFLEN];
- strnmov(tmp,hostname,FN_REFLEN-5);
- strmov(strcend(tmp,'.'),"-bin");
- opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
- }
- mysql_bin_log.set_index_file_name(opt_binlog_index_name);
- open_log(&mysql_bin_log, hostname, opt_bin_logname, "-bin",
- LOG_BIN);
- }
- else
- sql_print_error("Server id is not set - binary logging disabled");
+ if (!opt_bin_logname)
+ {
+ char tmp[FN_REFLEN];
+ strmake(tmp,glob_hostname,FN_REFLEN-5);
+ strmov(strcend(tmp,'.'),"-bin");
+ opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
+ }
+ mysql_bin_log.set_index_file_name(opt_binlog_index_name);
+ open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
+ LOG_BIN);
+ using_update_log=1;
}
if (opt_slow_log)
- open_log(&mysql_slow_log, hostname, opt_slow_logname, "-slow.log",
+ open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL);
if (ha_init())
{
sql_print_error("Can't init databases");
exit(1);
}
+ ha_key_cache();
#ifdef HAVE_MLOCKALL
if (locked_in_memory && !geteuid())
{
@@ -544,105 +527,61 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
sql_print_error("Can't create thread-keys");
exit(1);
}
- //init_signals();
- opt_noacl = 1;
+ opt_noacl = 1; // No permissions
if (acl_init(opt_noacl))
{
- select_thread_in_use=0;
- (void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL);
- exit(1);
+ mysql_server_end();
+ return 1;
}
- if (!opt_noacl)
- (void) grant_init();
#ifdef HAVE_DLOPEN
if (!opt_noacl)
udf_init();
#endif
- if (opt_bootstrap)
- {
- int error=bootstrap(stdin);
- end_thr_alarm(); // Don't allow alarms
- unireg_abort(error ? 1 : 0);
- }
- if (opt_init_file)
- {
- if (read_init_file(opt_init_file))
- {
- end_thr_alarm(); // Don't allow alarms
- unireg_abort(1);
- }
- }
(void) thr_setconcurrency(concurrency); // 10 by default
- if (flush_time && flush_time != ~(ulong) 0L)
+ if (
+#ifdef HAVE_BERKELEY_DB
+ !berkeley_skip ||
+#endif
+ (flush_time && flush_time != ~(ulong) 0L))
{
pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
+ {
sql_print_error("Warning: Can't create thread to manage maintenance");
+ mysql_server_end();
+ return 1;
+ }
}
-
- // slave thread
- if(master_host)
- {
- if(server_id)
- {
- pthread_t hThread;
- if(!opt_skip_slave_start &&
- pthread_create(&hThread, &connection_attrib, handle_slave, 0))
- sql_print_error("Warning: Can't create thread to handle slave");
- }
- else
- sql_print_error("Server id is not set, slave thread will not be started");
- }
-
- //printf(ER(ER_READY),my_progname,server_version,"");
- //printf("%s initialized.\n", server_version);
- fflush(stdout);
+ return 0;
}
+
void mysql_server_end()
{
- /* (void) pthread_attr_destroy(&connection_attrib); */
-
- DBUG_PRINT("quit",("Exiting main thread"));
-
-#ifdef EXTRA_DEBUG
- sql_print_error("Before Lock_thread_count");
-#endif
- (void) pthread_mutex_lock(&LOCK_thread_count);
- select_thread_in_use=0; // For close_connections
- (void) pthread_cond_broadcast(&COND_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
-#ifdef EXTRA_DEBUG
- sql_print_error("After lock_thread_count");
+ clean_up(0);
+#ifdef THREAD
+ /* Don't call my_thread_end() if the application is using MY_INIT() */
+ if (!org_my_init_done)
+ my_thread_end();
#endif
-
-// /* Wait until cleanup is done */
-// (void) pthread_mutex_lock(&LOCK_thread_count);
-// while (!ready_to_exit)
-// {
-// pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
-// }
-// (void) pthread_mutex_unlock(&LOCK_thread_count);
- unireg_end(0);
- my_thread_end();
}
my_bool mysql_thread_init()
{
#ifdef THREAD
- return my_thread_init();
+ return my_thread_init();
#else
- return 0;
+ return 0;
#endif
}
void mysql_thread_end()
{
#ifdef THREAD
- my_thread_end();
+ my_thread_end();
#endif
}
@@ -651,11 +590,10 @@ void start_embedded_connection(NET * net)
start_embedded_conn1(net);
}
-} /* extern "C" */
-
-int embedded_do_command(NET * net)
+void end_embedded_connection(NET * net)
{
- THD * thd = (THD *) net ->vio;
- do_command(thd);
- return 0;
+ THD *thd = (THD *) net->vio->dest_thd;
+ delete thd;
}
+
+} /* extern "C" */
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 8931bc3cd48..c6860098ed8 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -15,15 +15,7 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
-#include <my_global.h>
-#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
-#include <winsock.h>
-#include <odbcinst.h>
-#endif
-#include "mysql_embed.h"
-#include "mysql.h"
-#include "mysql_version.h"
-#include "mysqld_error.h"
+#include "embedded_priv.h"
#include <my_sys.h>
#include <mysys_err.h>
#include <m_string.h>
@@ -51,9 +43,6 @@
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
-#if defined(THREAD) && !defined(__WIN__)
-#include <my_pthread.h> /* because of signal() */
-#endif
#ifndef INADDR_NONE
#define INADDR_NONE -1
#endif
@@ -74,12 +63,6 @@ my_string mysql_unix_port=0;
#define closesocket(A) close(A)
#endif
-/* XXX: this is real ugly... */
-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);
@@ -89,7 +72,6 @@ static void end_server(MYSQL *mysql);
static void read_user_name(char *name);
static void append_wild(char *to,char *end,const char *wild);
static int send_file_to_server(MYSQL *mysql,const char *filename);
-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);
@@ -402,22 +384,6 @@ mysql_debug(const char *debug)
#endif
}
-
-/**************************************************************************
-** Close the server connection if we get a SIGPIPE
- ARGSUSED
-**************************************************************************/
-
-static sig_handler
-pipe_sig_handler(int sig __attribute__((unused)))
-{
- DBUG_PRINT("info",("Hit by signal %d",sig));
-#ifdef DONT_REMEMBER_SIGNAL
- (void) signal(SIGPIPE,pipe_sig_handler);
-#endif
-}
-
-
/**************************************************************************
** Shut down connection
**************************************************************************/
@@ -428,11 +394,7 @@ end_server(MYSQL *mysql)
DBUG_ENTER("end_server");
if (mysql->net.vio != 0)
{
- init_sigpipe_variables
- DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
- set_sigpipe(mysql);
- vio_delete(mysql->net.vio);
- reset_sigpipe(mysql);
+ end_embedded_connection(&mysql->net);
mysql->net.vio= 0; /* Marker */
}
net_end(&mysql->net);