summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-07-23 20:39:36 +0300
committerunknown <monty@mashka.mysql.fi>2002-07-23 20:39:36 +0300
commit10bd14dee8488b59798e9b24db1c50759e9242ae (patch)
treedd3586b209432966efbbf77cd272760438711106 /libmysqld
parentb42ca98d34a2e834dfc454338493fa26553c8d20 (diff)
parenta8caad316a89d6eeb8c22e70bc7a5fd4cf6ce904 (diff)
downloadmariadb-git-10bd14dee8488b59798e9b24db1c50759e9242ae.tar.gz
merge
include/my_sys.h: Auto merged include/myisam.h: Auto merged myisam/mi_check.c: Auto merged sql/Makefile.am: Auto merged sql/ha_myisam.h: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_myisammrg.h: Auto merged sql/handler.cc: Auto merged sql/item.h: Auto merged sql/lex.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_union.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/structs.h: Auto merged
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/Makefile.am6
-rw-r--r--libmysqld/embedded_priv.h3
-rw-r--r--libmysqld/lib_sql.cc140
-rw-r--r--libmysqld/libmysqld.c3
4 files changed, 76 insertions, 76 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index a196adc7314..10a8459b66b 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -32,7 +32,7 @@ INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include \
noinst_LIBRARIES = libmysqld_int.a
pkglib_LIBRARIES = libmysqld.a
SUBDIRS = . examples
-libmysqld_sources= libmysqld.c lib_sql.cc lib_load.cc
+libmysqld_sources= libmysqld.c lib_sql.cc
libmysqlsources = errmsg.c get_password.c password.c
noinst_HEADERS = embedded_priv.h
@@ -46,10 +46,10 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
item_uniq.cc key.cc lock.cc log.cc log_event.cc mf_iocache.cc\
mini_client.cc net_pkg.cc net_serv.cc opt_ft.cc opt_range.cc \
opt_sum.cc procedure.cc records.cc sql_acl.cc \
- repl_failsafe.cc slave.cc \
+ repl_failsafe.cc slave.cc sql_load.cc sql_olap.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_manager.cc sql_map.cc sql_olap.cc sql_parse.cc \
+ sql_list.cc sql_manager.cc sql_map.cc set_var.cc sql_parse.cc \
sql_rename.cc sql_repl.cc sql_select.cc sql_do.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 \
diff --git a/libmysqld/embedded_priv.h b/libmysqld/embedded_priv.h
index 96d2c96ed0b..e17b72e84d8 100644
--- a/libmysqld/embedded_priv.h
+++ b/libmysqld/embedded_priv.h
@@ -17,9 +17,8 @@
/* Prototypes for the embedded version of MySQL */
#include <my_global.h>
-#include <mysql_embed.h>
#include <mysql.h>
-#include <mysql_version.h>
+#include <mysql_embed.h>
#include <mysqld_error.h>
#include <my_pthread.h>
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 60f0c74859b..d461c46d604 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -11,11 +11,9 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
- */
-#include "embedded_priv.h"
-#include "sys/types.h"
-#include "../regex/regex.h"
-#include "my_sys.h"
+
+ This code was modified by the MySQL team
+*/
/*
The following is needed to not cause conflicts when we include mysqld.cc
@@ -24,26 +22,6 @@
#define main main1
#define mysql_unix_port mysql_inix_port1
#define mysql_port mysql_port1
-#define net_read_timeout net_read_timeout1
-#define net_write_timeout net_write_timeout1
-#define changeable_vars changeable_vars1
-
-extern "C"
-{
-#include "mysql_com.h"
-#include "lib_vio.c"
-}
-
-
-class THD;
-
-static int check_connections1(THD * thd);
-static int check_connections2(THD * thd);
-static bool check_user(THD *thd, enum_server_command command,
- const char *user, const char *passwd, const char *db,
- bool check_count);
-void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
-#define free_defaults free_defaults_internal
#if defined (__WIN__)
#include "../sql/mysqld.cpp"
@@ -53,11 +31,16 @@ void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
#define SCRAMBLE_LENGTH 8
C_MODE_START
+#include "lib_vio.c"
+static int check_connections1(THD * thd);
+static int check_connections2(THD * thd);
+static bool check_user(THD *thd, enum_server_command command,
+ const char *user, const char *passwd, const char *db,
+ bool check_count);
char * get_mysql_home(){ return mysql_home;};
char * get_mysql_real_data_home(){ return mysql_real_data_home;};
-
bool lib_dispatch_command(enum enum_server_command command, NET *net,
const char *arg, ulong length)
{
@@ -117,7 +100,7 @@ void start_embedded_conn1(NET * net)
thd->dbug_thread_id=my_thread_id();
thd->thread_stack= (char*) &thd;
- if (thd->max_join_size == HA_POS_ERROR)
+ if (thd->variables.max_join_size == (ulong) HA_POS_ERROR)
thd->options |= OPTION_BIG_SELECTS;
thd->proc_info=0; // Remove 'login'
@@ -206,12 +189,12 @@ check_connections2(THD * thd)
#endif
if (connect_errors)
reset_host_errors(&thd->remote.sin_addr);
- if (thd->packet.alloc(net_buffer_length))
+ if (thd->packet.alloc(thd->variables.net_buffer_length))
return(ER_OUT_OF_RESOURCES);
thd->client_capabilities=uint2korr(net->read_pos);
- thd->max_packet_length=uint3korr(net->read_pos+2);
+ thd->max_client_packet_length=uint3korr(net->read_pos+2);
char *user= (char*) net->read_pos+5;
char *passwd= strend(user)+1;
char *db=0;
@@ -219,11 +202,9 @@ check_connections2(THD * thd)
return ER_HANDSHAKE_ERROR;
if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB)
db=strend(passwd)+1;
- if (thd->client_capabilities & CLIENT_INTERACTIVE)
- thd->inactive_timeout= thd->variables.net_interactive_timeout;
if (thd->client_capabilities & CLIENT_TRANSACTIONS)
thd->net.return_status= &thd->server_status;
- net->timeout=net_read_timeout;
+ net->read_timeout=thd->variables.net_read_timeout;
if (check_user(thd,COM_CONNECT, user, passwd, db, 1))
return (-1);
thd->password=test(passwd[0]);
@@ -249,7 +230,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
CLIENT_LONG_PASSWORD),&ur);
DBUG_PRINT("info",
("Capabilities: %d packet_length: %d Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'",
- thd->client_capabilities, thd->max_packet_length,
+ thd->client_capabilities, thd->max_client_packet_length,
thd->host_or_ip, thd->priv_user,
passwd[0] ? "yes": "no",
thd->master_access, thd->db ? thd->db : "*none*"));
@@ -297,6 +278,7 @@ extern "C"
{
static my_bool inited, org_my_init_done;
+ulong max_allowed_packet, net_buffer_length;
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
@@ -358,20 +340,24 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql");
#ifndef DBUG_OFF
- strcat(server_version,"-debug");
+ strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
+#else
+ strmov(strend(server_version),MYSQL_SERVER_SUFFIX);
#endif
- strcat(server_version,"-embedded");
load_defaults("my", (const char **) groups, argcp, argvp);
defaults_argv=*argvp;
- mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
+
+ /* Get default temporary directory */
+ opt_mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
#if defined( __WIN__) || defined(OS2)
- if (!mysql_tmpdir)
- mysql_tmpdir=getenv("TEMP");
- if (!mysql_tmpdir)
- mysql_tmpdir=getenv("TMP");
+ if (!opt_mysql_tmpdir)
+ opt_mysql_tmpdir=getenv("TEMP");
+ if (!opt_mysql_tmpdir)
+ opt_mysql_tmpdir=getenv("TMP");
#endif
- if (!mysql_tmpdir || !mysql_tmpdir[0])
- mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
+ if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
+ opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
+
set_options();
get_options(*argcp, *argvp);
@@ -398,15 +384,19 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
(void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST);
+ (void) pthread_mutex_init(&LOCK_server_id, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
+ (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
+ (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
+ (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
(void) pthread_cond_init(&COND_thread_count,NULL);
(void) pthread_cond_init(&COND_refresh,NULL);
(void) pthread_cond_init(&COND_thread_cache,NULL);
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
(void) pthread_cond_init(&COND_manager,NULL);
- (void) pthread_cond_init(&COND_binlog_update, NULL);
+ (void) pthread_cond_init(&COND_rpl_status, NULL);
- if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
+ if (set_default_charset_by_name(sys_charset.value, MYF(MY_WME)))
{
mysql_server_end();
return 1;
@@ -420,13 +410,15 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
pthread_attr_setstacksize(&connection_attrib,thread_stack);
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
-#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
- /* connections and databases neads lots of files */
+#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
+ /* connections and databases needs lots of files */
{
uint wanted_files=10+(uint) max(max_connections*5,
max_connections+table_cache_size*2);
+ set_if_bigger(wanted_files, open_files_limit);
+ // Note that some system returns 0 if we succeed here:
uint files=set_maximum_open_files(wanted_files);
- if (files && files < wanted_files) // Some systems return 0
+ if (files && files < wanted_files && ! open_files_limit)
{
max_connections= (ulong) min((files-10),max_connections);
table_cache_size= (ulong) max((files-10-max_connections)/2,64);
@@ -441,6 +433,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
init_errmessage(); /* Read error messages from file */
lex_init();
item_init();
+ set_var_init();
mysys_uses_curses=0;
#ifdef USE_REGEX
regex_init();
@@ -452,12 +445,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
}
/*
- ** We have enough space for fiddling with the argv, continue
+ We have enough space for fiddling with the argv, continue
*/
umask(((~my_umask) & 0666));
table_cache_init();
hostname_cache_init();
- /*sql_cache_init();*/
+ query_cache_result_size_limit(query_cache_limit);
+ query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions();
init_thr_lock();
@@ -472,20 +466,6 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
LOG_NEW);
using_update_log=1;
}
- if (opt_bin_log)
- {
- 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, glob_hostname, opt_slow_logname, "-slow.log",
@@ -496,10 +476,9 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
exit(1);
}
ha_key_cache();
-#ifdef HAVE_MLOCKALL
+#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
if (locked_in_memory && !geteuid())
{
- ha_key_cache();
if (mlockall(MCL_CURRENT))
{
sql_print_error("Warning: Failed to lock memory. Errno: %d\n",errno);
@@ -513,7 +492,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
if (opt_myisam_log)
(void) mi_log( 1 );
- ft_init_stopwords(ft_precompiled_stopwords); /* SerG */
+ ft_init_stopwords(ft_precompiled_stopwords);
/*
init signals & alarm
@@ -532,12 +511,33 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
mysql_server_end();
return 1;
}
+ if (!opt_noacl)
+ (void) grant_init();
+ init_max_user_conn();
#ifdef HAVE_DLOPEN
if (!opt_noacl)
udf_init();
#endif
+ if (opt_bin_log)
+ {
+ if (!opt_bin_logname)
+ {
+ char tmp[FN_REFLEN];
+ /* TODO: The following should be using fn_format(); We just need to
+ first change fn_format() to cut the file name if it's too long.
+ */
+ 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;
+ }
+
(void) thr_setconcurrency(concurrency); // 10 by default
if (
@@ -548,12 +548,12 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
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;
- }
}
+
+ /* Update mysqld variables from client variables */
+ global_system_variables.max_allowed_packet=max_allowed_packet;
+ global_system_variables.net_buffer_length=net_buffer_length;
return 0;
}
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 59e6239c1e7..3fba238a8bf 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -794,6 +794,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
{
char buff[100],charset_name_buff[16],*end,*host_info, *charset_name;
uint pkt_length;
+ ulong max_allowed_packet;
NET *net= &mysql->net;
DBUG_ENTER("mysql_real_connect");
DBUG_PRINT("enter",("host: %s db: %s user: %s",
@@ -949,7 +950,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
int2store(buff,client_flag);
mysql->client_flag=client_flag;
-
+ max_allowed_packet=net->max_packet_size;
int3store(buff+2,max_allowed_packet);
if (user && user[0])
strmake(buff+5,user,32);