From a8caad316a89d6eeb8c22e70bc7a5fd4cf6ce904 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Jul 2002 18:31:22 +0300 Subject: New SET syntax & system variables. Made a some new buffers thread specific and changeable. Resize of key_buffer. AUTO_COMMIT -> AUTOCOMMIT Fixed mutex bug in DROP DATABASE Fixed bug when using auto_increment as second part of a key where first part could include NULL. Split handler->extra() to extra() and extra_opt() to be able to support thread specific buffers. Don't write message to error log when slave reconnects becasue of timeout. Fixed possible update problem when using DELETE/UPDATE on small tables (In some cases we used index even if table scanning would be better) A lot of minior code cleanups BitKeeper/deleted/.del-net.c~ef21d6402bb882f9: Delete: libmysql/net.c BitKeeper/etc/ignore: added libmysql/net.c Docs/manual.texi: New SET syntax & system variables. client/client_priv.h: moved order of include files client/mysql.cc: Removed compiler warning client/mysqladmin.c: Use new SHOW GLOBAL syntax (if server supports it) configure.in: version change include/Makefile.am: indentation cleanup include/my_getopt.h: Made some helper functions global include/my_sys.h: Removed not used code include/myisam.h: Added extra argument to ..._extra() include/myisammrg.h: Added extra argument to ..._extra() include/mysql_com.h: changed NET to be able to support changeable system variables include/mysql_embed.h: Added MYSQL_SERVER_SUFFIX include/mysql_version.h.in: Added check of multiple including (needed for embedded library) include/mysqld_error.h: New error messages innobase/dict/dict0dict.c: Remove compiler warnings innobase/include/ut0mem.h: Remove compiler warnings innobase/include/ut0mem.ic: Remove compiler warnings isam/isamchk.c: new init_key_cache() arguments isam/isamlog.c: new init_key_cache() arguments isam/test2.c: new init_key_cache() arguments isam/test3.c: new init_key_cache() arguments libmysql/Makefile.am: Removed net.c (Automaticly make it from net_serv.cc) libmysql/Makefile.shared: Removed net.c (Automaticly make it from net_serv.cc) libmysql/libmysql.c: Changeable system variables libmysqld/Makefile.am: Added set_var.cc file libmysqld/embedded_priv.h: Changed order of include fiels libmysqld/lib_sql.cc: merge with mysqld.cc (for changeable variables) libmysqld/libmysqld.c: New changeable system variables myisam/mi_check.c: Added extra argument to ..._extra() myisam/mi_extra.c: Added extra argument to ..._extra() myisam/mi_open.c: Removed not used variable myisam/mi_test1.c: Changed call to init_key_cache myisam/mi_test2.c: Added extra argument to ..._extra() myisam/mi_test3.c: Added extra argument to ..._extra() myisam/mi_write.c: Add cache size argument to bulk-insert-init myisam/myisamchk.c: Use new key cache myisam/myisamdef.h: new mi_init_bulk_insert() arguments myisam/myisamlog.c: Added extra argument to ..._extra() myisam/myisampack.c: Added extra argument to ..._extra() myisammrg/myrg_extra.c: Added extra argument to ..._extra() myisammrg/myrg_rrnd.c: Added extra argument to ..._extra() mysql-test/r/insert_select.result: New changeable system variables mysql-test/r/key.result: Test of bug in auto_increment mysql-test/r/query_cache.result: New changeable system variables mysql-test/r/rpl000001.result: New changeable system variables mysql-test/r/rpl000016.result: New changeable system variables mysql-test/r/union.result: New changeable system variables mysql-test/r/user_var.result: New changeable system variables mysql-test/r/variables.result: New changeable system variables mysql-test/t/key.test: Test of bug in auto_increment mysql-test/t/query_cache.test: New changeable system variables mysql-test/t/rpl000001.test: New changeable system variables mysql-test/t/rpl000009.test: New changeable system variables mysql-test/t/rpl000016.test: New changeable system variables mysql-test/t/rpl_compat.test: New changeable system variables mysql-test/t/union.test: New changeable system variables mysql-test/t/user_var.test: New changeable system variables mysql-test/t/variables.test: New changeable system variables mysys/default.c: Bigger default memory allocation mysys/mf_iocache.c: Removed compiler warning mysys/mf_keycache.c: Made key cache resizable on the fly Removed not needed extra argument to init_key_cache() mysys/my_getopt.c: Made some helper functions global sql/Makefile.am: Aded set_var.cc sql/convert.cc: Comment cleanup sql/field.cc: new changeable system variables sql/filesort.cc: new changeable system variables sql/ha_berkeley.cc: AUTO_COMMIT -> AUTOCOMMIT sql/ha_innodb.cc: new changeable system variables sql/ha_myisam.cc: Added extra argument to ..._extra() sql/ha_myisam.h: Added extra argument to ..._extra() sql/ha_myisammrg.cc: Added extra argument to ..._extra() sql/ha_myisammrg.h: Added extra argument to ..._extra() sql/handler.cc: Added extra argument to ..._extra() Added resize of key cache Change ha_table_typelib for use with new system variables sql/handler.h: Added extra argument to ..._extra() sql/item.cc: new changeable system variables sql/item.h: Added better support of Item_uint sql/item_func.cc: Added support for SET @@[global | session] system_variable sql/item_strfunc.cc: new changeable system variables sql/key.cc: Fixed bug in auto_increment on second part keys sql/lex.h: Removed not needed keywords sql/log.cc: new changeable system variables sql/log_event.cc: new changeable system variables sql/log_event.h: Removed not needed var reference sql/mini_client.cc: new changeable system variables code cleanup sql/mini_client.h: Indentation cleanup sql/mysql_priv.h: Changed order of include files & variables to make file more readable sql/mysqld.cc: Changed order of variables to make file more readable. Support for changeable variables Rename of system variables Moved init_vars to set_var.cc Changed output of --help sql/net_pkg.cc: Added my_net_local_init() to make it possible to set different defaults for network connection depending if you are a client, embedded library or server. sql/net_serv.cc: new changeable system variables To support this, some global variables had to be move to the NET structure. sql/records.cc: new changeable system variables use extra_opt() sql/repl_failsafe.cc: new changeable system variables minior code cleanups sql/repl_failsafe.h: removed not needed external var reference sql/share/czech/errmsg.txt: new changeable system variables sql/share/danish/errmsg.txt: new changeable system variables sql/share/dutch/errmsg.txt: new changeable system variables sql/share/english/errmsg.txt: new changeable system variables sql/share/estonian/errmsg.txt: new changeable system variables sql/share/french/errmsg.txt: new changeable system variables sql/share/german/errmsg.txt: new changeable system variables sql/share/greek/errmsg.txt: new changeable system variables sql/share/hungarian/errmsg.txt: new changeable system variables sql/share/italian/errmsg.txt: new changeable system variables sql/share/japanese/errmsg.txt: new changeable system variables sql/share/korean/errmsg.txt: new changeable system variables sql/share/norwegian-ny/errmsg.txt: new changeable system variables sql/share/norwegian/errmsg.txt: new changeable system variables sql/share/polish/errmsg.txt: new changeable system variables sql/share/portuguese/errmsg.txt: new changeable system variables sql/share/romanian/errmsg.txt: new changeable system variables sql/share/russian/errmsg.txt: new changeable system variables sql/share/slovak/errmsg.txt: new changeable system variables sql/share/spanish/errmsg.txt: new changeable system variables sql/share/swedish/errmsg.txt: new changeable system variables sql/share/ukrainian/errmsg.txt: new changeable system variables sql/slave.cc: new changeable system variables Added some suppression of error messages Initialize current_thd for all slave threads. sql/sql_acl.cc: Added checking of arguments for SET PASSWORD (for new SET defintion) sql/sql_acl.h: new prototypes sql/sql_base.cc: new changeable system variables sql/sql_cache.cc: new changeable system variables sql/sql_cache.h: Renamed some arguments to make code more readable sql/sql_class.cc: new changeable system variables sql/sql_class.h: New changeable system variables Code cleanup sql/sql_db.cc: Fixed bug in DROP DATABASE sql/sql_delete.cc: Usage of wrong define in test (possible speed problem) sql/sql_insert.cc: use extra_opt() Code cleanup sql/sql_lex.cc: Added support for SET @@[global | session] system_variable sql/sql_lex.h: Added support for SET @@[global | session] system_variable sql/sql_load.cc: Cleanup for embedded library Use extra_opt() sql/sql_parse.cc: Cleanup for embedded library New changeable system variables sql/sql_repl.cc: new changeable system variables sql/sql_repl.h: Fixed variable definitions sql/sql_select.cc: new changeable system variables sql/sql_show.cc: New changeable system variables sql/sql_table.cc: Fixed bug in DROP DATABASE sql/sql_union.cc: New changeable system variables sql/sql_update.cc: Usage of wrong define in test (possible speed problem) sql/sql_yacc.yy: New changeable system variables sql/structs.h: Added typedef for SHOW_VAR sql/table.cc: Fixed bug in auto_increment on second part keys sql/uniques.cc: Comment fix sql/unireg.h: A --- libmysqld/Makefile.am | 6 +- libmysqld/embedded_priv.h | 3 +- libmysqld/lib_sql.cc | 140 +++++++++++++++++++++++----------------------- libmysqld/libmysqld.c | 3 +- 4 files changed, 76 insertions(+), 76 deletions(-) (limited to 'libmysqld') diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index edee13c98bb..4b2b8dcb31c 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_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_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 -#include #include -#include +#include #include #include 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); -- cgit v1.2.1