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
This commit is contained in:
parent
373e19dca1
commit
dddc20d9d1
@ -480,3 +480,4 @@ mit-pthreads/machdep.c
|
||||
mit-pthreads/pg++
|
||||
mit-pthreads/pgcc
|
||||
scripts/mysql_tableinfo
|
||||
libmysql/net.c
|
||||
|
745
Docs/manual.texi
745
Docs/manual.texi
File diff suppressed because it is too large
Load Diff
@ -19,8 +19,8 @@
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <errmsg.h>
|
||||
#include <my_getopt.h>
|
||||
|
||||
|
@ -1487,7 +1487,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
||||
|
||||
static void init_pager()
|
||||
{
|
||||
#if !defined( __WIN__) && !defined( OS2) && (!defined(HAVE_mit_thread) && defined(THREAD))
|
||||
#if !defined( __WIN__) && !defined( OS2) && (!defined(HAVE_mit_thread) || !defined(THREAD))
|
||||
if (!opt_nopager)
|
||||
{
|
||||
if (!(PAGER= popen(pager, "w")))
|
||||
@ -2336,11 +2336,11 @@ com_status(String *buffer __attribute__((unused)),
|
||||
|
||||
if ((status=mysql_stat(&mysql)) && !mysql_error(&mysql)[0])
|
||||
{
|
||||
char *pos,buff[40];
|
||||
ulong sec;
|
||||
pos=strchr(status,' ');
|
||||
*pos++=0;
|
||||
tee_fprintf(stdout, "%s\t\t\t", status); /* print label */
|
||||
char buff[40];
|
||||
const char *pos= strchr(status,' ');
|
||||
/* print label */
|
||||
tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status), status);
|
||||
if ((status=str2int(pos,10,0,LONG_MAX,(long*) &sec)))
|
||||
{
|
||||
nice_time((double) sec,buff,0);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <my_pthread.h> /* because of signal() */
|
||||
#endif
|
||||
|
||||
#define ADMIN_VERSION "8.35"
|
||||
#define ADMIN_VERSION "8.36"
|
||||
#define MAX_MYSQL_VAR 128
|
||||
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
|
||||
#define MAX_TRUNC_LENGTH 3
|
||||
@ -588,7 +588,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
||||
MYSQL_ROW row;
|
||||
|
||||
new_line=1;
|
||||
if (mysql_query(mysql,"show variables") ||
|
||||
if (mysql_query(mysql,"show /*!40003 GLOBAL */ variables") ||
|
||||
!(res=mysql_store_result(mysql)))
|
||||
{
|
||||
my_printf_error(0,"unable to show variables; error: '%s'",MYF(ME_BELL),
|
||||
|
@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(sql/mysqld.cc)
|
||||
AC_CANONICAL_SYSTEM
|
||||
# The Docs Makefile.am parses this line!
|
||||
AM_INIT_AUTOMAKE(mysql, 4.0.2-alpha)
|
||||
AM_INIT_AUTOMAKE(mysql, 4.0.3-beta)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
PROTOCOL_VERSION=10
|
||||
|
@ -18,8 +18,8 @@
|
||||
BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h
|
||||
pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \
|
||||
mysql.h mysql_com.h mysqld_error.h mysql_embed.h \
|
||||
my_semaphore.h my_pthread.h my_no_pthread.h raid.h errmsg.h \
|
||||
my_global.h my_net.h my_alloc.h\
|
||||
my_semaphore.h my_pthread.h my_no_pthread.h raid.h \
|
||||
errmsg.h my_global.h my_net.h my_alloc.h\
|
||||
sslopt-case.h sslopt-longopts.h sslopt-usage.h \
|
||||
sslopt-vars.h $(BUILT_SOURCES)
|
||||
noinst_HEADERS = config-win.h \
|
||||
|
@ -49,4 +49,6 @@ extern int handle_options (int *argc, char ***argv,
|
||||
extern void my_print_help(const struct my_option *options);
|
||||
extern void my_print_variables(const struct my_option *options);
|
||||
|
||||
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);
|
||||
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
|
||||
C_MODE_END
|
||||
|
@ -494,18 +494,6 @@ my_off_t my_b_append_tell(IO_CACHE* info);
|
||||
#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
|
||||
*(info)->current_pos)
|
||||
|
||||
typedef struct st_changeable_var
|
||||
{
|
||||
const char *name; /* Name of variable */
|
||||
long *varptr; /* Pointer to variable */
|
||||
long def_value, /* Default value */
|
||||
min_value, /* Min allowed value */
|
||||
max_value, /* Max allowed value */
|
||||
sub_size, /* Subtract this from given value */
|
||||
block_size; /* Value should be a mult. of this */
|
||||
} CHANGEABLE_VAR;
|
||||
|
||||
|
||||
#include <my_alloc.h>
|
||||
|
||||
/* Prototypes for mysys and my_func functions */
|
||||
@ -647,7 +635,8 @@ extern int flush_write_cache(RECORD_CACHE *info);
|
||||
extern long my_clock(void);
|
||||
extern sig_handler sigtstp_handler(int signal_number);
|
||||
extern void handle_recived_signals(void);
|
||||
extern int init_key_cache(ulong use_mem,ulong leave_this_much_mem);
|
||||
extern int init_key_cache(ulong use_mem);
|
||||
extern int resize_key_cache(ulong use_mem);
|
||||
extern byte *key_cache_read(File file,my_off_t filepos,byte* buff,uint length,
|
||||
uint block_length,int return_buffer);
|
||||
extern int key_cache_write(File file,my_off_t filepos,byte* buff,uint length,
|
||||
@ -726,10 +715,6 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
|
||||
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
|
||||
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
|
||||
extern void dynstr_free(DYNAMIC_STRING *str);
|
||||
void set_all_changeable_vars(CHANGEABLE_VAR *vars);
|
||||
my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars);
|
||||
my_bool set_changeable_varval(const char *var, ulong val,
|
||||
CHANGEABLE_VAR *vars);
|
||||
#ifdef HAVE_MLOCK
|
||||
extern byte *my_malloc_lock(uint length,myf flags);
|
||||
extern void my_free_lock(byte *ptr,myf flags);
|
||||
|
@ -237,7 +237,8 @@ extern int mi_create(const char *name,uint keys,MI_KEYDEF *keydef,
|
||||
extern int mi_delete_table(const char *name);
|
||||
extern int mi_rename(const char *from, const char *to);
|
||||
extern int mi_extra(struct st_myisam_info *file,
|
||||
enum ha_extra_function function);
|
||||
enum ha_extra_function function,
|
||||
void *extra_arg);
|
||||
extern ha_rows mi_records_in_range(struct st_myisam_info *info,int inx,
|
||||
const byte *start_key,uint start_key_len,
|
||||
enum ha_rkey_function start_search_flag,
|
||||
@ -251,9 +252,8 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def);
|
||||
|
||||
/* this is used to pass to mysql_myisamchk_table -- by Sasha Pachev */
|
||||
|
||||
#define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r*/
|
||||
#define MYISAMCHK_VERIFY 2 /* run equivalent of myisamchk -c,
|
||||
* if corruption is detected, do myisamchk -r*/
|
||||
#define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */
|
||||
#define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */
|
||||
|
||||
/*
|
||||
Definitions needed for myisamchk.c
|
||||
|
@ -62,14 +62,15 @@ typedef struct st_myrg_table_info
|
||||
typedef struct st_myrg_info
|
||||
{
|
||||
MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
|
||||
uint merge_insert_method;
|
||||
ulonglong records; /* records in tables */
|
||||
ulonglong del; /* Removed records */
|
||||
ulonglong data_file_length;
|
||||
ulong cache_size;
|
||||
uint merge_insert_method;
|
||||
uint tables,options,reclength,keys;
|
||||
my_bool cache_in_use;
|
||||
LIST open_list;
|
||||
QUEUE by_key;
|
||||
LIST open_list;
|
||||
QUEUE by_key;
|
||||
} MYRG_INFO;
|
||||
|
||||
|
||||
@ -93,7 +94,8 @@ extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
|
||||
extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
|
||||
extern int myrg_create(const char *name, const char **table_names,
|
||||
uint insert_method, my_bool fix_names);
|
||||
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function);
|
||||
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
|
||||
void *extra_arg);
|
||||
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
|
||||
extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx,
|
||||
const byte *start_key,uint start_key_len,
|
||||
|
@ -21,7 +21,6 @@
|
||||
#ifndef _mysql_com_h
|
||||
#define _mysql_com_h
|
||||
|
||||
|
||||
#define NAME_LEN 64 /* Field/table name length */
|
||||
#define HOSTNAME_LENGTH 60
|
||||
#define USERNAME_LENGTH 16
|
||||
@ -115,9 +114,10 @@ typedef struct st_net {
|
||||
Vio* vio;
|
||||
unsigned char *buff,*buff_end,*write_pos,*read_pos;
|
||||
my_socket fd; /* For Perl DBI/dbd */
|
||||
unsigned long max_packet;
|
||||
unsigned long max_packet,max_packet_size;
|
||||
unsigned int last_errno,pkt_nr,compress_pkt_nr;
|
||||
unsigned int write_timeout,read_timeout;
|
||||
int fcntl;
|
||||
unsigned int last_errno,timeout,pkt_nr,compress_pkt_nr;
|
||||
char last_error[MYSQL_ERRMSG_SIZE];
|
||||
unsigned char error;
|
||||
my_bool return_errno,compress;
|
||||
@ -165,6 +165,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int my_net_init(NET *net, Vio* vio);
|
||||
void my_net_local_init(NET *net);
|
||||
void net_end(NET *net);
|
||||
void net_clear(NET *net);
|
||||
int net_flush(NET *net);
|
||||
|
@ -27,4 +27,8 @@
|
||||
#undef HAVE_ISAM
|
||||
|
||||
#define DONT_USE_RAID
|
||||
|
||||
#undef MYSQL_SERVER_SUFFIX
|
||||
#define MYSQL_SERVER_SUFFIX "-embedded"
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
/* Version numbers for protocol & mysqld */
|
||||
|
||||
#ifndef _mysql_version_h
|
||||
#define _mysql_version_h
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
@ -17,5 +19,6 @@
|
||||
/* mysqld compile time options */
|
||||
#ifndef MYSQL_CHARSET
|
||||
#define MYSQL_CHARSET "@default_charset@"
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MYSQL_CHARSET */
|
||||
#endif /* _CUSTOMCONFIG_ */
|
||||
#endif /* _mysql_version_h */
|
||||
|
@ -244,4 +244,10 @@
|
||||
#define ER_DUP_ARGUMENT 1225
|
||||
#define ER_USER_LIMIT_REACHED 1226
|
||||
#define ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
|
||||
#define ER_ERROR_MESSAGES 228
|
||||
#define ER_LOCAL_VARIABLE 1228
|
||||
#define ER_GLOBAL_VARIABLE 1229
|
||||
#define ER_NO_DEFAULT 1230
|
||||
#define ER_WRONG_VALUE_FOR_VAR 1231
|
||||
#define ER_WRONG_TYPE_FOR_VAR 1232
|
||||
#define ER_VAR_CANT_BE_READ 1233
|
||||
#define ER_ERROR_MESSAGES 234
|
||||
|
@ -1781,8 +1781,8 @@ char*
|
||||
dict_scan_to(
|
||||
/*=========*/
|
||||
|
||||
char* ptr, /* in: scan from */
|
||||
char* string) /* in: look for this */
|
||||
char* ptr, /* in: scan from */
|
||||
const char *string) /* in: look for this */
|
||||
{
|
||||
ibool success;
|
||||
ulint i;
|
||||
@ -1820,7 +1820,7 @@ dict_accept(
|
||||
/* out: if string was accepted, the pointer
|
||||
is moved after that, else ptr is returned */
|
||||
char* ptr, /* in: scan from this */
|
||||
char* string, /* in: accept only this string as the next
|
||||
const char* string, /* in: accept only this string as the next
|
||||
non-whitespace string */
|
||||
ibool* success)/* out: TRUE if accepted */
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ ut_strcpy(char* dest, char* sour);
|
||||
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
ut_strlen(char* str);
|
||||
ut_strlen(const char* str);
|
||||
|
||||
UNIV_INLINE
|
||||
int
|
||||
|
@ -36,7 +36,7 @@ ut_strcpy(char* dest, char* sour)
|
||||
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
ut_strlen(char* str)
|
||||
ut_strlen(const char* str)
|
||||
{
|
||||
return(strlen(str));
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ static int nisamchk(my_string filename)
|
||||
if (!rep_quick)
|
||||
{
|
||||
if (testflag & T_EXTEND)
|
||||
VOID(init_key_cache(use_buffers,(uint) NEED_MEM));
|
||||
VOID(init_key_cache(use_buffers));
|
||||
VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length,
|
||||
READ_CACHE,share->pack.header_length,1,
|
||||
MYF(MY_WME)));
|
||||
@ -1459,7 +1459,7 @@ my_string name;
|
||||
printf("Data records: %lu\n",(ulong) share->state.records);
|
||||
}
|
||||
|
||||
VOID(init_key_cache(use_buffers,NEED_MEM));
|
||||
VOID(init_key_cache(use_buffers));
|
||||
if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length,
|
||||
READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
|
||||
goto err;
|
||||
@ -1936,7 +1936,7 @@ int write_info;
|
||||
if (share->state.key_root[sort_key] == NI_POS_ERROR)
|
||||
DBUG_RETURN(0); /* Nothing to do */
|
||||
|
||||
init_key_cache(use_buffers,NEED_MEM);
|
||||
init_key_cache(use_buffers);
|
||||
if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length,
|
||||
WRITE_CACHE,share->pack.header_length,1,
|
||||
MYF(MY_WME | MY_WAIT_IF_FULL)))
|
||||
|
@ -329,7 +329,7 @@ static int examine_log(my_string file_name, char **table_names)
|
||||
bzero((gptr) com_count,sizeof(com_count));
|
||||
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1,
|
||||
(tree_element_free) file_info_free, NULL);
|
||||
VOID(init_key_cache(KEY_CACHE_SIZE,(uint) (10*4*(IO_SIZE+MALLOC_OVERHEAD))));
|
||||
VOID(init_key_cache(KEY_CACHE_SIZE));
|
||||
|
||||
files_open=0; access_time=0;
|
||||
while (access_time++ != number_of_commands &&
|
||||
|
@ -156,7 +156,7 @@ int main(int argc, char *argv[])
|
||||
goto err;
|
||||
printf("- Writing key:s\n");
|
||||
if (key_cacheing)
|
||||
init_key_cache(IO_SIZE*16,(uint) IO_SIZE*4*10); /* Use a small cache */
|
||||
init_key_cache(IO_SIZE*16); /* Use a small cache */
|
||||
if (locking)
|
||||
nisam_lock_database(file,F_WRLCK);
|
||||
if (write_cacheing)
|
||||
|
@ -171,7 +171,7 @@ void start_test(int id)
|
||||
exit(1);
|
||||
}
|
||||
if (key_cacheing && rnd(2) == 0)
|
||||
init_key_cache(65536L,(uint) IO_SIZE*4*10);
|
||||
init_key_cache(65536L);
|
||||
printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout);
|
||||
|
||||
for (error=i=0 ; i < tests && !error; i++)
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
# This file is public domain and comes with NO WARRANTY of any kind
|
||||
|
||||
target = libmysqlclient.la
|
||||
target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -DMYSQL_CLIENT
|
||||
LIBS = @CLIENT_LIBS@
|
||||
target = libmysqlclient.la
|
||||
target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -DMYSQL_CLIENT
|
||||
LIBS = @CLIENT_LIBS@
|
||||
INCLUDES = -I$(srcdir)/../include -I../include \
|
||||
-I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)
|
||||
|
||||
@ -60,7 +60,9 @@ link_sources:
|
||||
for f in $$ms $(mysysheaders); do \
|
||||
rm -f $(srcdir)/$$f; \
|
||||
@LN_CP_F@ $(srcdir)/../mysys/$$f $(srcdir)/$$f; \
|
||||
done;
|
||||
done; \
|
||||
rm -f $(srcdir)/net.c; \
|
||||
@LN_CP_F@ $(srcdir)/../sql/net_serv.cc $(srcdir)/net.c
|
||||
|
||||
# This part requires GNUmake
|
||||
#
|
||||
@ -77,7 +79,7 @@ nh = my_global.h config-win32.h dbug.h errmsg.h \
|
||||
mysql.h mysql_com.h mysql_version.h mysqld_error.h \
|
||||
mysys_err.h my_pthread.h thr_alarm.h violite.h hash.h
|
||||
# Get a list of the needed objects
|
||||
lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects)
|
||||
lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects) $(sqlobjects)
|
||||
|
||||
do-lib-dist:
|
||||
dir=libmysql-$(MYSQL_NO_DASH_VERSION); \
|
||||
|
@ -31,8 +31,8 @@ noinst_PROGRAMS = conf_to_src
|
||||
CHARSET_OBJS=@CHARSET_OBJS@
|
||||
LTCHARSET_OBJS= ${CHARSET_OBJS:.o=.lo}
|
||||
|
||||
target_sources = libmysql.c net.c password.c manager.c \
|
||||
get_password.c errmsg.c
|
||||
target_sources = libmysql.c password.c manager.c \
|
||||
get_password.c errmsg.c
|
||||
|
||||
mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
|
||||
strmake.lo strend.lo \
|
||||
@ -60,12 +60,13 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
|
||||
mf_iocache2.lo my_seek.lo \
|
||||
my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo \
|
||||
my_getopt.lo my_gethostbyname.lo
|
||||
sqlobjects = net.lo
|
||||
|
||||
# Not needed in the minimum library
|
||||
mysysobjects2 = my_lib.lo
|
||||
mysysobjects = $(mysysobjects1) $(mysysobjects2)
|
||||
target_libadd = $(mysysobjects) $(mystringsobjects) $(dbugobjects) \
|
||||
$(vio_objects)
|
||||
$(vio_objects) $(sqlobjects)
|
||||
target_ldflags = -version-info @SHARED_LIB_VERSION@
|
||||
vio_objects= vio.lo viosocket.lo viossl.lo viosslfactories.lo
|
||||
CLEANFILES = $(target_libadd) $(SHLIBOBJS) \
|
||||
@ -84,7 +85,7 @@ clean-local:
|
||||
`echo $(mysysobjects) | sed "s;\.lo;.c;g"` \
|
||||
`echo $(vio_objects) | sed "s;\.lo;.c;g"` \
|
||||
$(mystringsextra) $(mysysheaders) ctype_extra_sources.c \
|
||||
../linked_client_sources
|
||||
net.c ../linked_client_sources
|
||||
|
||||
ctype_extra_sources.c: conf_to_src
|
||||
./conf_to_src $(top_srcdir) @CHARSETS_NEED_SOURCE@ > \
|
||||
|
@ -59,6 +59,10 @@
|
||||
static my_bool mysql_client_init=0;
|
||||
uint mysql_port=0;
|
||||
my_string mysql_unix_port=0;
|
||||
ulong net_buffer_length=8192;
|
||||
ulong max_allowed_packet=16*1024*1024L;
|
||||
ulong net_read_timeout= NET_READ_TIMEOUT;
|
||||
ulong net_write_timeout= NET_WRITE_TIMEOUT;
|
||||
|
||||
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS)
|
||||
|
||||
@ -2889,6 +2893,18 @@ uint STDCALL mysql_thread_safe(void)
|
||||
Some support functions
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
Functions called my my_net_init() to set some application specific variables
|
||||
*/
|
||||
|
||||
void my_net_local_init(NET *net)
|
||||
{
|
||||
net->max_packet= (uint) net_buffer_length;
|
||||
net->read_timeout= (uint) net_read_timeout;
|
||||
net->write_timeout=(uint) net_write_timeout;
|
||||
net->max_packet_size= max(net_buffer_length, max_allowed_packet);
|
||||
}
|
||||
|
||||
/*
|
||||
Add escape characters to a string (blob?) to make it suitable for a insert
|
||||
to should at least have place for length*2+1 chars
|
||||
|
826
libmysql/net.c
826
libmysql/net.c
@ -1,826 +0,0 @@
|
||||
/* Copyright (C) 2000 MySQL 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 */
|
||||
|
||||
/* Write and read of logical packets to/from socket
|
||||
** Writes are cached into net_buffer_length big packets.
|
||||
** Read packets are reallocated dynamicly when reading big packets.
|
||||
** Each logical packet has the following pre-info:
|
||||
** 3 byte length & 1 byte package-number.
|
||||
*/
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define net_read_timeout net_read_timeout1
|
||||
#define net_write_timeout net_write_timeout1
|
||||
#endif
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
#include <my_global.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <mysql_com.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <my_net.h>
|
||||
#include <violite.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
The following handles the differences when this is linked between the
|
||||
client and the server.
|
||||
|
||||
This gives an error if a too big packet is found
|
||||
The server can change this with the -O switch, but because the client
|
||||
can't normally do this the client should have a bigger max_allowed_packet.
|
||||
*/
|
||||
|
||||
#ifdef MYSQL_SERVER
|
||||
ulong max_allowed_packet=65536;
|
||||
extern ulong net_read_timeout,net_write_timeout;
|
||||
extern uint test_flags;
|
||||
#define USE_QUERY_CACHE
|
||||
extern void query_cache_insert(NET *net, const char *packet, ulong length);
|
||||
#else
|
||||
ulong max_allowed_packet=16*1024*1024L;
|
||||
ulong net_read_timeout= NET_READ_TIMEOUT;
|
||||
ulong net_write_timeout= NET_WRITE_TIMEOUT;
|
||||
#endif
|
||||
|
||||
#if defined(__WIN__) || !defined(MYSQL_SERVER)
|
||||
/* The following is because alarms doesn't work on windows. */
|
||||
#define NO_ALARM
|
||||
#endif
|
||||
|
||||
#ifndef NO_ALARM
|
||||
#include "my_pthread.h"
|
||||
void sql_print_error(const char *format,...);
|
||||
#define RETRY_COUNT mysqld_net_retry_count
|
||||
extern ulong mysqld_net_retry_count;
|
||||
extern ulong bytes_sent, bytes_received;
|
||||
extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
|
||||
#else
|
||||
#undef statistic_add
|
||||
#define statistic_add(A,B,C)
|
||||
#define DONT_USE_THR_ALARM
|
||||
#define RETRY_COUNT 1
|
||||
#endif /* NO_ALARM */
|
||||
|
||||
#include "thr_alarm.h"
|
||||
|
||||
#define TEST_BLOCKING 8
|
||||
#define MAX_THREE_BYTES 255L*255L*255L
|
||||
|
||||
ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */
|
||||
|
||||
static int net_write_buff(NET *net,const char *packet,ulong len);
|
||||
|
||||
|
||||
/* Init with packet info */
|
||||
|
||||
int my_net_init(NET *net, Vio* vio)
|
||||
{
|
||||
if (!(net->buff=(uchar*) my_malloc((uint32) net_buffer_length+
|
||||
NET_HEADER_SIZE + COMP_HEADER_SIZE,
|
||||
MYF(MY_WME))))
|
||||
return 1;
|
||||
if (net_buffer_length > max_allowed_packet)
|
||||
max_allowed_packet=net_buffer_length;
|
||||
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
|
||||
net->vio = vio;
|
||||
net->no_send_ok = 0;
|
||||
net->error=0; net->return_errno=0; net->return_status=0;
|
||||
net->timeout=(uint) net_read_timeout; /* Timeout for read */
|
||||
net->pkt_nr=net->compress_pkt_nr=0;
|
||||
net->write_pos=net->read_pos = net->buff;
|
||||
net->last_error[0]=0;
|
||||
net->compress=0; net->reading_or_writing=0;
|
||||
net->where_b = net->remain_in_buf=0;
|
||||
net->last_errno=0;
|
||||
net->query_cache_query=0;
|
||||
|
||||
if (vio != 0) /* If real connection */
|
||||
{
|
||||
net->fd = vio_fd(vio); /* For perl DBI/DBD */
|
||||
#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
|
||||
if (!(test_flags & TEST_BLOCKING))
|
||||
vio_blocking(vio, FALSE);
|
||||
#endif
|
||||
vio_fastsend(vio);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void net_end(NET *net)
|
||||
{
|
||||
my_free((gptr) net->buff,MYF(MY_ALLOW_ZERO_PTR));
|
||||
net->buff=0;
|
||||
}
|
||||
|
||||
/* Realloc the packet buffer */
|
||||
|
||||
static my_bool net_realloc(NET *net, ulong length)
|
||||
{
|
||||
uchar *buff;
|
||||
ulong pkt_length;
|
||||
if (length >= max_allowed_packet)
|
||||
{
|
||||
DBUG_PRINT("error",("Packet too large (%lu)", length));
|
||||
net->error=1;
|
||||
net->last_errno=ER_NET_PACKET_TOO_LARGE;
|
||||
return 1;
|
||||
}
|
||||
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
|
||||
/* We must allocate some extra bytes for the end 0 and to be able to
|
||||
read big compressed blocks */
|
||||
if (!(buff=(uchar*) my_realloc((char*) net->buff, (uint32) pkt_length +
|
||||
NET_HEADER_SIZE + COMP_HEADER_SIZE,
|
||||
MYF(MY_WME))))
|
||||
{
|
||||
net->error=1;
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno=ER_OUT_OF_RESOURCES;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
net->buff=net->write_pos=buff;
|
||||
net->buff_end=buff+(net->max_packet=pkt_length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove unwanted characters from connection */
|
||||
|
||||
void net_clear(NET *net)
|
||||
{
|
||||
#if !defined(EXTRA_DEBUG) && !defined(EMBEDDED_LIBRARY)
|
||||
int count; /* One may get 'unused' warn */
|
||||
bool is_blocking=vio_is_blocking(net->vio);
|
||||
if (is_blocking)
|
||||
vio_blocking(net->vio, FALSE);
|
||||
if (!vio_is_blocking(net->vio)) /* Safety if SSL */
|
||||
{
|
||||
while ( (count = vio_read(net->vio, (char*) (net->buff),
|
||||
(uint32) net->max_packet)) > 0)
|
||||
DBUG_PRINT("info",("skipped %d bytes from file: %s",
|
||||
count,vio_description(net->vio)));
|
||||
if (is_blocking)
|
||||
vio_blocking(net->vio, TRUE);
|
||||
}
|
||||
#endif /* EXTRA_DEBUG */
|
||||
net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */
|
||||
net->write_pos=net->buff;
|
||||
}
|
||||
|
||||
/* Flush write_buffer if not empty. */
|
||||
|
||||
int net_flush(NET *net)
|
||||
{
|
||||
int error=0;
|
||||
DBUG_ENTER("net_flush");
|
||||
if (net->buff != net->write_pos)
|
||||
{
|
||||
error=net_real_write(net,(char*) net->buff,
|
||||
(ulong) (net->write_pos - net->buff));
|
||||
net->write_pos=net->buff;
|
||||
}
|
||||
/* Sync packet number if using compression */
|
||||
if (net->compress)
|
||||
net->pkt_nr=net->compress_pkt_nr;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Write something to server/client buffer
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
** Write a logical packet with packet header
|
||||
** Format: Packet length (3 bytes), packet number(1 byte)
|
||||
** When compression is used a 3 byte compression length is added
|
||||
** NOTE: If compression is used the original package is modified!
|
||||
*/
|
||||
|
||||
int
|
||||
my_net_write(NET *net,const char *packet,ulong len)
|
||||
{
|
||||
uchar buff[NET_HEADER_SIZE];
|
||||
/*
|
||||
Big packets are handled by splitting them in packets of MAX_THREE_BYTES
|
||||
length. The last packet is always a packet that is < MAX_THREE_BYTES.
|
||||
(The last packet may even have a lengt of 0)
|
||||
*/
|
||||
while (len >= MAX_THREE_BYTES)
|
||||
{
|
||||
const ulong z_size = MAX_THREE_BYTES;
|
||||
int3store(buff, z_size);
|
||||
buff[3]= (uchar) net->pkt_nr++;
|
||||
if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) ||
|
||||
net_write_buff(net, packet, z_size))
|
||||
return 1;
|
||||
packet += z_size;
|
||||
len-= z_size;
|
||||
}
|
||||
/* Write last packet */
|
||||
int3store(buff,len);
|
||||
buff[3]= (uchar) net->pkt_nr++;
|
||||
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
|
||||
return 1;
|
||||
return net_write_buff(net,packet,len);
|
||||
}
|
||||
|
||||
/*
|
||||
Send a command to the server.
|
||||
As the command is part of the first data packet, we have to do some data
|
||||
juggling to put the command in there, without having to create a new
|
||||
packet.
|
||||
This function will split big packets into sub-packets if needed.
|
||||
(Each sub packet can only be 2^24 bytes)
|
||||
*/
|
||||
|
||||
int
|
||||
net_write_command(NET *net,uchar command,const char *packet,ulong len)
|
||||
{
|
||||
ulong length=len+1; /* 1 extra byte for command */
|
||||
uchar buff[NET_HEADER_SIZE+1];
|
||||
uint header_size=NET_HEADER_SIZE+1;
|
||||
buff[4]=command; /* For first packet */
|
||||
|
||||
if (length >= MAX_THREE_BYTES)
|
||||
{
|
||||
/* Take into account that we have the command in the first header */
|
||||
len= MAX_THREE_BYTES -1;
|
||||
do
|
||||
{
|
||||
int3store(buff, MAX_THREE_BYTES);
|
||||
buff[3]= (uchar) net->pkt_nr++;
|
||||
if (net_write_buff(net,(char*) buff, header_size) ||
|
||||
net_write_buff(net,packet,len))
|
||||
return 1;
|
||||
packet+= len;
|
||||
length-= MAX_THREE_BYTES;
|
||||
len=MAX_THREE_BYTES;
|
||||
header_size=NET_HEADER_SIZE;
|
||||
} while (length >= MAX_THREE_BYTES);
|
||||
len=length; /* Data left to be written */
|
||||
}
|
||||
int3store(buff,length);
|
||||
buff[3]= (uchar) net->pkt_nr++;
|
||||
return test(net_write_buff(net,(char*) buff,header_size) ||
|
||||
net_write_buff(net,packet,len) || net_flush(net));
|
||||
}
|
||||
|
||||
/*
|
||||
Caching the data in a local buffer before sending it.
|
||||
One can force the buffer to be flushed with 'net_flush'.
|
||||
*/
|
||||
|
||||
static int
|
||||
net_write_buff(NET *net,const char *packet,ulong len)
|
||||
{
|
||||
ulong left_length=(ulong) (net->buff_end - net->write_pos);
|
||||
|
||||
while (len > left_length)
|
||||
{
|
||||
memcpy((char*) net->write_pos,packet,left_length);
|
||||
if (net_real_write(net,(char*) net->buff,net->max_packet))
|
||||
return 1;
|
||||
net->write_pos=net->buff;
|
||||
packet+=left_length;
|
||||
len-=left_length;
|
||||
left_length=net->max_packet;
|
||||
}
|
||||
memcpy((char*) net->write_pos,packet,len);
|
||||
net->write_pos+=len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Read and write one packet using timeouts.
|
||||
If needed, the packet is compressed before sending.
|
||||
*/
|
||||
|
||||
int
|
||||
net_real_write(NET *net,const char *packet,ulong len)
|
||||
{
|
||||
long int length;
|
||||
char *pos,*end;
|
||||
thr_alarm_t alarmed;
|
||||
#ifndef NO_ALARM
|
||||
ALARM alarm_buff;
|
||||
#endif
|
||||
uint retry_count=0;
|
||||
my_bool net_blocking = vio_is_blocking(net->vio);
|
||||
DBUG_ENTER("net_real_write");
|
||||
|
||||
#if defined(MYSQL_SERVER) && defined(HAVE_QUERY_CACHE)
|
||||
if (net->query_cache_query != 0)
|
||||
query_cache_insert(net, packet, len);
|
||||
#endif
|
||||
|
||||
if (net->error == 2)
|
||||
DBUG_RETURN(-1); /* socket can't be used */
|
||||
|
||||
net->reading_or_writing=2;
|
||||
#ifdef HAVE_COMPRESS
|
||||
if (net->compress)
|
||||
{
|
||||
ulong complen;
|
||||
uchar *b;
|
||||
uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE;
|
||||
if (!(b=(uchar*) my_malloc((uint32) len + NET_HEADER_SIZE +
|
||||
COMP_HEADER_SIZE, MYF(MY_WME))))
|
||||
{
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno=ER_OUT_OF_RESOURCES;
|
||||
net->error=2;
|
||||
#endif
|
||||
net->reading_or_writing=0;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
memcpy(b+header_length,packet,len);
|
||||
|
||||
if (my_compress((byte*) b+header_length,&len,&complen))
|
||||
{
|
||||
DBUG_PRINT("warning",
|
||||
("Compression error; Continuing without compression"));
|
||||
complen=0;
|
||||
}
|
||||
int3store(&b[NET_HEADER_SIZE],complen);
|
||||
int3store(b,len);
|
||||
b[3]=(uchar) (net->compress_pkt_nr++);
|
||||
len+= header_length;
|
||||
packet= (char*) b;
|
||||
}
|
||||
#endif /* HAVE_COMPRESS */
|
||||
|
||||
/* DBUG_DUMP("net",packet,len); */
|
||||
#ifndef NO_ALARM
|
||||
thr_alarm_init(&alarmed);
|
||||
if (net_blocking)
|
||||
thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff);
|
||||
#else
|
||||
alarmed=0;
|
||||
#endif /* NO_ALARM */
|
||||
|
||||
pos=(char*) packet; end=pos+len;
|
||||
while (pos != end)
|
||||
{
|
||||
if ((long) (length=vio_write(net->vio,pos,(uint32) (end-pos))) <= 0)
|
||||
{
|
||||
my_bool interrupted = vio_should_retry(net->vio);
|
||||
#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
|
||||
if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
|
||||
{ /* Always true for client */
|
||||
if (!vio_is_blocking(net->vio))
|
||||
{
|
||||
while (vio_blocking(net->vio, TRUE) < 0)
|
||||
{
|
||||
if (vio_should_retry(net->vio) && retry_count++ < RETRY_COUNT)
|
||||
continue;
|
||||
#ifdef EXTRA_DEBUG
|
||||
fprintf(stderr,
|
||||
"%s: my_net_write: fcntl returned error %d, aborting thread\n",
|
||||
my_progname,vio_errno(net->vio));
|
||||
#endif /* EXTRA_DEBUG */
|
||||
net->error=2; /* Close socket */
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
retry_count=0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* (!defined(__WIN__) && !defined(__EMX__)) */
|
||||
if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) &&
|
||||
interrupted)
|
||||
{
|
||||
if (retry_count++ < RETRY_COUNT)
|
||||
continue;
|
||||
#ifdef EXTRA_DEBUG
|
||||
fprintf(stderr, "%s: write looped, aborting thread\n",
|
||||
my_progname);
|
||||
#endif /* EXTRA_DEBUG */
|
||||
}
|
||||
#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
|
||||
if (vio_errno(net->vio) == SOCKET_EINTR)
|
||||
{
|
||||
DBUG_PRINT("warning",("Interrupted write. Retrying..."));
|
||||
continue;
|
||||
}
|
||||
#endif /* defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) */
|
||||
net->error=2; /* Close socket */
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno= (interrupted ? ER_NET_WRITE_INTERRUPTED :
|
||||
ER_NET_ERROR_ON_WRITE);
|
||||
#endif /* MYSQL_SERVER */
|
||||
break;
|
||||
}
|
||||
pos+=length;
|
||||
statistic_add(bytes_sent,length,&LOCK_bytes_sent);
|
||||
}
|
||||
#ifndef __WIN__
|
||||
end:
|
||||
#endif
|
||||
#ifdef HAVE_COMPRESS
|
||||
if (net->compress)
|
||||
my_free((char*) packet,MYF(0));
|
||||
#endif
|
||||
if (thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
thr_end_alarm(&alarmed);
|
||||
vio_blocking(net->vio, net_blocking);
|
||||
}
|
||||
net->reading_or_writing=0;
|
||||
DBUG_RETURN(((int) (pos != end)));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Read something from server/clinet
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef NO_ALARM
|
||||
/*
|
||||
Help function to clear the commuication buffer when we get a too
|
||||
big packet
|
||||
*/
|
||||
|
||||
static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
|
||||
{
|
||||
ALARM alarm_buff;
|
||||
uint retry_count=0;
|
||||
if (!thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
if (!thr_alarm(alarmed,net->timeout,&alarm_buff) ||
|
||||
(!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0))
|
||||
return; /* Can't setup, abort */
|
||||
}
|
||||
while (remain > 0)
|
||||
{
|
||||
ulong length;
|
||||
if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L)
|
||||
{
|
||||
my_bool interrupted = vio_should_retry(net->vio);
|
||||
if (!thr_got_alarm(&alarmed) && interrupted)
|
||||
{ /* Probably in MIT threads */
|
||||
if (retry_count++ < RETRY_COUNT)
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
remain -= (uint32) length;
|
||||
statistic_add(bytes_received,length,&LOCK_bytes_received);
|
||||
}
|
||||
}
|
||||
#endif /* NO_ALARM */
|
||||
|
||||
|
||||
/*
|
||||
Reads one packet to net->buff + net->where_b
|
||||
Returns length of packet. Long packets are handled by my_net_read().
|
||||
This function reallocates the net->buff buffer if necessary.
|
||||
*/
|
||||
|
||||
static ulong
|
||||
my_real_read(NET *net, ulong *complen)
|
||||
{
|
||||
uchar *pos;
|
||||
long length;
|
||||
uint i,retry_count=0;
|
||||
ulong len=packet_error;
|
||||
thr_alarm_t alarmed;
|
||||
#ifndef NO_ALARM
|
||||
ALARM alarm_buff;
|
||||
#endif
|
||||
my_bool net_blocking=vio_is_blocking(net->vio);
|
||||
uint32 remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
|
||||
NET_HEADER_SIZE);
|
||||
*complen = 0;
|
||||
|
||||
net->reading_or_writing=1;
|
||||
thr_alarm_init(&alarmed);
|
||||
#ifndef NO_ALARM
|
||||
if (net_blocking)
|
||||
thr_alarm(&alarmed,net->timeout,&alarm_buff);
|
||||
#endif /* NO_ALARM */
|
||||
|
||||
pos = net->buff + net->where_b; /* net->packet -4 */
|
||||
for (i=0 ; i < 2 ; i++)
|
||||
{
|
||||
while (remain > 0)
|
||||
{
|
||||
/* First read is done with non blocking mode */
|
||||
if ((int) (length=vio_read(net->vio,(char*) pos,remain)) <= 0L)
|
||||
{
|
||||
my_bool interrupted = vio_should_retry(net->vio);
|
||||
|
||||
DBUG_PRINT("info",("vio_read returned %d, errno: %d",
|
||||
length, vio_errno(net->vio)));
|
||||
#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
|
||||
/*
|
||||
We got an error that there was no data on the socket. We now set up
|
||||
an alarm to not 'read forever', change the socket to non blocking
|
||||
mode and try again
|
||||
*/
|
||||
if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
if (!thr_alarm(&alarmed,net->timeout,&alarm_buff)) /* Don't wait too long */
|
||||
{
|
||||
if (!vio_is_blocking(net->vio))
|
||||
{
|
||||
while (vio_blocking(net->vio,TRUE) < 0)
|
||||
{
|
||||
if (vio_should_retry(net->vio) &&
|
||||
retry_count++ < RETRY_COUNT)
|
||||
continue;
|
||||
DBUG_PRINT("error",
|
||||
("fcntl returned error %d, aborting thread",
|
||||
vio_errno(net->vio)));
|
||||
#ifdef EXTRA_DEBUG
|
||||
fprintf(stderr,
|
||||
"%s: read: fcntl returned error %d, aborting thread\n",
|
||||
my_progname,vio_errno(net->vio));
|
||||
#endif /* EXTRA_DEBUG */
|
||||
len= packet_error;
|
||||
net->error=2; /* Close socket */
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno=ER_NET_FCNTL_ERROR;
|
||||
#endif
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
retry_count=0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) */
|
||||
if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) &&
|
||||
interrupted)
|
||||
{ /* Probably in MIT threads */
|
||||
if (retry_count++ < RETRY_COUNT)
|
||||
continue;
|
||||
#ifdef EXTRA_DEBUG
|
||||
fprintf(stderr, "%s: read looped with error %d, aborting thread\n",
|
||||
my_progname,vio_errno(net->vio));
|
||||
#endif /* EXTRA_DEBUG */
|
||||
}
|
||||
#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
|
||||
if (vio_should_retry(net->vio))
|
||||
{
|
||||
DBUG_PRINT("warning",("Interrupted read. Retrying..."));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
DBUG_PRINT("error",("Couldn't read packet: remain: %lu errno: %d length: %ld alarmed: %d", remain,vio_errno(net->vio),length,alarmed));
|
||||
len= packet_error;
|
||||
net->error=2; /* Close socket */
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno= (interrupted ? ER_NET_READ_INTERRUPTED :
|
||||
ER_NET_READ_ERROR);
|
||||
#endif
|
||||
goto end;
|
||||
}
|
||||
remain -= (uint32) length;
|
||||
pos+= (ulong) length;
|
||||
statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received);
|
||||
}
|
||||
if (i == 0)
|
||||
{ /* First parts is packet length */
|
||||
ulong helping;
|
||||
if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr)
|
||||
{
|
||||
if (net->buff[net->where_b] != (uchar) 255)
|
||||
{
|
||||
DBUG_PRINT("error",
|
||||
("Packets out of order (Found: %d, expected %u)",
|
||||
(int) net->buff[net->where_b + 3],
|
||||
net->pkt_nr));
|
||||
#ifdef EXTRA_DEBUG
|
||||
fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n",
|
||||
(int) net->buff[net->where_b + 3],
|
||||
(uint) (uchar) net->pkt_nr);
|
||||
#endif
|
||||
}
|
||||
len= packet_error;
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno=ER_NET_PACKETS_OUT_OF_ORDER;
|
||||
#endif
|
||||
goto end;
|
||||
}
|
||||
net->compress_pkt_nr= ++net->pkt_nr;
|
||||
#ifdef HAVE_COMPRESS
|
||||
if (net->compress)
|
||||
{
|
||||
/* complen is > 0 if package is really compressed */
|
||||
*complen=uint3korr(&(net->buff[net->where_b + NET_HEADER_SIZE]));
|
||||
}
|
||||
#endif
|
||||
|
||||
len=uint3korr(net->buff+net->where_b);
|
||||
if (!len) /* End of big multi-packet */
|
||||
goto end;
|
||||
helping = max(len,*complen) + net->where_b;
|
||||
/* The necessary size of net->buff */
|
||||
if (helping >= net->max_packet)
|
||||
{
|
||||
if (net_realloc(net,helping))
|
||||
{
|
||||
#ifndef NO_ALARM
|
||||
if (i == 1)
|
||||
my_net_skip_rest(net, (uint32) len, &alarmed);
|
||||
#endif
|
||||
len= packet_error; /* Return error */
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
pos=net->buff + net->where_b;
|
||||
remain = (uint32) len;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
thr_end_alarm(&alarmed);
|
||||
vio_blocking(net->vio, net_blocking);
|
||||
}
|
||||
net->reading_or_writing=0;
|
||||
return(len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Read a packet from the client/server and return it without the internal
|
||||
package header.
|
||||
If the packet is the first packet of a multi-packet packet
|
||||
(which is indicated by the length of the packet = 0xffffff) then
|
||||
all sub packets are read and concatenated.
|
||||
If the packet was compressed, its uncompressed and the length of the
|
||||
uncompressed packet is returned.
|
||||
|
||||
The function returns the length of the found packet or packet_error.
|
||||
net->read_pos points to the read data.
|
||||
*/
|
||||
|
||||
ulong
|
||||
my_net_read(NET *net)
|
||||
{
|
||||
ulong len,complen;
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
if (!net->compress)
|
||||
{
|
||||
#endif
|
||||
len = my_real_read(net,&complen);
|
||||
if (len == MAX_THREE_BYTES)
|
||||
{
|
||||
/* First packet of a multi-packet. Concatenate the packets */
|
||||
ulong save_pos = net->where_b;
|
||||
ulong total_length=0;
|
||||
do
|
||||
{
|
||||
net->where_b += len;
|
||||
total_length += len;
|
||||
len = my_real_read (net,&complen);
|
||||
} while (len == MAX_THREE_BYTES);
|
||||
if (len != packet_error)
|
||||
len+= total_length;
|
||||
net->where_b = save_pos;
|
||||
}
|
||||
net->read_pos = net->buff + net->where_b;
|
||||
if (len != packet_error)
|
||||
net->read_pos[len]=0; /* Safeguard for mysql_use_result */
|
||||
return len;
|
||||
#ifdef HAVE_COMPRESS
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We are using the compressed protocol */
|
||||
|
||||
ulong buf_length= net->buf_length;
|
||||
ulong start_of_packet= net->buf_length - net->remain_in_buf;
|
||||
ulong first_packet_offset=start_of_packet;
|
||||
uint read_length, multi_byte_packet=0;
|
||||
|
||||
if (net->remain_in_buf)
|
||||
{
|
||||
/* Restore the character that was overwritten by the end 0 */
|
||||
net->buff[start_of_packet]=net->save_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* reuse buffer, as there is noting in it that we need */
|
||||
buf_length=start_of_packet=first_packet_offset=0;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
ulong packet_len;
|
||||
|
||||
if (buf_length - start_of_packet >= NET_HEADER_SIZE)
|
||||
{
|
||||
read_length = uint3korr(net->buff+start_of_packet);
|
||||
if (!read_length)
|
||||
{
|
||||
/* End of multi-byte packet */
|
||||
start_of_packet += NET_HEADER_SIZE;
|
||||
break;
|
||||
}
|
||||
if (read_length + NET_HEADER_SIZE <= buf_length - start_of_packet)
|
||||
{
|
||||
if (multi_byte_packet)
|
||||
{
|
||||
/* Remove packet header for second packet */
|
||||
memmove(net->buff + first_packet_offset + start_of_packet,
|
||||
net->buff + first_packet_offset + start_of_packet +
|
||||
NET_HEADER_SIZE,
|
||||
buf_length - start_of_packet);
|
||||
start_of_packet += read_length;
|
||||
buf_length -= NET_HEADER_SIZE;
|
||||
}
|
||||
else
|
||||
start_of_packet+= read_length + NET_HEADER_SIZE;
|
||||
|
||||
if (read_length != MAX_THREE_BYTES) /* last package */
|
||||
{
|
||||
multi_byte_packet= 0; /* No last zero len packet */
|
||||
break;
|
||||
}
|
||||
multi_byte_packet= NET_HEADER_SIZE;
|
||||
/* Move data down to read next data packet after current one */
|
||||
if (first_packet_offset)
|
||||
{
|
||||
memmove(net->buff,net->buff+first_packet_offset,
|
||||
buf_length-first_packet_offset);
|
||||
buf_length-=first_packet_offset;
|
||||
start_of_packet -= first_packet_offset;
|
||||
first_packet_offset=0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* Move data down to read next data packet after current one */
|
||||
if (first_packet_offset)
|
||||
{
|
||||
memmove(net->buff,net->buff+first_packet_offset,
|
||||
buf_length-first_packet_offset);
|
||||
buf_length-=first_packet_offset;
|
||||
start_of_packet -= first_packet_offset;
|
||||
first_packet_offset=0;
|
||||
}
|
||||
|
||||
net->where_b=buf_length;
|
||||
if ((packet_len = my_real_read(net,&complen)) == packet_error)
|
||||
return packet_error;
|
||||
if (my_uncompress((byte*) net->buff + net->where_b, &packet_len,
|
||||
&complen))
|
||||
{
|
||||
net->error=2; /* caller will close socket */
|
||||
#ifdef MYSQL_SERVER
|
||||
net->last_errno=ER_NET_UNCOMPRESS_ERROR;
|
||||
#endif
|
||||
return packet_error;
|
||||
}
|
||||
buf_length+=packet_len;
|
||||
}
|
||||
|
||||
net->read_pos= net->buff+ first_packet_offset + NET_HEADER_SIZE;
|
||||
net->buf_length= buf_length;
|
||||
net->remain_in_buf= (ulong) (buf_length - start_of_packet);
|
||||
len = ((ulong) (start_of_packet - first_packet_offset) - NET_HEADER_SIZE -
|
||||
multi_byte_packet);
|
||||
net->save_char= net->read_pos[len]; /* Must be saved */
|
||||
net->read_pos[len]=0; /* Safeguard for mysql_use_result */
|
||||
}
|
||||
#endif /* HAVE_COMPRESS */
|
||||
return len;
|
||||
}
|
||||
|
||||
int net_request_file(NET* net, const char* fname)
|
||||
{
|
||||
char tmp [FN_REFLEN+1],*end;
|
||||
DBUG_ENTER("net_request_file");
|
||||
tmp[0] = (char) 251; /* NULL_LENGTH */
|
||||
end=strnmov(tmp+1,fname,sizeof(tmp)-2);
|
||||
DBUG_RETURN(my_net_write(net,tmp,(uint) (end-tmp)) ||
|
||||
net_flush(net));
|
||||
}
|
@ -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 \
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -455,7 +455,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
|
||||
info->s->state.auto_increment=save_auto_value;
|
||||
|
||||
/* Check that there isn't a row with auto_increment = 0 in the table */
|
||||
mi_extra(info,HA_EXTRA_KEYREAD);
|
||||
mi_extra(info,HA_EXTRA_KEYREAD,0);
|
||||
bzero(info->lastkey,keyinfo->seg->length);
|
||||
if (!mi_rkey(info, info->rec_buff, key, (const byte*) info->lastkey,
|
||||
keyinfo->seg->length, HA_READ_KEY_EXACT))
|
||||
@ -466,7 +466,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
|
||||
"Found row where the auto_increment column has the value 0");
|
||||
param->warning_printed=save;
|
||||
}
|
||||
mi_extra(info,HA_EXTRA_NO_KEYREAD);
|
||||
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
|
||||
}
|
||||
|
||||
length=(my_off_t) isam_key_length(info,keyinfo)*keys + param->key_blocks*2;
|
||||
@ -1128,7 +1128,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
|
||||
param->testflag|=T_REP; /* for easy checking */
|
||||
|
||||
if (!param->using_global_keycache)
|
||||
VOID(init_key_cache(param->use_buffers,NEED_MEM));
|
||||
VOID(init_key_cache(param->use_buffers));
|
||||
|
||||
if (init_io_cache(¶m->read_cache,info->dfile,
|
||||
(uint) param->read_buffer_length,
|
||||
@ -3601,12 +3601,12 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
|
||||
!(param->testflag & T_REP))
|
||||
printf("Updating MyISAM file: %s\n", param->isam_file_name);
|
||||
/* We have to use keyread here as a normal read uses info->rec_buff */
|
||||
mi_extra(info,HA_EXTRA_KEYREAD);
|
||||
mi_extra(info,HA_EXTRA_KEYREAD,0);
|
||||
if (mi_rlast(info,info->rec_buff, info->s->base.auto_key-1))
|
||||
{
|
||||
if (my_errno != HA_ERR_END_OF_FILE)
|
||||
{
|
||||
mi_extra(info,HA_EXTRA_NO_KEYREAD);
|
||||
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
|
||||
mi_check_print_error(param,"%d when reading last record",my_errno);
|
||||
return;
|
||||
}
|
||||
@ -3621,7 +3621,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
|
||||
update_auto_increment(info,info->rec_buff);
|
||||
set_if_bigger(info->s->state.auto_increment,auto_increment);
|
||||
}
|
||||
mi_extra(info,HA_EXTRA_NO_KEYREAD);
|
||||
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
|
||||
update_state_info(param, info, UPDATE_AUTO_INC);
|
||||
return;
|
||||
}
|
||||
|
@ -14,11 +14,6 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/* Extra functions we want to do with a database */
|
||||
/* - Set flags for quicker databasehandler */
|
||||
/* - Set databasehandler to normal */
|
||||
/* - Reset recordpointers as after open database */
|
||||
|
||||
#include "myisamdef.h"
|
||||
#ifdef HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
@ -27,11 +22,28 @@
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* set extra flags for database */
|
||||
/*
|
||||
Set options and buffers to optimize table handling
|
||||
|
||||
int mi_extra(MI_INFO *info, enum ha_extra_function function)
|
||||
SYNOPSIS
|
||||
mi_extra()
|
||||
info open table
|
||||
function operation
|
||||
extra_arg Pointer to extra argument (normally pointer to ulong)
|
||||
Used when function is one of:
|
||||
HA_EXTRA_WRITE_CACHE
|
||||
HA_EXTRA_CACHE
|
||||
HA_EXTRA_BULK_INSERT_BEGIN
|
||||
If extra_arg is 0, then the default cache size is used.
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
*/
|
||||
|
||||
|
||||
int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
|
||||
{
|
||||
int error=0;
|
||||
ulong cache_size;
|
||||
MYISAM_SHARE *share=info->s;
|
||||
DBUG_ENTER("mi_extra");
|
||||
DBUG_PRINT("enter",("function: %d",(int) function));
|
||||
@ -103,11 +115,13 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function)
|
||||
if (!(info->opt_flag &
|
||||
(READ_CACHE_USED | WRITE_CACHE_USED | MEMMAP_USED)))
|
||||
{
|
||||
cache_size= (extra_arg ? *(ulong*) extra_arg :
|
||||
my_default_record_cache_size);
|
||||
if (!(init_io_cache(&info->rec_cache,info->dfile,
|
||||
(uint) min(info->state->data_file_length+1,
|
||||
my_default_record_cache_size),
|
||||
READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
|
||||
MYF(share->write_flag & MY_WAIT_IF_FULL))))
|
||||
cache_size),
|
||||
READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
|
||||
MYF(share->write_flag & MY_WAIT_IF_FULL))))
|
||||
{
|
||||
info->opt_flag|=READ_CACHE_USED;
|
||||
info->update&= ~HA_STATE_ROW_CHANGED;
|
||||
@ -133,10 +147,12 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function)
|
||||
error=1; /* Not possibly if not locked */
|
||||
break;
|
||||
}
|
||||
cache_size= (extra_arg ? *(ulong*) extra_arg :
|
||||
my_default_record_cache_size);
|
||||
if (!(info->opt_flag &
|
||||
(READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) &&
|
||||
!share->state.header.uniques)
|
||||
if (!(init_io_cache(&info->rec_cache,info->dfile,0,
|
||||
if (!(init_io_cache(&info->rec_cache,info->dfile, cache_size,
|
||||
WRITE_CACHE,info->state->data_file_length,
|
||||
(pbool) (info->lock_type != F_UNLCK),
|
||||
MYF(share->write_flag & MY_WAIT_IF_FULL))))
|
||||
@ -337,7 +353,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function)
|
||||
info->quick_mode=1;
|
||||
break;
|
||||
case HA_EXTRA_BULK_INSERT_BEGIN:
|
||||
error=_mi_init_bulk_insert(info);
|
||||
error=_mi_init_bulk_insert(info, (extra_arg ? *(ulong*) extra_arg :
|
||||
myisam_bulk_insert_tree_size));
|
||||
break;
|
||||
case HA_EXTRA_BULK_INSERT_END:
|
||||
if (info->bulk_insert)
|
||||
|
@ -66,7 +66,7 @@ static MI_INFO *test_if_reopen(char *filename)
|
||||
MI_INFO *mi_open(const char *name, int mode, uint open_flags)
|
||||
{
|
||||
int lock_error,kfile,open_mode,save_errno;
|
||||
uint i,j,len,errpos,head_length,base_pos,offset,info_length,extra,keys,
|
||||
uint i,j,len,errpos,head_length,base_pos,offset,info_length,keys,
|
||||
key_parts,unique_key_parts,tmp_length,uniques;
|
||||
char name_buff[FN_REFLEN], org_name [FN_REFLEN], index_name[FN_REFLEN],
|
||||
data_name[FN_REFLEN];
|
||||
|
@ -50,7 +50,7 @@ int main(int argc,char *argv[])
|
||||
MY_INIT(argv[0]);
|
||||
my_init();
|
||||
if (key_cacheing)
|
||||
init_key_cache(IO_SIZE*16,(uint) IO_SIZE*4*10);
|
||||
init_key_cache(IO_SIZE*16);
|
||||
get_options(argc,argv);
|
||||
|
||||
exit(run_test("test1"));
|
||||
|
@ -208,13 +208,13 @@ int main(int argc, char *argv[])
|
||||
if (!silent)
|
||||
printf("- Writing key:s\n");
|
||||
if (key_cacheing)
|
||||
init_key_cache(key_cache_size,(uint) IO_SIZE*4*10); /* Use a small cache */
|
||||
init_key_cache(key_cache_size); /* Use a small cache */
|
||||
if (locking)
|
||||
mi_lock_database(file,F_WRLCK);
|
||||
if (write_cacheing)
|
||||
mi_extra(file,HA_EXTRA_WRITE_CACHE);
|
||||
mi_extra(file,HA_EXTRA_WRITE_CACHE,0);
|
||||
if (opt_quick_mode)
|
||||
mi_extra(file,HA_EXTRA_QUICK);
|
||||
mi_extra(file,HA_EXTRA_QUICK,0);
|
||||
|
||||
for (i=0 ; i < recant ; i++)
|
||||
{
|
||||
@ -261,11 +261,15 @@ int main(int argc, char *argv[])
|
||||
if (testflag==1) goto end;
|
||||
|
||||
if (write_cacheing)
|
||||
if (mi_extra(file,HA_EXTRA_NO_CACHE))
|
||||
{
|
||||
if (mi_extra(file,HA_EXTRA_NO_CACHE,0))
|
||||
{
|
||||
puts("got error from mi_extra(HA_EXTRA_NO_CACHE)");
|
||||
goto end;
|
||||
}
|
||||
if (key_cacheing)
|
||||
resize_key_cache(key_cache_size*2);
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("- Delete\n");
|
||||
@ -677,7 +681,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!silent)
|
||||
printf("- mi_extra(CACHE) + mi_rrnd.... + mi_extra(NO_CACHE)\n");
|
||||
if (mi_extra(file,HA_EXTRA_RESET) || mi_extra(file,HA_EXTRA_CACHE))
|
||||
if (mi_extra(file,HA_EXTRA_RESET,0) || mi_extra(file,HA_EXTRA_CACHE,0))
|
||||
{
|
||||
if (locking || (!use_blob && !pack_fields))
|
||||
{
|
||||
@ -695,7 +699,7 @@ int main(int argc, char *argv[])
|
||||
ant,write_count-opt_delete);
|
||||
goto end;
|
||||
}
|
||||
if (mi_extra(file,HA_EXTRA_NO_CACHE))
|
||||
if (mi_extra(file,HA_EXTRA_NO_CACHE,0))
|
||||
{
|
||||
puts("got error from mi_extra(HA_EXTRA_NO_CACHE)");
|
||||
goto end;
|
||||
@ -720,7 +724,7 @@ int main(int argc, char *argv[])
|
||||
DBUG_PRINT("progpos",("Removing keys"));
|
||||
lastpos = HA_OFFSET_ERROR;
|
||||
/* DBUG_POP(); */
|
||||
mi_extra(file,HA_EXTRA_RESET);
|
||||
mi_extra(file,HA_EXTRA_RESET,0);
|
||||
found_parts=0;
|
||||
while ((error=mi_rrnd(file,read_record,HA_OFFSET_ERROR)) !=
|
||||
HA_ERR_END_OF_FILE)
|
||||
@ -791,8 +795,10 @@ end:
|
||||
printf("myisam_block_size: %u\n", myisam_block_size);
|
||||
if (key_cacheing)
|
||||
{
|
||||
puts("Key cacheing used");
|
||||
puts("Key cache used");
|
||||
printf("key_cache_block_size: %u\n", key_cache_block_size);
|
||||
if (write_cacheing)
|
||||
puts("Key cache resized");
|
||||
}
|
||||
if (write_cacheing)
|
||||
puts("Write cacheing used");
|
||||
|
@ -173,7 +173,7 @@ void start_test(int id)
|
||||
exit(1);
|
||||
}
|
||||
if (key_cacheing && rnd(2) == 0)
|
||||
init_key_cache(65536L,(uint) IO_SIZE*4*10);
|
||||
init_key_cache(65536L);
|
||||
printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout);
|
||||
|
||||
for (error=i=0 ; i < tests && !error; i++)
|
||||
@ -302,7 +302,7 @@ int test_rrnd(MI_INFO *file,int id)
|
||||
return 1;
|
||||
}
|
||||
if (rnd(2) == 0)
|
||||
mi_extra(file,HA_EXTRA_CACHE);
|
||||
mi_extra(file,HA_EXTRA_CACHE,0);
|
||||
}
|
||||
|
||||
count=0;
|
||||
@ -323,7 +323,7 @@ int test_rrnd(MI_INFO *file,int id)
|
||||
end:
|
||||
if (lock)
|
||||
{
|
||||
mi_extra(file,HA_EXTRA_NO_CACHE);
|
||||
mi_extra(file,HA_EXTRA_NO_CACHE,0);
|
||||
if (mi_lock_database(file,F_UNLCK))
|
||||
{
|
||||
fprintf(stderr,"%2d: Can't unlock table\n",id);
|
||||
@ -355,7 +355,7 @@ int test_write(MI_INFO *file,int id,int lock_type)
|
||||
return 1;
|
||||
}
|
||||
if (rnd(2) == 0)
|
||||
mi_extra(file,HA_EXTRA_WRITE_CACHE);
|
||||
mi_extra(file,HA_EXTRA_WRITE_CACHE,0);
|
||||
}
|
||||
|
||||
sprintf(record.id,"%7d",getpid());
|
||||
@ -380,7 +380,7 @@ int test_write(MI_INFO *file,int id,int lock_type)
|
||||
}
|
||||
if (lock)
|
||||
{
|
||||
mi_extra(file,HA_EXTRA_NO_CACHE);
|
||||
mi_extra(file,HA_EXTRA_NO_CACHE,0);
|
||||
if (mi_lock_database(file,F_UNLCK))
|
||||
{
|
||||
fprintf(stderr,"%2d: Can't unlock table\n",id);
|
||||
|
@ -801,7 +801,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
|
||||
}
|
||||
|
||||
|
||||
int _mi_init_bulk_insert(MI_INFO *info)
|
||||
int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
|
||||
{
|
||||
MYISAM_SHARE *share=info->s;
|
||||
MI_KEYDEF *key=share->keyinfo;
|
||||
@ -809,6 +809,7 @@ int _mi_init_bulk_insert(MI_INFO *info)
|
||||
uint i, num_keys;
|
||||
ulonglong key_map=0;
|
||||
DBUG_ENTER("_mi_init_bulk_insert");
|
||||
DBUG_PRINT("enter",("cache_size: %lu", cache_size));
|
||||
|
||||
if (info->bulk_insert)
|
||||
DBUG_RETURN(0);
|
||||
@ -824,7 +825,7 @@ int _mi_init_bulk_insert(MI_INFO *info)
|
||||
}
|
||||
|
||||
if (num_keys==0 ||
|
||||
num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > myisam_bulk_insert_tree_size)
|
||||
num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > cache_size)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
info->bulk_insert=(TREE *)
|
||||
@ -842,8 +843,8 @@ int _mi_init_bulk_insert(MI_INFO *info)
|
||||
params->info=info;
|
||||
params->keynr=i;
|
||||
init_tree(&info->bulk_insert[i],
|
||||
myisam_bulk_insert_tree_size / num_keys / 4 + 10,
|
||||
myisam_bulk_insert_tree_size / num_keys, 0,
|
||||
cache_size / num_keys / 4 + 10,
|
||||
cache_size / num_keys, 0,
|
||||
(qsort_cmp2)keys_compare, 0,
|
||||
(tree_element_free) keys_free, (void *)params++);
|
||||
}
|
||||
|
@ -1003,7 +1003,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
|
||||
!(param->testflag & (T_FAST | T_FORCE_CREATE)))
|
||||
{
|
||||
if (param->testflag & (T_EXTEND | T_MEDIUM))
|
||||
VOID(init_key_cache(param->use_buffers,(uint) NEED_MEM));
|
||||
VOID(init_key_cache(param->use_buffers));
|
||||
VOID(init_io_cache(¶m->read_cache,datafile,
|
||||
(uint) param->read_buffer_length,
|
||||
READ_CACHE,
|
||||
@ -1413,7 +1413,7 @@ static int mi_sort_records(MI_CHECK *param,
|
||||
if (share->state.key_root[sort_key] == HA_OFFSET_ERROR)
|
||||
DBUG_RETURN(0); /* Nothing to do */
|
||||
|
||||
init_key_cache(param->use_buffers,NEED_MEM);
|
||||
init_key_cache(param->use_buffers);
|
||||
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
|
||||
WRITE_CACHE,share->pack.header_length,1,
|
||||
MYF(MY_WME | MY_WAIT_IF_FULL)))
|
||||
|
@ -656,7 +656,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup);
|
||||
int mi_open_keyfile(MYISAM_SHARE *share);
|
||||
void mi_setup_functions(register MYISAM_SHARE *share);
|
||||
|
||||
int _mi_init_bulk_insert(MI_INFO *info);
|
||||
int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size);
|
||||
|
||||
/* Functions needed by mi_check */
|
||||
void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...));
|
||||
|
@ -333,7 +333,7 @@ static int examine_log(my_string file_name, char **table_names)
|
||||
bzero((gptr) com_count,sizeof(com_count));
|
||||
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1,
|
||||
(tree_element_free) file_info_free, NULL);
|
||||
VOID(init_key_cache(KEY_CACHE_SIZE,(uint) (10*4*(IO_SIZE+MALLOC_OVERHEAD))));
|
||||
VOID(init_key_cache(KEY_CACHE_SIZE));
|
||||
|
||||
files_open=0; access_time=0;
|
||||
while (access_time++ != number_of_commands &&
|
||||
@ -484,7 +484,7 @@ static int examine_log(my_string file_name, char **table_names)
|
||||
command_name[command], (int) extra_command,result);
|
||||
if (update && curr_file_info && !curr_file_info->closed)
|
||||
{
|
||||
if (mi_extra(curr_file_info->isam, extra_command) != (int) result)
|
||||
if (mi_extra(curr_file_info->isam, extra_command, 0) != (int) result)
|
||||
{
|
||||
fflush(stdout);
|
||||
VOID(fprintf(stderr,
|
||||
|
@ -2088,7 +2088,7 @@ static void mrg_reset(PACK_MRG_INFO *mrg)
|
||||
{
|
||||
if (mrg->current)
|
||||
{
|
||||
mi_extra(*mrg->current,HA_EXTRA_NO_CACHE);
|
||||
mi_extra(*mrg->current, HA_EXTRA_NO_CACHE, 0);
|
||||
mrg->current=0;
|
||||
}
|
||||
}
|
||||
@ -2103,8 +2103,8 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
|
||||
{
|
||||
isam_info= *(info->current=info->file);
|
||||
info->end=info->current+info->count;
|
||||
mi_extra(isam_info,HA_EXTRA_RESET);
|
||||
mi_extra(isam_info,HA_EXTRA_CACHE);
|
||||
mi_extra(isam_info, HA_EXTRA_RESET, 0);
|
||||
mi_extra(isam_info, HA_EXTRA_CACHE, 0);
|
||||
filepos=isam_info->s->pack.header_length;
|
||||
}
|
||||
else
|
||||
@ -2120,14 +2120,14 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
|
||||
filepos, 1)) ||
|
||||
error != HA_ERR_END_OF_FILE)
|
||||
return (error);
|
||||
mi_extra(isam_info,HA_EXTRA_NO_CACHE);
|
||||
mi_extra(isam_info,HA_EXTRA_NO_CACHE, 0);
|
||||
if (info->current+1 == info->end)
|
||||
return(HA_ERR_END_OF_FILE);
|
||||
info->current++;
|
||||
isam_info= *info->current;
|
||||
filepos=isam_info->s->pack.header_length;
|
||||
mi_extra(isam_info,HA_EXTRA_RESET);
|
||||
mi_extra(isam_info,HA_EXTRA_CACHE);
|
||||
mi_extra(isam_info,HA_EXTRA_RESET, 0);
|
||||
mi_extra(isam_info,HA_EXTRA_CACHE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,8 @@
|
||||
|
||||
#include "myrg_def.h"
|
||||
|
||||
int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
|
||||
int myrg_extra(MYRG_INFO *info,enum ha_extra_function function,
|
||||
void *extra_arg)
|
||||
{
|
||||
int error,save_error=0;
|
||||
MYRG_TABLE *file;
|
||||
@ -30,7 +31,11 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
|
||||
DBUG_PRINT("info",("function: %d",(ulong) function));
|
||||
|
||||
if (function == HA_EXTRA_CACHE)
|
||||
{
|
||||
info->cache_in_use=1;
|
||||
info->cache_size= (extra_arg ? *(long*) extra_arg :
|
||||
my_default_record_cache_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET)
|
||||
@ -41,12 +46,15 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
|
||||
info->last_used_table=info->open_tables;
|
||||
}
|
||||
for (file=info->open_tables ; file != info->end_table ; file++)
|
||||
if ((error=mi_extra(file->table,function)))
|
||||
{
|
||||
if ((error=mi_extra(file->table, function, extra_arg)))
|
||||
save_error=error;
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(save_error);
|
||||
}
|
||||
|
||||
|
||||
void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
|
||||
{
|
||||
MYRG_TABLE *file;
|
||||
|
@ -48,7 +48,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
|
||||
}
|
||||
isam_info=(info->current_table=info->open_tables)->table;
|
||||
if (info->cache_in_use)
|
||||
mi_extra(isam_info,HA_EXTRA_CACHE);
|
||||
mi_extra(isam_info,HA_EXTRA_CACHE,(byte*) &info->cache_size);
|
||||
filepos=isam_info->s->pack.header_length;
|
||||
isam_info->lastinx= (uint) -1; /* Can't forward or backward */
|
||||
}
|
||||
@ -66,13 +66,15 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
|
||||
HA_ERR_END_OF_FILE)
|
||||
DBUG_RETURN(error);
|
||||
if (info->cache_in_use)
|
||||
mi_extra(info->current_table->table,HA_EXTRA_NO_CACHE);
|
||||
mi_extra(info->current_table->table, HA_EXTRA_NO_CACHE,
|
||||
(byte*) &info->cache_size);
|
||||
if (info->current_table+1 == info->end_table)
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
info->current_table++;
|
||||
info->last_used_table=info->current_table;
|
||||
if (info->cache_in_use)
|
||||
mi_extra(info->current_table->table,HA_EXTRA_CACHE);
|
||||
mi_extra(info->current_table->table, HA_EXTRA_CACHE,
|
||||
(byte*) &info->cache_size);
|
||||
info->current_table->file_offset=
|
||||
info->current_table[-1].file_offset+
|
||||
info->current_table[-1].table->state->data_file_length;
|
||||
|
@ -61,7 +61,7 @@ SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM crash2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
show variables like '%bulk%';
|
||||
Variable_name Value
|
||||
myisam_bulk_insert_tree_size 8388608
|
||||
bulk_insert_buffer_size 8388608
|
||||
INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM crash2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
|
@ -147,3 +147,34 @@ t1 0 e 1 e A 0 NULL NULL BTREE
|
||||
t1 0 b 1 b A NULL NULL NULL YES BTREE
|
||||
t1 1 c 1 c A NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
|
||||
UNIQUE (c,i));
|
||||
INSERT INTO t1 (c) VALUES (NULL),(NULL);
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
1
|
||||
2
|
||||
INSERT INTO t1 (c) VALUES ('a'),('a');
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
1
|
||||
2
|
||||
a 1
|
||||
a 2
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c CHAR(10) NULL, i INT NOT NULL AUTO_INCREMENT,
|
||||
UNIQUE (c,i));
|
||||
INSERT INTO t1 (c) VALUES (NULL),(NULL);
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
NULL 1
|
||||
NULL 2
|
||||
INSERT INTO t1 (c) VALUES ('a'),('a');
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
NULL 1
|
||||
NULL 2
|
||||
a 1
|
||||
a 2
|
||||
drop table t1;
|
||||
|
@ -226,7 +226,7 @@ show status like "Qcache_free_blocks";
|
||||
Variable_name Value
|
||||
Qcache_free_blocks 1
|
||||
drop table t1, t2, t3, t11, t21;
|
||||
set sql_query_cache_type=demand;
|
||||
set query_cache_type=demand;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
@ -242,7 +242,7 @@ a
|
||||
1
|
||||
2
|
||||
3
|
||||
set sql_query_cache_type=2;
|
||||
set query_cache_type=2;
|
||||
select sql_cache * from t1;
|
||||
a
|
||||
1
|
||||
@ -254,7 +254,7 @@ Qcache_hits 4
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
set sql_query_cache_type=on;
|
||||
set query_cache_type=on;
|
||||
reset query cache;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
|
@ -67,7 +67,7 @@ select (@id := id) - id from t2;
|
||||
kill @id;
|
||||
drop table t2;
|
||||
Server shutdown in progress
|
||||
set sql_slave_skip_counter=1;
|
||||
set global sql_slave_skip_counter=1;
|
||||
slave start;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
|
@ -33,7 +33,7 @@ master-bin.003
|
||||
insert into t2 values(1234);
|
||||
set insert_id=1234;
|
||||
insert into t2 values(NULL);
|
||||
set sql_slave_skip_counter=1;
|
||||
set global sql_slave_skip_counter=1;
|
||||
slave start;
|
||||
purge master logs to 'master-bin.003';
|
||||
show master logs;
|
||||
|
@ -194,9 +194,9 @@ a
|
||||
1
|
||||
2
|
||||
set SQL_SELECT_LIMIT=2;
|
||||
(select * from t1 limit 2) union (select * from t2 limit 3);
|
||||
(select * from t1 limit 1) union (select * from t2 limit 3);
|
||||
a
|
||||
1
|
||||
2
|
||||
11
|
||||
set SQL_SELECT_LIMIT=DEFAULT;
|
||||
drop table t1,t2;
|
||||
|
@ -1,5 +1,5 @@
|
||||
set @a := foo;
|
||||
You may only use constant expressions with SET
|
||||
Unknown column 'foo' in 'field list'
|
||||
set @a := connection_id() + 3;
|
||||
select @a - connection_id();
|
||||
@a - connection_id()
|
||||
|
@ -44,17 +44,277 @@ c_id c_name c_country
|
||||
1 Bozo USA
|
||||
4 Mr. Floppy GB
|
||||
drop table t1;
|
||||
set max_join_size=100;
|
||||
show variables like 'max_join_size';
|
||||
Variable_name Value
|
||||
max_join_size 100
|
||||
show global variables like 'max_join_size';
|
||||
Variable_name Value
|
||||
max_join_size 4294967295
|
||||
set GLOBAL max_join_size=2000;
|
||||
show global variables like 'max_join_size';
|
||||
Variable_name Value
|
||||
max_join_size 2000
|
||||
set max_join_size=DEFAULT;
|
||||
show variables like 'max_join_size';
|
||||
Variable_name Value
|
||||
max_join_size 2000
|
||||
set GLOBAL max_join_size=DEFAULT;
|
||||
show global variables like 'max_join_size';
|
||||
Variable_name Value
|
||||
max_join_size 4294967295
|
||||
set @@max_join_size=1000, @@global.max_join_size=2000;
|
||||
select @@local.max_join_size, @@global.max_join_size;
|
||||
@@max_join_size @@max_join_size
|
||||
1000 2000
|
||||
select @@identity, length(@@version)>0;
|
||||
@@identity length(@@version)>0
|
||||
0 1
|
||||
select @@VERSION=version();
|
||||
@@VERSION=version()
|
||||
1
|
||||
select last_insert_id(345);
|
||||
last_insert_id(345)
|
||||
345
|
||||
select @@IDENTITY,last_insert_id();
|
||||
@@IDENTITY last_insert_id()
|
||||
345 345
|
||||
select @@identity;
|
||||
@@IDENTITY
|
||||
345
|
||||
select @@unknown_variable;
|
||||
select @@IDENTITY,last_insert_id(), @@identity;
|
||||
@@identity last_insert_id() @@identity
|
||||
345 345 345
|
||||
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
|
||||
set global concurrent_insert=ON;
|
||||
show variables like 'concurrent_insert';
|
||||
Variable_name Value
|
||||
concurrent_insert ON
|
||||
set global concurrent_insert=1;
|
||||
show variables like 'concurrent_insert';
|
||||
Variable_name Value
|
||||
concurrent_insert ON
|
||||
set global concurrent_insert=0;
|
||||
show variables like 'concurrent_insert';
|
||||
Variable_name Value
|
||||
concurrent_insert OFF
|
||||
set global concurrent_insert=OFF;
|
||||
show variables like 'concurrent_insert';
|
||||
Variable_name Value
|
||||
concurrent_insert OFF
|
||||
set global concurrent_insert=DEFAULT;
|
||||
show variables like 'concurrent_insert';
|
||||
Variable_name Value
|
||||
concurrent_insert ON
|
||||
set table_type=MYISAM, table_type="HEAP", global table_type="INNODB";
|
||||
show local variables like 'table_type';
|
||||
Variable_name Value
|
||||
table_type HEAP
|
||||
show global variables like 'table_type';
|
||||
Variable_name Value
|
||||
table_type INNODB
|
||||
set GLOBAL query_cache_size=100000;
|
||||
set GLOBAL safe_show_database=0;
|
||||
set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000;
|
||||
show variables like 'myisam_max_sort_file_size';
|
||||
Variable_name Value
|
||||
myisam_max_sort_file_size 10000
|
||||
show global variables like 'myisam_max_sort_file_size';
|
||||
Variable_name Value
|
||||
myisam_max_sort_file_size 20000
|
||||
set myisam_max_sort_file_size=default;
|
||||
show variables like 'myisam_max_sort_file_size';
|
||||
Variable_name Value
|
||||
myisam_max_sort_file_size 20000
|
||||
set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300;
|
||||
set session net_buffer_length=2048, net_write_timeout=500, net_read_timeout=600;
|
||||
show global variables like 'net_%';
|
||||
Variable_name Value
|
||||
net_buffer_length 1024
|
||||
net_read_timeout 300
|
||||
net_retry_count 10
|
||||
net_write_timeout 200
|
||||
show session variables like 'net_%';
|
||||
Variable_name Value
|
||||
net_buffer_length 2048
|
||||
net_read_timeout 600
|
||||
net_retry_count 10
|
||||
net_write_timeout 500
|
||||
set session net_buffer_length=8000, global net_read_timeout=900, net_write_timeout=1000;
|
||||
show global variables like 'net_%';
|
||||
Variable_name Value
|
||||
net_buffer_length 1024
|
||||
net_read_timeout 900
|
||||
net_retry_count 10
|
||||
net_write_timeout 1000
|
||||
show session variables like 'net_%';
|
||||
Variable_name Value
|
||||
net_buffer_length 7168
|
||||
net_read_timeout 600
|
||||
net_retry_count 10
|
||||
net_write_timeout 500
|
||||
set net_buffer_length=1;
|
||||
show variables like 'net_buffer_length';
|
||||
Variable_name Value
|
||||
net_buffer_length 1024
|
||||
set net_buffer_length=2000000000;
|
||||
show variables like 'net_buffer_length';
|
||||
Variable_name Value
|
||||
net_buffer_length 1048576
|
||||
set GLOBAL character set cp1251_koi8;
|
||||
show global variables like "convert_character_set";
|
||||
Variable_name Value
|
||||
convert_character_set cp1251_koi8
|
||||
set character set cp1251_koi8;
|
||||
show variables like "convert_character_set";
|
||||
Variable_name Value
|
||||
convert_character_set cp1251_koi8
|
||||
set global character set default, session character set default;
|
||||
show variables like "convert_character_set";
|
||||
Variable_name Value
|
||||
convert_character_set cp1251_koi8
|
||||
select @@timestamp>0;
|
||||
@@timestamp>0
|
||||
1
|
||||
set big_tables=OFFF;
|
||||
Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
set big_tables="OFFF";
|
||||
Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
set unknown_variable=1;
|
||||
Unknown system variable 'unknown_variable'
|
||||
set max_join_size="hello";
|
||||
Wrong argument type to variable 'max_join_size'
|
||||
set table_type=UNKNOWN_TABLE_TYPE;
|
||||
Variable 'table_type' can't be set to the value of 'UNKNOWN_TABLE_TYPE'
|
||||
set table_type=INNODB, big_tables=2;
|
||||
Variable 'big_tables' can't be set to the value of '2'
|
||||
show local variables like 'table_type';
|
||||
Variable_name Value
|
||||
table_type HEAP
|
||||
set SESSION query_cache_size=10000;
|
||||
Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set GLOBAL table_type=DEFAULT;
|
||||
Variable 'table_type' doesn't have a default value
|
||||
set convert_character_set=UNKNOWN_CHARACTER_SET;
|
||||
Unknown character set: 'UNKNOWN_CHARACTER_SET'
|
||||
set character set unknown;
|
||||
Unknown character set: 'unknown'
|
||||
set character set 0;
|
||||
Wrong argument type to variable 'convert_character_set'
|
||||
set global autocommit=1;
|
||||
Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
select @@global.timestamp;
|
||||
Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
set @@version='';
|
||||
Unknown system variable 'version'
|
||||
set @@concurrent_insert=1;
|
||||
Variable 'concurrent_insert' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set @@global.sql_auto_is_null=1;
|
||||
Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
select @@global.sql_auto_is_null;
|
||||
Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
set autocommit=1;
|
||||
set big_tables=1;
|
||||
select @@autocommit, @@big_tables;
|
||||
@@autocommit @@big_tables
|
||||
1 1
|
||||
set global binlog_cache_size=100;
|
||||
set bulk_insert_buffer_size=100;
|
||||
set convert_character_set=cp1251_koi8;
|
||||
set convert_character_set=default;
|
||||
set @@global.concurrent_insert=1;
|
||||
set global connect_timeout=100;
|
||||
set global delay_key_write=1;
|
||||
set global delayed_insert_limit=100;
|
||||
set global delayed_insert_timeout=100;
|
||||
set global delayed_queue_size=100;
|
||||
set global flush=1;
|
||||
set global flush_time=100;
|
||||
set insert_id=1;
|
||||
set interactive_timeout=100;
|
||||
set join_buffer_size=100;
|
||||
set last_insert_id=1;
|
||||
set global local_infile=1;
|
||||
set long_query_time=100;
|
||||
set low_priority_updates=1;
|
||||
set max_allowed_packet=100;
|
||||
set global max_binlog_cache_size=100;
|
||||
set global max_binlog_size=100;
|
||||
set global max_connect_errors=100;
|
||||
set global max_connections=100;
|
||||
set global max_delayed_threads=100;
|
||||
set max_heap_table_size=100;
|
||||
set max_join_size=100;
|
||||
set max_sort_length=100;
|
||||
set max_tmp_tables=100;
|
||||
set global max_user_connections=100;
|
||||
select @@max_user_connections;
|
||||
@@max_user_connections
|
||||
100
|
||||
set global max_write_lock_count=100;
|
||||
set myisam_max_extra_sort_file_size=100;
|
||||
select @@myisam_max_extra_sort_file_size;
|
||||
@@myisam_max_extra_sort_file_size
|
||||
100
|
||||
set myisam_max_sort_file_size=100;
|
||||
set myisam_sort_buffer_size=100;
|
||||
set net_buffer_length=100;
|
||||
set net_read_timeout=100;
|
||||
set net_write_timeout=100;
|
||||
set global query_cache_limit=100;
|
||||
set global query_cache_size=100;
|
||||
set global query_cache_type=demand;
|
||||
set read_buffer_size=100;
|
||||
set read_rnd_buffer_size=100;
|
||||
set global rpl_recovery_rank=100;
|
||||
set global safe_show_database=1;
|
||||
set global server_id=100;
|
||||
set global slave_net_timeout=100;
|
||||
set global slow_launch_time=100;
|
||||
set sort_buffer_size=100;
|
||||
set sql_auto_is_null=1;
|
||||
select @@sql_auto_is_null;
|
||||
@@sql_auto_is_null
|
||||
1
|
||||
set @@sql_auto_is_null=0;
|
||||
select @@sql_auto_is_null;
|
||||
@@sql_auto_is_null
|
||||
0
|
||||
set sql_big_selects=1;
|
||||
set sql_big_tables=1;
|
||||
set sql_buffer_result=1;
|
||||
set sql_log_bin=1;
|
||||
set sql_log_off=1;
|
||||
set sql_log_update=1;
|
||||
set sql_low_priority_updates=1;
|
||||
set sql_max_join_size=200;
|
||||
select @@sql_max_join_size,@@max_join_size;
|
||||
@@sql_max_join_size @@max_join_size
|
||||
200 200
|
||||
set sql_quote_show_create=1;
|
||||
set sql_safe_updates=1;
|
||||
set sql_select_limit=1;
|
||||
set global sql_slave_skip_counter=100;
|
||||
set sql_warnings=1;
|
||||
set global table_cache=100;
|
||||
set table_type=myisam;
|
||||
set global thread_cache_size=100;
|
||||
set timestamp=1, timestamp=default;
|
||||
set tmp_table_size=100;
|
||||
set tx_isolation="READ-COMMITTED";
|
||||
set wait_timeout=100;
|
||||
set log_warnings=1;
|
||||
DROP TABLE IF EXISTS t1,t2;
|
||||
create table t1 (a int not null auto_increment, primary key(a));
|
||||
create table t2 (a int not null auto_increment, primary key(a));
|
||||
insert into t1 values(null),(null),(null);
|
||||
insert into t2 values(null),(null),(null);
|
||||
set global key_buffer_size=100000;
|
||||
select @@key_buffer_size;
|
||||
@@key_buffer_size
|
||||
98304
|
||||
select * from t1 where a=2;
|
||||
a
|
||||
2
|
||||
select * from t2 where a=3;
|
||||
a
|
||||
3
|
||||
check table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
test.t2 check status OK
|
||||
drop table t1,t2;
|
||||
|
@ -168,3 +168,23 @@ drop table t1;
|
||||
create table t1 (a int not null unique, b int unique, c int, d int not null primary key, key(c), e int not null unique);
|
||||
show keys from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Problem with UNIQUE() with NULL parts and auto increment
|
||||
#
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
|
||||
UNIQUE (c,i));
|
||||
INSERT INTO t1 (c) VALUES (NULL),(NULL);
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 (c) VALUES ('a'),('a');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c CHAR(10) NULL, i INT NOT NULL AUTO_INCREMENT,
|
||||
UNIQUE (c,i));
|
||||
INSERT INTO t1 (c) VALUES (NULL),(NULL);
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 (c) VALUES ('a'),('a');
|
||||
SELECT * FROM t1;
|
||||
drop table t1;
|
||||
|
@ -139,17 +139,17 @@ drop table t1, t2, t3, t11, t21;
|
||||
#
|
||||
# SELECT SQL_CACHE ...
|
||||
#
|
||||
set sql_query_cache_type=demand;
|
||||
set query_cache_type=demand;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
select sql_cache * from t1;
|
||||
set sql_query_cache_type=2;
|
||||
set query_cache_type=2;
|
||||
select sql_cache * from t1;
|
||||
show status like "Qcache_hits";
|
||||
show status like "Qcache_queries_in_cache";
|
||||
set sql_query_cache_type=on;
|
||||
set query_cache_type=on;
|
||||
#
|
||||
# RESET QUERY CACHE
|
||||
#
|
||||
|
@ -85,7 +85,7 @@ wait_for_slave_to_stop;
|
||||
# --replace_result 9306 9999 3334 9999 3335 9999
|
||||
# show slave status;
|
||||
|
||||
set sql_slave_skip_counter=1;
|
||||
set global sql_slave_skip_counter=1;
|
||||
slave start;
|
||||
select count(*) from t1;
|
||||
connection master1;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#this one assumes we are ignoring updates on tables in database foo, but doing
|
||||
#the ones in database bar
|
||||
# This one assumes we are ignoring updates on tables in database foo, but doing
|
||||
# the ones in database bar
|
||||
|
||||
source include/master-slave.inc;
|
||||
connection master;
|
||||
drop database if exists foo;
|
||||
@ -32,9 +33,10 @@ sync_with_master;
|
||||
drop database if exists bar;
|
||||
drop database if exists foo;
|
||||
|
||||
#now let's test load data from master
|
||||
# Now let's test load data from master
|
||||
|
||||
# First create some databases and tables on the master
|
||||
|
||||
#first create some databases and tables on the master
|
||||
connection master;
|
||||
set sql_log_bin = 0;
|
||||
create database foo;
|
||||
@ -55,11 +57,11 @@ save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
|
||||
#this should show that the slave is empty at this point
|
||||
# This should show that the slave is empty at this point
|
||||
show databases;
|
||||
load data from master;
|
||||
|
||||
#now let's check if we have the right tables and the right data in them
|
||||
# Now let's check if we have the right tables and the right data in them
|
||||
show databases;
|
||||
use foo;
|
||||
show tables;
|
||||
@ -68,7 +70,7 @@ show tables;
|
||||
select * from bar.t1;
|
||||
select * from bar.t2;
|
||||
|
||||
#now let's see if replication works
|
||||
# Now let's see if replication works
|
||||
connection master;
|
||||
insert into bar.t1 values (4, 'four bar');
|
||||
save_master_pos;
|
||||
@ -76,7 +78,7 @@ connection slave;
|
||||
sync_with_master;
|
||||
select * from bar.t1;
|
||||
|
||||
#now time for cleanup
|
||||
# Now time for cleanup
|
||||
connection master;
|
||||
drop database bar;
|
||||
drop database foo;
|
||||
|
@ -54,7 +54,7 @@ sync_with_master;
|
||||
wait_for_slave_to_stop;
|
||||
|
||||
#restart slave skipping one event
|
||||
set sql_slave_skip_counter=1;
|
||||
set global sql_slave_skip_counter=1;
|
||||
slave start;
|
||||
|
||||
connection master;
|
||||
|
@ -58,7 +58,7 @@ sync_with_master ;
|
||||
#now slave will hit an error
|
||||
wait_for_slave_to_stop;
|
||||
|
||||
set sql_slave_skip_counter=1;
|
||||
set global sql_slave_skip_counter=1;
|
||||
slave start;
|
||||
select count(*) from t1;
|
||||
connection master1;
|
||||
|
@ -88,6 +88,6 @@ insert into t2 values (11),(12),(13),(14),(15);
|
||||
(select * from t1 limit 2) union (select * from t2 limit 3);
|
||||
(select * from t1 limit 2) union (select * from t2 limit 20,3);
|
||||
set SQL_SELECT_LIMIT=2;
|
||||
(select * from t1 limit 2) union (select * from t2 limit 3);
|
||||
(select * from t1 limit 1) union (select * from t2 limit 3);
|
||||
set SQL_SELECT_LIMIT=DEFAULT;
|
||||
drop table t1,t2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
error 1204;
|
||||
error 1054;
|
||||
set @a := foo;
|
||||
set @a := connection_id() + 3;
|
||||
select @a - connection_id();
|
||||
|
1
mysql-test/t/variables-master.opt
Normal file
1
mysql-test/t/variables-master.opt
Normal file
@ -0,0 +1 @@
|
||||
max_join_size=10
|
@ -32,9 +32,200 @@ drop table t1;
|
||||
# Test system variables
|
||||
#
|
||||
|
||||
set max_join_size=100;
|
||||
show variables like 'max_join_size';
|
||||
show global variables like 'max_join_size';
|
||||
set GLOBAL max_join_size=2000;
|
||||
show global variables like 'max_join_size';
|
||||
set max_join_size=DEFAULT;
|
||||
show variables like 'max_join_size';
|
||||
set GLOBAL max_join_size=DEFAULT;
|
||||
show global variables like 'max_join_size';
|
||||
set @@max_join_size=1000, @@global.max_join_size=2000;
|
||||
select @@local.max_join_size, @@global.max_join_size;
|
||||
select @@identity, length(@@version)>0;
|
||||
select @@VERSION=version();
|
||||
select last_insert_id(345);
|
||||
select @@IDENTITY,last_insert_id();
|
||||
select @@identity;
|
||||
select @@IDENTITY,last_insert_id(), @@identity;
|
||||
|
||||
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
|
||||
|
||||
set global concurrent_insert=ON;
|
||||
show variables like 'concurrent_insert';
|
||||
set global concurrent_insert=1;
|
||||
show variables like 'concurrent_insert';
|
||||
set global concurrent_insert=0;
|
||||
show variables like 'concurrent_insert';
|
||||
set global concurrent_insert=OFF;
|
||||
show variables like 'concurrent_insert';
|
||||
set global concurrent_insert=DEFAULT;
|
||||
show variables like 'concurrent_insert';
|
||||
|
||||
set table_type=MYISAM, table_type="HEAP", global table_type="INNODB";
|
||||
show local variables like 'table_type';
|
||||
show global variables like 'table_type';
|
||||
set GLOBAL query_cache_size=100000;
|
||||
set GLOBAL safe_show_database=0;
|
||||
|
||||
set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000;
|
||||
show variables like 'myisam_max_sort_file_size';
|
||||
show global variables like 'myisam_max_sort_file_size';
|
||||
set myisam_max_sort_file_size=default;
|
||||
show variables like 'myisam_max_sort_file_size';
|
||||
|
||||
set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300;
|
||||
set session net_buffer_length=2048, net_write_timeout=500, net_read_timeout=600;
|
||||
show global variables like 'net_%';
|
||||
show session variables like 'net_%';
|
||||
set session net_buffer_length=8000, global net_read_timeout=900, net_write_timeout=1000;
|
||||
show global variables like 'net_%';
|
||||
show session variables like 'net_%';
|
||||
set net_buffer_length=1;
|
||||
show variables like 'net_buffer_length';
|
||||
set net_buffer_length=2000000000;
|
||||
show variables like 'net_buffer_length';
|
||||
|
||||
set GLOBAL character set cp1251_koi8;
|
||||
show global variables like "convert_character_set";
|
||||
set character set cp1251_koi8;
|
||||
show variables like "convert_character_set";
|
||||
set global character set default, session character set default;
|
||||
show variables like "convert_character_set";
|
||||
select @@timestamp>0;
|
||||
|
||||
# The following should give errors
|
||||
|
||||
--error 1231
|
||||
set big_tables=OFFF;
|
||||
--error 1231
|
||||
set big_tables="OFFF";
|
||||
--error 1193
|
||||
select @@unknown_variable;
|
||||
set unknown_variable=1;
|
||||
--error 1232
|
||||
set max_join_size="hello";
|
||||
--error 1231
|
||||
set table_type=UNKNOWN_TABLE_TYPE;
|
||||
--error 1231
|
||||
set table_type=INNODB, big_tables=2;
|
||||
show local variables like 'table_type';
|
||||
--error 1229
|
||||
set SESSION query_cache_size=10000;
|
||||
--error 1230
|
||||
set GLOBAL table_type=DEFAULT;
|
||||
--error 1115
|
||||
set convert_character_set=UNKNOWN_CHARACTER_SET;
|
||||
--error 1115
|
||||
set character set unknown;
|
||||
--error 1232
|
||||
set character set 0;
|
||||
--error 1228
|
||||
set global autocommit=1;
|
||||
--error 1228
|
||||
select @@global.timestamp;
|
||||
--error 1193
|
||||
set @@version='';
|
||||
--error 1229
|
||||
set @@concurrent_insert=1;
|
||||
--error 1228
|
||||
set @@global.sql_auto_is_null=1;
|
||||
--error 1228
|
||||
select @@global.sql_auto_is_null;
|
||||
|
||||
# Test setting all variables
|
||||
|
||||
set autocommit=1;
|
||||
set big_tables=1;
|
||||
select @@autocommit, @@big_tables;
|
||||
set global binlog_cache_size=100;
|
||||
set bulk_insert_buffer_size=100;
|
||||
set convert_character_set=cp1251_koi8;
|
||||
set convert_character_set=default;
|
||||
set @@global.concurrent_insert=1;
|
||||
set global connect_timeout=100;
|
||||
set global delay_key_write=1;
|
||||
set global delayed_insert_limit=100;
|
||||
set global delayed_insert_timeout=100;
|
||||
set global delayed_queue_size=100;
|
||||
set global flush=1;
|
||||
set global flush_time=100;
|
||||
set insert_id=1;
|
||||
set interactive_timeout=100;
|
||||
set join_buffer_size=100;
|
||||
set last_insert_id=1;
|
||||
set global local_infile=1;
|
||||
set long_query_time=100;
|
||||
set low_priority_updates=1;
|
||||
set max_allowed_packet=100;
|
||||
set global max_binlog_cache_size=100;
|
||||
set global max_binlog_size=100;
|
||||
set global max_connect_errors=100;
|
||||
set global max_connections=100;
|
||||
set global max_delayed_threads=100;
|
||||
set max_heap_table_size=100;
|
||||
set max_join_size=100;
|
||||
set max_sort_length=100;
|
||||
set max_tmp_tables=100;
|
||||
set global max_user_connections=100;
|
||||
select @@max_user_connections;
|
||||
set global max_write_lock_count=100;
|
||||
set myisam_max_extra_sort_file_size=100;
|
||||
select @@myisam_max_extra_sort_file_size;
|
||||
set myisam_max_sort_file_size=100;
|
||||
set myisam_sort_buffer_size=100;
|
||||
set net_buffer_length=100;
|
||||
set net_read_timeout=100;
|
||||
set net_write_timeout=100;
|
||||
set global query_cache_limit=100;
|
||||
set global query_cache_size=100;
|
||||
set global query_cache_type=demand;
|
||||
set read_buffer_size=100;
|
||||
set read_rnd_buffer_size=100;
|
||||
set global rpl_recovery_rank=100;
|
||||
set global safe_show_database=1;
|
||||
set global server_id=100;
|
||||
set global slave_net_timeout=100;
|
||||
set global slow_launch_time=100;
|
||||
set sort_buffer_size=100;
|
||||
set sql_auto_is_null=1;
|
||||
select @@sql_auto_is_null;
|
||||
set @@sql_auto_is_null=0;
|
||||
select @@sql_auto_is_null;
|
||||
set sql_big_selects=1;
|
||||
set sql_big_tables=1;
|
||||
set sql_buffer_result=1;
|
||||
set sql_log_bin=1;
|
||||
set sql_log_off=1;
|
||||
set sql_log_update=1;
|
||||
set sql_low_priority_updates=1;
|
||||
set sql_max_join_size=200;
|
||||
select @@sql_max_join_size,@@max_join_size;
|
||||
set sql_quote_show_create=1;
|
||||
set sql_safe_updates=1;
|
||||
set sql_select_limit=1;
|
||||
set global sql_slave_skip_counter=100;
|
||||
set sql_warnings=1;
|
||||
set global table_cache=100;
|
||||
set table_type=myisam;
|
||||
set global thread_cache_size=100;
|
||||
set timestamp=1, timestamp=default;
|
||||
set tmp_table_size=100;
|
||||
set tx_isolation="READ-COMMITTED";
|
||||
set wait_timeout=100;
|
||||
set log_warnings=1;
|
||||
|
||||
#
|
||||
# key buffer
|
||||
#
|
||||
|
||||
DROP TABLE IF EXISTS t1,t2;
|
||||
create table t1 (a int not null auto_increment, primary key(a));
|
||||
create table t2 (a int not null auto_increment, primary key(a));
|
||||
insert into t1 values(null),(null),(null);
|
||||
insert into t2 values(null),(null),(null);
|
||||
set global key_buffer_size=100000;
|
||||
select @@key_buffer_size;
|
||||
select * from t1 where a=2;
|
||||
select * from t2 where a=3;
|
||||
check table t1,t2;
|
||||
drop table t1,t2;
|
||||
|
||||
|
@ -82,7 +82,7 @@ void load_defaults(const char *conf_file, const char **groups,
|
||||
char *ptr,**res;
|
||||
DBUG_ENTER("load_defaults");
|
||||
|
||||
init_alloc_root(&alloc,128,0);
|
||||
init_alloc_root(&alloc,512,0);
|
||||
if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
|
||||
{
|
||||
/* remove the --no-defaults argument and return only the other arguments */
|
||||
|
@ -547,7 +547,7 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
|
||||
info->error=(int) read_len;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
cnt=(len > Count) ? (int) Count : len;
|
||||
cnt=((uint) len > Count) ? (int) Count : len;
|
||||
memcpy(Buffer,info->read_pos, (size_t)cnt);
|
||||
Count -=cnt;
|
||||
Buffer+=cnt;
|
||||
|
@ -53,6 +53,7 @@ typedef struct sec_link {
|
||||
|
||||
|
||||
static SEC_LINK *find_key_block(int file,my_off_t filepos,int *error);
|
||||
static int flush_all_key_blocks();
|
||||
|
||||
/* static variables in this file */
|
||||
static SEC_LINK *_my_block_root,**_my_hash_root,
|
||||
@ -76,11 +77,9 @@ static my_bool _my_printed;
|
||||
/* Returns blocks in use */
|
||||
/* ARGSUSED */
|
||||
|
||||
int init_key_cache(ulong use_mem,
|
||||
ulong leave_this_much_mem __attribute__((unused)))
|
||||
int init_key_cache(ulong use_mem)
|
||||
{
|
||||
uint blocks,length;
|
||||
byte *extra_mem=0;
|
||||
DBUG_ENTER("init_key_cache");
|
||||
|
||||
if (key_cache_inited && _my_disk_blocks > 0)
|
||||
@ -105,10 +104,6 @@ int init_key_cache(ulong use_mem,
|
||||
/* No use to have very few blocks */
|
||||
if (blocks >= 8 && _my_disk_blocks < 0)
|
||||
{
|
||||
#if !defined(HAVE_ALLOCA) && !defined(THREAD)
|
||||
if ((extra_mem=my_malloc((uint) leave_this_much_mem,MYF(0))) == 0)
|
||||
goto err;
|
||||
#endif
|
||||
for (;;)
|
||||
{
|
||||
/* Set my_hash_blocks to the next bigger 2 power */
|
||||
@ -138,21 +133,48 @@ int init_key_cache(ulong use_mem,
|
||||
DBUG_PRINT("exit",("disk_blocks: %d block_root: %lx _my_hash_blocks: %d hash_root: %lx",
|
||||
_my_disk_blocks,_my_block_root,_my_hash_blocks,
|
||||
_my_hash_root));
|
||||
#if !defined(HAVE_ALLOCA) && !defined(THREAD)
|
||||
my_free(extra_mem,MYF(0));
|
||||
#endif
|
||||
}
|
||||
bzero((gptr) changed_blocks,sizeof(changed_blocks[0])*CHANGED_BLOCKS_HASH);
|
||||
bzero((gptr) file_blocks,sizeof(file_blocks[0])*CHANGED_BLOCKS_HASH);
|
||||
DBUG_RETURN((int) blocks);
|
||||
|
||||
err:
|
||||
if (extra_mem) /* purecov: inspected */
|
||||
my_free(extra_mem,MYF(0));
|
||||
my_errno=ENOMEM;
|
||||
DBUG_RETURN(0);
|
||||
} /* init_key_cache */
|
||||
|
||||
|
||||
/*
|
||||
Resize the key cache
|
||||
|
||||
SYNOPSIS
|
||||
resize_key_cache()
|
||||
use_mem Bytes to use for new key cache
|
||||
|
||||
RETURN VALUES
|
||||
0 Error
|
||||
# number of blocks in key cache
|
||||
*/
|
||||
|
||||
|
||||
int resize_key_cache(ulong use_mem)
|
||||
{
|
||||
int block;
|
||||
pthread_mutex_lock(&THR_LOCK_keycache);
|
||||
if (flush_all_key_blocks())
|
||||
{
|
||||
/* TODO: If this happens, we should write a warning in the log file ! */
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
return 0;
|
||||
}
|
||||
end_key_cache();
|
||||
/* The following will work even if memory is 0 */
|
||||
block=init_key_cache(use_mem);
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
/* Remove key_cache from memory */
|
||||
|
||||
void end_key_cache(void)
|
||||
@ -264,6 +286,11 @@ byte *key_cache_read(File file, my_off_t filepos, byte *buff, uint length,
|
||||
byte *start=buff;
|
||||
uint read_length;
|
||||
pthread_mutex_lock(&THR_LOCK_keycache);
|
||||
if (_my_disk_blocks <= 0) /* Resize failed */
|
||||
{
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
goto no_key_cache;
|
||||
}
|
||||
do
|
||||
{
|
||||
_my_cache_r_requests++;
|
||||
@ -300,6 +327,8 @@ byte *key_cache_read(File file, my_off_t filepos, byte *buff, uint length,
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
DBUG_RETURN(start);
|
||||
}
|
||||
|
||||
no_key_cache:
|
||||
_my_cache_r_requests++;
|
||||
_my_cache_read++;
|
||||
if (my_pread(file,(byte*) buff,length,filepos,MYF(MY_NABP)))
|
||||
@ -336,6 +365,12 @@ int key_cache_write(File file, my_off_t filepos, byte *buff, uint length,
|
||||
{ /* We have key_cacheing */
|
||||
uint read_length;
|
||||
pthread_mutex_lock(&THR_LOCK_keycache);
|
||||
if (_my_disk_blocks <= 0) /* If resize failed */
|
||||
{
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
goto no_key_cache;
|
||||
}
|
||||
|
||||
_my_cache_w_requests++;
|
||||
do
|
||||
{
|
||||
@ -359,8 +394,11 @@ int key_cache_write(File file, my_off_t filepos, byte *buff, uint length,
|
||||
} while ((length-= read_length));
|
||||
error=0;
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
goto end;
|
||||
}
|
||||
else if (dont_write)
|
||||
|
||||
no_key_cache:
|
||||
if (dont_write)
|
||||
{ /* We must write, no cache */
|
||||
_my_cache_w_requests++;
|
||||
_my_cache_write++;
|
||||
@ -368,6 +406,7 @@ int key_cache_write(File file, my_off_t filepos, byte *buff, uint length,
|
||||
MYF(MY_NABP | MY_WAIT_IF_FULL)))
|
||||
error=1;
|
||||
}
|
||||
|
||||
end:
|
||||
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
|
||||
DBUG_EXECUTE("check_keycache",test_key_cache("end of key_cache_write",1););
|
||||
@ -507,6 +546,7 @@ static int cmp_sec_link(SEC_LINK **a, SEC_LINK **b)
|
||||
((*a)->diskpos > (*b)->diskpos) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
static int flush_cached_blocks(File file, SEC_LINK **cache, uint count)
|
||||
{
|
||||
uint last_errno=0;
|
||||
@ -525,25 +565,23 @@ static int flush_cached_blocks(File file, SEC_LINK **cache, uint count)
|
||||
}
|
||||
|
||||
|
||||
int flush_key_blocks(File file, enum flush_type type)
|
||||
static int flush_key_blocks_int(File file, enum flush_type type)
|
||||
{
|
||||
int error=0,last_errno=0;
|
||||
uint count=0;
|
||||
SEC_LINK *cache_buff[FLUSH_CACHE],**cache,**pos,**end;
|
||||
SEC_LINK *used,*next;
|
||||
DBUG_ENTER("flush_key_blocks");
|
||||
DBUG_ENTER("flush_key_blocks_int");
|
||||
DBUG_PRINT("enter",("file: %d blocks_used: %d blocks_changed: %d",
|
||||
file,_my_blocks_used,_my_blocks_changed));
|
||||
|
||||
pthread_mutex_lock(&THR_LOCK_keycache);
|
||||
|
||||
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
|
||||
DBUG_EXECUTE("check_keycache",test_key_cache("start of flush_key_blocks",0););
|
||||
#endif
|
||||
cache=cache_buff; /* If no key cache */
|
||||
if (_my_disk_blocks > 0 &&
|
||||
(!my_disable_flush_key_blocks || type != FLUSH_KEEP))
|
||||
{
|
||||
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
|
||||
DBUG_EXECUTE("check_keycache",test_key_cache("start of flush_key_blocks",0););
|
||||
#endif
|
||||
if (type != FLUSH_IGNORE_CHANGED)
|
||||
{
|
||||
/* Count how many key blocks we have to cache to be able to
|
||||
@ -614,22 +652,69 @@ int flush_key_blocks(File file, enum flush_type type)
|
||||
free_block(used);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_EXECUTE("check_keycache",test_key_cache("end of flush_key_blocks",0););
|
||||
DBUG_EXECUTE("check_keycache",test_key_cache("end of flush_key_blocks",0););
|
||||
#endif
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
}
|
||||
if (cache != cache_buff)
|
||||
my_free((gptr) cache,MYF(0));
|
||||
if (last_errno)
|
||||
errno=last_errno; /* Return first error */
|
||||
DBUG_RETURN(last_errno != 0);
|
||||
} /* flush_key_blocks */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Flush all blocks for a specific file to disk
|
||||
|
||||
SYNOPSIS
|
||||
flush_all_key_blocks()
|
||||
file File descriptor
|
||||
type Type of flush operation
|
||||
|
||||
RETURN VALUES
|
||||
0 Ok
|
||||
1 Error
|
||||
*/
|
||||
|
||||
int flush_key_blocks(File file, enum flush_type type)
|
||||
{
|
||||
int res;
|
||||
pthread_mutex_lock(&THR_LOCK_keycache);
|
||||
res=flush_key_blocks_int(file, type);
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Flush all blocks in the key cache to disk
|
||||
|
||||
SYNOPSIS
|
||||
flush_all_key_blocks()
|
||||
|
||||
NOTE
|
||||
We must have a lock on THR_LOCK_keycache before calling this function
|
||||
|
||||
RETURN VALUES
|
||||
0 Ok
|
||||
1 Error
|
||||
*/
|
||||
|
||||
|
||||
static int flush_all_key_blocks()
|
||||
{
|
||||
int error=0;
|
||||
while (_my_blocks_changed > 0)
|
||||
if (flush_key_blocks_int(_my_used_first->file, FLUSH_RELEASE))
|
||||
error=1;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
/* Test if disk-cachee is ok */
|
||||
/* Test if disk-cache is ok */
|
||||
|
||||
static void test_key_cache(const char *where, my_bool lock)
|
||||
{
|
||||
@ -638,7 +723,14 @@ static void test_key_cache(const char *where, my_bool lock)
|
||||
SEC_LINK *pos,**prev;
|
||||
|
||||
if (lock)
|
||||
{
|
||||
pthread_mutex_lock(&THR_LOCK_keycache);
|
||||
if (_my_disk_blocks <= 0) /* No active key cache */
|
||||
{
|
||||
pthread_mutex_unlock(&THR_LOCK_keycache);
|
||||
return;
|
||||
}
|
||||
}
|
||||
found=error=0;
|
||||
for (i= 0 ; i < _my_hash_blocks ; i++)
|
||||
{
|
||||
|
@ -25,7 +25,8 @@
|
||||
static int findopt(char *optpat, uint length,
|
||||
const struct my_option **opt_res,
|
||||
char **ffname);
|
||||
static my_bool compare_strings(register const char *s, register const char *t,
|
||||
my_bool getopt_compare_strings(const char *s,
|
||||
const char *t,
|
||||
uint length);
|
||||
static longlong getopt_ll(char *arg, const struct my_option *optp, int *err);
|
||||
static ulonglong getopt_ull(char *arg, const struct my_option *optp,
|
||||
@ -116,7 +117,7 @@ int handle_options(int *argc, char ***argv,
|
||||
(*argc)--;
|
||||
}
|
||||
}
|
||||
else if (!compare_strings(cur_arg, "-set-variable", 13))
|
||||
else if (!getopt_compare_strings(cur_arg, "-set-variable", 13))
|
||||
{
|
||||
must_be_var= 1;
|
||||
if (cur_arg[13] == '=')
|
||||
@ -182,8 +183,8 @@ int handle_options(int *argc, char ***argv,
|
||||
must_be_var= 1; /* option is followed by an argument */
|
||||
for (i= 0; special_opt_prefix[i]; i++)
|
||||
{
|
||||
if (!compare_strings(special_opt_prefix[i], cur_arg,
|
||||
special_opt_prefix_lengths[i]) &&
|
||||
if (!getopt_compare_strings(special_opt_prefix[i], cur_arg,
|
||||
special_opt_prefix_lengths[i]) &&
|
||||
cur_arg[special_opt_prefix_lengths[i]] == '-')
|
||||
{
|
||||
/*
|
||||
@ -481,21 +482,21 @@ static int setval (const struct my_option *opts, char *argument,
|
||||
the name in ffname argument
|
||||
*/
|
||||
|
||||
static int findopt (char *optpat, uint length,
|
||||
const struct my_option **opt_res,
|
||||
char **ffname)
|
||||
static int findopt(char *optpat, uint length,
|
||||
const struct my_option **opt_res,
|
||||
char **ffname)
|
||||
{
|
||||
int count;
|
||||
struct my_option *opt= (struct my_option *) *opt_res;
|
||||
|
||||
for (count= 0; opt->name; opt++)
|
||||
{
|
||||
if (!compare_strings(opt->name, optpat, length)) /* match found */
|
||||
if (!getopt_compare_strings(opt->name, optpat, length)) /* match found */
|
||||
{
|
||||
(*opt_res)= opt;
|
||||
if (!count)
|
||||
*ffname= (char *) opt->name; /* we only need to know one prev */
|
||||
if (length == strlen(opt->name)) /* exact match */
|
||||
*ffname= (char *) opt->name; /* We only need to know one prev */
|
||||
if (!opt->name[length]) /* Exact match */
|
||||
return 1;
|
||||
count++;
|
||||
}
|
||||
@ -511,7 +512,7 @@ static int findopt (char *optpat, uint length,
|
||||
2.) Returns -1 if strings differ, 0 if they are equal
|
||||
*/
|
||||
|
||||
static my_bool compare_strings(register const char *s, register const char *t,
|
||||
my_bool getopt_compare_strings(register const char *s, register const char *t,
|
||||
uint length)
|
||||
{
|
||||
char const *end= s + length;
|
||||
@ -565,7 +566,7 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name)
|
||||
In case of an error, set error value in *err.
|
||||
*/
|
||||
|
||||
static longlong getopt_ll (char *arg, const struct my_option *optp, int *err)
|
||||
longlong getopt_ll (char *arg, const struct my_option *optp, int *err)
|
||||
{
|
||||
longlong num;
|
||||
|
||||
@ -594,16 +595,23 @@ static ulonglong getopt_ull (char *arg, const struct my_option *optp, int *err)
|
||||
ulonglong num;
|
||||
|
||||
num= eval_num_suffix(arg, err, (char*) optp->name);
|
||||
return getopt_ull_limit_value(num, optp);
|
||||
}
|
||||
|
||||
|
||||
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp)
|
||||
{
|
||||
if ((ulonglong) num > (ulonglong) (ulong) optp->max_value &&
|
||||
optp->max_value) /* if max value is not set -> no upper limit */
|
||||
num= (ulonglong) (ulong) optp->max_value;
|
||||
if (optp->block_size > 1)
|
||||
{
|
||||
num/= (ulonglong) optp->block_size;
|
||||
num*= (ulonglong) optp->block_size;
|
||||
}
|
||||
if (num < (ulonglong) optp->min_value)
|
||||
num= (ulonglong) optp->min_value;
|
||||
else if (num > 0 && (ulonglong) num > (ulonglong) (ulong) optp->max_value
|
||||
&& optp->max_value) /* if max value is not set -> no upper limit */
|
||||
num= (ulonglong) (ulong) optp->max_value;
|
||||
num= ((num - (ulonglong) optp->sub_size) / (optp->block_size ?
|
||||
(ulonglong) optp->block_size :
|
||||
1L));
|
||||
return (ulonglong) (num * (optp->block_size ? (ulonglong) optp->block_size :
|
||||
1L));
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -65,7 +65,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
||||
net_serv.cc net_pkg.cc lock.cc my_lock.c \
|
||||
sql_string.cc sql_manager.cc sql_map.cc \
|
||||
mysqld.cc password.c hash_filo.cc hostname.cc \
|
||||
convert.cc sql_parse.cc sql_yacc.yy \
|
||||
convert.cc set_var.cc sql_parse.cc sql_yacc.yy \
|
||||
sql_base.cc table.cc sql_select.cc sql_insert.cc \
|
||||
sql_update.cc sql_delete.cc uniques.cc sql_do.cc \
|
||||
procedure.cc item_uniq.cc sql_test.cc \
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "mysql_priv.h"
|
||||
|
||||
/****************************************************************************
|
||||
** Convert tables
|
||||
Convert tables
|
||||
****************************************************************************/
|
||||
|
||||
/* Windows cp1251->koi8 and reverse conversion by Timur I. Bakeyev <translate@bat.ru> */
|
||||
|
@ -201,7 +201,7 @@ bool Field::send(THD *thd, String *packet)
|
||||
String tmp(buff,sizeof(buff));
|
||||
val_str(&tmp,&tmp);
|
||||
CONVERT *convert;
|
||||
if ((convert=thd->convert_set))
|
||||
if ((convert=thd->variables.convert_set))
|
||||
return convert->store(packet,tmp.ptr(),tmp.length());
|
||||
return net_store_data(packet,tmp.ptr(),tmp.length());
|
||||
}
|
||||
|
@ -318,7 +318,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
|
||||
file->extra(HA_EXTRA_KEYREAD); // QQ is removed
|
||||
next_pos=(byte*) 0; /* Find records in sequence */
|
||||
file->rnd_init();
|
||||
file->extra(HA_EXTRA_CACHE); /* Quicker reads */
|
||||
file->extra_opt(HA_EXTRA_CACHE,
|
||||
current_thd->variables.read_buff_size);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
@ -920,7 +921,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
|
||||
if (sortorder->field)
|
||||
{
|
||||
if (sortorder->field->type() == FIELD_TYPE_BLOB)
|
||||
sortorder->length= thd->variables.max_item_sort_length;
|
||||
sortorder->length= thd->variables.max_sort_length;
|
||||
else
|
||||
{
|
||||
sortorder->length=sortorder->field->pack_length();
|
||||
@ -956,7 +957,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
|
||||
if (sortorder->item->maybe_null)
|
||||
length++; // Place for NULL marker
|
||||
}
|
||||
set_if_smaller(sortorder->length, thd->variables.max_item_sort_length);
|
||||
set_if_smaller(sortorder->length, thd->variables.max_sort_length);
|
||||
length+=sortorder->length;
|
||||
}
|
||||
sortorder->field= (Field*) 0; // end marker
|
||||
|
@ -1701,7 +1701,7 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
|
||||
DBUG_ASSERT(thd->transaction.stmt.bdb_tid == 0);
|
||||
transaction=0; // Safety
|
||||
/* First table lock, start transaction */
|
||||
if ((thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN |
|
||||
if ((thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN |
|
||||
OPTION_TABLE_LOCK)) &&
|
||||
!thd->transaction.all.bdb_tid)
|
||||
{
|
||||
|
@ -3176,7 +3176,7 @@ ha_innobase::external_lock(
|
||||
thd->transaction.all.innodb_active_trans = 1;
|
||||
trx->n_mysql_tables_in_use++;
|
||||
|
||||
if (thd->tx_isolation == ISO_SERIALIZABLE
|
||||
if (thd->variables.tx_isolation == ISO_SERIALIZABLE
|
||||
&& prebuilt->select_lock_type == LOCK_NONE) {
|
||||
|
||||
/* To get serializable execution we let InnoDB
|
||||
@ -3204,7 +3204,7 @@ ha_innobase::external_lock(
|
||||
innobase_release_stat_resources(trx);
|
||||
|
||||
if (!(thd->options
|
||||
& (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) {
|
||||
& (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
|
||||
|
||||
innobase_commit(thd, trx);
|
||||
thd->transaction.all.innodb_active_trans=0;
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "../myisam/myisamdef.h"
|
||||
#endif
|
||||
|
||||
ulong myisam_sort_buffer_size;
|
||||
ulong myisam_recover_options= HA_RECOVER_NONE;
|
||||
|
||||
/* bits in myisam_recover_options */
|
||||
@ -218,10 +217,10 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
|
||||
return (my_errno ? my_errno : -1);
|
||||
|
||||
if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
|
||||
VOID(mi_extra(file,HA_EXTRA_NO_WAIT_LOCK));
|
||||
VOID(mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0));
|
||||
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
|
||||
if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
|
||||
VOID(mi_extra(file,HA_EXTRA_WAIT_LOCK));
|
||||
VOID(mi_extra(file, HA_EXTRA_WAIT_LOCK, 0));
|
||||
if (!table->db_record_offset)
|
||||
int_table_flags|=HA_REC_NOT_IN_SEQ;
|
||||
return (0);
|
||||
@ -665,13 +664,16 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
||||
if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
|
||||
{
|
||||
if (!(specialflag & SPECIAL_SAFE_MODE))
|
||||
if (rows==HA_POS_ERROR)
|
||||
mi_extra(file, HA_EXTRA_NO_KEYS);
|
||||
{
|
||||
if (rows == HA_POS_ERROR)
|
||||
mi_extra(file, HA_EXTRA_NO_KEYS, 0);
|
||||
else
|
||||
{
|
||||
mi_disable_non_unique_index(file,rows);
|
||||
mi_extra(file, HA_EXTRA_BULK_INSERT_BEGIN);
|
||||
ha_myisam::extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
|
||||
current_thd->variables.bulk_insert_buff_size);
|
||||
}
|
||||
}
|
||||
enable_activate_all_index=1;
|
||||
}
|
||||
else
|
||||
@ -686,7 +688,7 @@ bool ha_myisam::activate_all_index(THD *thd)
|
||||
MYISAM_SHARE* share = file->s;
|
||||
DBUG_ENTER("activate_all_index");
|
||||
|
||||
mi_extra(file, HA_EXTRA_BULK_INSERT_END);
|
||||
mi_extra(file, HA_EXTRA_BULK_INSERT_END, 0);
|
||||
if (enable_activate_all_index &&
|
||||
share->state.key_map != set_bits(ulonglong, share->base.keys))
|
||||
{
|
||||
@ -697,7 +699,7 @@ bool ha_myisam::activate_all_index(THD *thd)
|
||||
param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
|
||||
T_CREATE_MISSING_KEYS);
|
||||
param.myf_rw&= ~MY_WAIT_IF_FULL;
|
||||
param.sort_buffer_length= myisam_sort_buffer_size;
|
||||
param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
|
||||
param.tmpdir=mysql_tmpdir;
|
||||
error=repair(thd,param,0) != HA_ADMIN_OK;
|
||||
thd->proc_info=save_proc_info;
|
||||
@ -828,8 +830,7 @@ int ha_myisam::rnd_init(bool scan)
|
||||
{
|
||||
if (scan)
|
||||
return mi_scan_init(file);
|
||||
else
|
||||
return mi_extra(file,HA_EXTRA_RESET);
|
||||
return mi_extra(file, HA_EXTRA_RESET, 0);
|
||||
}
|
||||
|
||||
int ha_myisam::rnd_next(byte *buf)
|
||||
@ -921,17 +922,27 @@ void ha_myisam::info(uint flag)
|
||||
|
||||
int ha_myisam::extra(enum ha_extra_function operation)
|
||||
{
|
||||
if (((specialflag & SPECIAL_SAFE_MODE) || (test_flags & TEST_NO_EXTRA)) &&
|
||||
if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_KEYREAD)
|
||||
return 0;
|
||||
return mi_extra(file, operation, 0);
|
||||
}
|
||||
|
||||
|
||||
/* To be used with WRITE_CACHE, EXTRA_CACHE and BULK_INSERT_BEGIN */
|
||||
|
||||
int ha_myisam::extra_opt(enum ha_extra_function operation, ulong cache_size)
|
||||
{
|
||||
if ((specialflag & SPECIAL_SAFE_MODE) &
|
||||
(operation == HA_EXTRA_WRITE_CACHE ||
|
||||
operation == HA_EXTRA_KEYREAD ||
|
||||
operation == HA_EXTRA_BULK_INSERT_BEGIN))
|
||||
return 0;
|
||||
return mi_extra(file,operation);
|
||||
return mi_extra(file, operation, (void*) &cache_size);
|
||||
}
|
||||
|
||||
|
||||
int ha_myisam::reset(void)
|
||||
{
|
||||
return mi_extra(file,HA_EXTRA_RESET);
|
||||
return mi_extra(file, HA_EXTRA_RESET, 0);
|
||||
}
|
||||
|
||||
int ha_myisam::delete_all_rows()
|
||||
|
@ -100,6 +100,7 @@ class ha_myisam: public handler
|
||||
my_off_t row_position() { return mi_position(file); }
|
||||
void info(uint);
|
||||
int extra(enum ha_extra_function operation);
|
||||
int extra_opt(enum ha_extra_function operation, ulong cache_size);
|
||||
int reset(void);
|
||||
int external_lock(THD *thd, int lock_type);
|
||||
int delete_all_rows(void);
|
||||
|
@ -49,10 +49,10 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
|
||||
myrg_extrafunc(file, query_cache_invalidate_by_MyISAM_filename_ref);
|
||||
if (!(test_if_locked == HA_OPEN_WAIT_IF_LOCKED ||
|
||||
test_if_locked == HA_OPEN_ABORT_IF_LOCKED))
|
||||
myrg_extra(file,HA_EXTRA_NO_WAIT_LOCK);
|
||||
myrg_extra(file,HA_EXTRA_NO_WAIT_LOCK,0);
|
||||
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
|
||||
if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
|
||||
myrg_extra(file,HA_EXTRA_WAIT_LOCK);
|
||||
myrg_extra(file,HA_EXTRA_WAIT_LOCK,0);
|
||||
if (table->reclength != mean_rec_length && mean_rec_length)
|
||||
{
|
||||
DBUG_PRINT("error",("reclength: %d mean_rec_length: %d",
|
||||
@ -155,7 +155,7 @@ int ha_myisammrg::index_last(byte * buf)
|
||||
|
||||
int ha_myisammrg::rnd_init(bool scan)
|
||||
{
|
||||
return myrg_extra(file,HA_EXTRA_RESET);
|
||||
return myrg_extra(file,HA_EXTRA_RESET,0);
|
||||
}
|
||||
|
||||
int ha_myisammrg::rnd_next(byte *buf)
|
||||
@ -210,12 +210,25 @@ int ha_myisammrg::extra(enum ha_extra_function operation)
|
||||
if (operation == HA_EXTRA_FORCE_REOPEN ||
|
||||
operation == HA_EXTRA_PREPARE_FOR_DELETE)
|
||||
return 0;
|
||||
return myrg_extra(file,operation);
|
||||
return myrg_extra(file,operation,0);
|
||||
}
|
||||
|
||||
|
||||
/* To be used with WRITE_CACHE, EXTRA_CACHE and BULK_INSERT_BEGIN */
|
||||
|
||||
int ha_myisammrg::extra_opt(enum ha_extra_function operation, ulong cache_size)
|
||||
{
|
||||
if ((specialflag & SPECIAL_SAFE_MODE) &
|
||||
(operation == HA_EXTRA_WRITE_CACHE ||
|
||||
operation == HA_EXTRA_BULK_INSERT_BEGIN))
|
||||
return 0;
|
||||
return myrg_extra(file, operation, (void*) &cache_size);
|
||||
}
|
||||
|
||||
|
||||
int ha_myisammrg::reset(void)
|
||||
{
|
||||
return myrg_extra(file,HA_EXTRA_RESET);
|
||||
return myrg_extra(file,HA_EXTRA_RESET,0);
|
||||
}
|
||||
|
||||
int ha_myisammrg::external_lock(THD *thd, int lock_type)
|
||||
|
@ -72,6 +72,7 @@ class ha_myisammrg: public handler
|
||||
my_off_t row_position() { return myrg_position(file); }
|
||||
void info(uint);
|
||||
int extra(enum ha_extra_function operation);
|
||||
int extra_opt(enum ha_extra_function operation, ulong cache_size);
|
||||
int reset(void);
|
||||
int external_lock(THD *thd, int lock_type);
|
||||
uint lock_count(void) const;
|
||||
|
@ -53,8 +53,10 @@ const char *ha_table_type[] = {
|
||||
"MRG_ISAM","MYISAM", "MRG_MYISAM", "BDB", "INNODB", "GEMINI", "?", "?",NullS
|
||||
};
|
||||
|
||||
TYPELIB ha_table_typelib= {array_elements(ha_table_type)-4,"",
|
||||
ha_table_type+1};
|
||||
TYPELIB ha_table_typelib=
|
||||
{
|
||||
array_elements(ha_table_type)-3, "", ha_table_type
|
||||
};
|
||||
|
||||
const char *ha_row_type[] = {
|
||||
"", "FIXED", "DYNAMIC", "COMPRESSED","?","?","?"
|
||||
@ -216,7 +218,7 @@ int ha_autocommit_or_rollback(THD *thd, int error)
|
||||
}
|
||||
else
|
||||
(void) ha_rollback_stmt(thd);
|
||||
thd->tx_isolation=thd->session_tx_isolation;
|
||||
thd->variables.tx_isolation=thd->session_tx_isolation;
|
||||
}
|
||||
#endif
|
||||
DBUG_RETURN(error);
|
||||
@ -314,7 +316,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
|
||||
#endif /*HAVE_QUERY_CACHE*/
|
||||
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
|
||||
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
|
||||
thd->tx_isolation=thd->session_tx_isolation;
|
||||
thd->variables.tx_isolation=thd->session_tx_isolation;
|
||||
if (operation_done)
|
||||
{
|
||||
statistic_increment(ha_commit_count,&LOCK_status);
|
||||
@ -362,7 +364,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
|
||||
reinit_io_cache(&thd->transaction.trans_log,
|
||||
WRITE_CACHE, (my_off_t) 0, 0, 1);
|
||||
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
|
||||
thd->tx_isolation=thd->session_tx_isolation;
|
||||
thd->variables.tx_isolation=thd->session_tx_isolation;
|
||||
if (operation_done)
|
||||
{
|
||||
statistic_increment(ha_rollback_count,&LOCK_status);
|
||||
@ -865,8 +867,14 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
|
||||
void ha_key_cache(void)
|
||||
{
|
||||
if (keybuff_size)
|
||||
(void) init_key_cache(keybuff_size,0);
|
||||
} /* ha_key_cache */
|
||||
(void) init_key_cache(keybuff_size);
|
||||
}
|
||||
|
||||
|
||||
void ha_resize_key_cache(void)
|
||||
{
|
||||
(void) resize_key_cache(keybuff_size);
|
||||
}
|
||||
|
||||
|
||||
static int NEAR_F delete_file(const char *name,const char *ext,int extflag)
|
||||
@ -875,3 +883,9 @@ static int NEAR_F delete_file(const char *name,const char *ext,int extflag)
|
||||
VOID(fn_format(buff,name,"",ext,extflag | 4));
|
||||
return(my_delete_with_symlink(buff,MYF(MY_WME)));
|
||||
}
|
||||
|
||||
void st_ha_check_opt::init()
|
||||
{
|
||||
flags= sql_flags= 0;
|
||||
sort_buffer_size = current_thd->variables.myisam_sort_buff_size;
|
||||
}
|
||||
|
@ -172,18 +172,13 @@ typedef struct st_ha_create_information
|
||||
|
||||
struct st_table;
|
||||
typedef struct st_table TABLE;
|
||||
extern ulong myisam_sort_buffer_size;
|
||||
|
||||
typedef struct st_ha_check_opt
|
||||
{
|
||||
ulong sort_buffer_size;
|
||||
uint flags; /* isam layer flags (e.g. for myisamchk) */
|
||||
uint sql_flags; /* sql layer flags - for something myisamchk cannot do */
|
||||
inline void init()
|
||||
{
|
||||
flags= sql_flags= 0;
|
||||
sort_buffer_size = myisam_sort_buffer_size;
|
||||
}
|
||||
void init();
|
||||
} HA_CHECK_OPT;
|
||||
|
||||
class handler :public Sql_alloc
|
||||
@ -285,6 +280,10 @@ public:
|
||||
virtual my_off_t row_position() { return HA_OFFSET_ERROR; }
|
||||
virtual void info(uint)=0;
|
||||
virtual int extra(enum ha_extra_function operation)=0;
|
||||
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
|
||||
{
|
||||
return extra(operation);
|
||||
}
|
||||
virtual int reset()=0;
|
||||
virtual int external_lock(THD *thd, int lock_type)=0;
|
||||
virtual void unlock_row() {}
|
||||
@ -367,6 +366,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
|
||||
int ha_delete_table(enum db_type db_type, const char *path);
|
||||
void ha_drop_database(char* path);
|
||||
void ha_key_cache(void);
|
||||
void ha_resize_key_cache(void);
|
||||
int ha_start_stmt(THD *thd);
|
||||
int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name,
|
||||
my_off_t end_offset);
|
||||
|
@ -593,7 +593,7 @@ bool Item::send(THD *thd, String *packet)
|
||||
String s(buff,sizeof(buff)),*res;
|
||||
if (!(res=val_str(&s)))
|
||||
return net_store_null(packet);
|
||||
if ((convert=thd->convert_set))
|
||||
if ((convert=thd->variables.convert_set))
|
||||
return convert->store(packet,res->ptr(),res->length());
|
||||
return net_store_data(packet,res->ptr(),res->length());
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
const char *full_name() const;
|
||||
};
|
||||
|
||||
|
||||
class Item_field :public Item_ident
|
||||
{
|
||||
void set_field(Field *field);
|
||||
@ -193,6 +194,7 @@ class Item_uint :public Item_int
|
||||
public:
|
||||
Item_uint(const char *str_arg, uint length) :
|
||||
Item_int(str_arg, (longlong) strtoull(str_arg,(char**) 0,10), length) {}
|
||||
Item_uint(uint32 i) :Item_int((longlong) i, 10) {}
|
||||
double val() { return ulonglong2double(value); }
|
||||
String *val_str(String*);
|
||||
void make_field(Send_field *field);
|
||||
@ -478,4 +480,3 @@ extern Item_buff *new_Item_buff(Item *item);
|
||||
extern Item_result item_cmp_type(Item_result a,Item_result b);
|
||||
extern Item *resolve_const_item(Item *item,Item *cmp_item);
|
||||
extern bool field_is_equal_to_item(Field *field,Item *item);
|
||||
Item *get_system_var(LEX_STRING name);
|
||||
|
@ -1761,7 +1761,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
|
||||
bool Item_func_set_user_var::fix_fields(THD *thd,TABLE_LIST *tables)
|
||||
{
|
||||
if (!thd)
|
||||
thd=current_thd;
|
||||
thd=current_thd; // Should never happen
|
||||
if (Item_func::fix_fields(thd,tables) ||
|
||||
!(entry= get_variable(&thd->user_vars, name, 1)))
|
||||
return 1;
|
||||
@ -2269,21 +2269,35 @@ longlong Item_func_bit_xor::val_int()
|
||||
|
||||
/***************************************************************************
|
||||
System variables
|
||||
This has to be recoded after we get more than 3 system variables
|
||||
****************************************************************************/
|
||||
|
||||
Item *get_system_var(LEX_STRING name)
|
||||
Item *get_system_var(enum_var_type var_type, LEX_STRING name)
|
||||
{
|
||||
if (!my_strcasecmp(name.str,"IDENTITY"))
|
||||
return new Item_int((char*) "@@IDENTITY",
|
||||
current_thd->insert_id(),21);
|
||||
if (!my_strcasecmp(name.str,"VERSION"))
|
||||
return new Item_string("@@VERSION",server_version,
|
||||
(uint) strlen(server_version));
|
||||
net_printf(¤t_thd->net, ER_UNKNOWN_SYSTEM_VARIABLE, name.str);
|
||||
return 0;
|
||||
|
||||
THD *thd=current_thd;
|
||||
Item *item;
|
||||
sys_var *var;
|
||||
char buff[MAX_SYS_VAR_LENGTH+3];
|
||||
|
||||
if (!(var= find_sys_var(name.str)))
|
||||
{
|
||||
net_printf(&thd->net, ER_UNKNOWN_SYSTEM_VARIABLE, name.str);
|
||||
return 0;
|
||||
}
|
||||
if (!(item=var->item(thd, var_type)))
|
||||
return 0; // Impossible
|
||||
thd->safe_to_cache_query=0;
|
||||
buff[0]='@';
|
||||
buff[1]='@';
|
||||
memcpy(buff+2, var->name, var->name_length+1);
|
||||
item->set_name(buff,var->name_length+2); // Will allocate name
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check a user level lock.
|
||||
|
||||
|
@ -236,7 +236,8 @@ String *Item_func_concat::val_str(String *str)
|
||||
goto null;
|
||||
if (res2->length() == 0)
|
||||
continue;
|
||||
if (res->length()+res2->length() > max_allowed_packet)
|
||||
if (res->length()+res2->length() >
|
||||
current_thd->variables.max_allowed_packet)
|
||||
goto null; // Error check
|
||||
if (res->alloced_length() >= res->length()+res2->length())
|
||||
{ // Use old buffer
|
||||
@ -505,7 +506,7 @@ String *Item_func_concat_ws::val_str(String *str)
|
||||
continue; // Skip NULL and empty string
|
||||
|
||||
if (res->length() + sep_str->length() + res2->length() >
|
||||
max_allowed_packet)
|
||||
current_thd->variables.max_allowed_packet)
|
||||
goto null; // Error check
|
||||
if (res->alloced_length() >=
|
||||
res->length() + sep_str->length() + res2->length())
|
||||
@ -714,7 +715,8 @@ redo:
|
||||
while (j != search_end)
|
||||
if (*i++ != *j++) goto skipp;
|
||||
offset= (int) (ptr-res->ptr());
|
||||
if (res->length()-from_length + to_length > max_allowed_packet)
|
||||
if (res->length()-from_length + to_length >
|
||||
current_thd->variables.max_allowed_packet)
|
||||
goto null;
|
||||
if (!alloced)
|
||||
{
|
||||
@ -734,7 +736,8 @@ skipp:
|
||||
#endif /* USE_MB */
|
||||
do
|
||||
{
|
||||
if (res->length()-from_length + to_length > max_allowed_packet)
|
||||
if (res->length()-from_length + to_length >
|
||||
current_thd->variables.max_allowed_packet)
|
||||
goto null;
|
||||
if (!alloced)
|
||||
{
|
||||
@ -794,7 +797,8 @@ String *Item_func_insert::val_str(String *str)
|
||||
return res; // Wrong param; skip insert
|
||||
if (length > res->length()-start)
|
||||
length=res->length()-start;
|
||||
if (res->length() - length + res2->length() > max_allowed_packet)
|
||||
if (res->length() - length + res2->length() >
|
||||
current_thd->variables.max_allowed_packet)
|
||||
goto null; // OOM check
|
||||
res=copy_if_not_alloced(str,res,res->length());
|
||||
res->replace(start,length,*res2);
|
||||
@ -1699,7 +1703,8 @@ String *Item_func_repeat::val_str(String *str)
|
||||
if (count == 1) // To avoid reallocs
|
||||
return res;
|
||||
length=res->length();
|
||||
if (length > max_allowed_packet/count)// Safe length check
|
||||
// Safe length check
|
||||
if (length > current_thd->variables.max_allowed_packet/count)
|
||||
goto err; // Probably an error
|
||||
tot_length= length*(uint) count;
|
||||
if (!(res= alloc_buffer(res,str,&tmp_value,tot_length)))
|
||||
@ -1757,7 +1762,8 @@ String *Item_func_rpad::val_str(String *str)
|
||||
return (res);
|
||||
}
|
||||
length_pad= rpad->length();
|
||||
if ((ulong) count > max_allowed_packet || args[2]->null_value || !length_pad)
|
||||
if ((ulong) count > current_thd->variables.max_allowed_packet ||
|
||||
args[2]->null_value || !length_pad)
|
||||
goto err;
|
||||
if (!(res= alloc_buffer(res,str,&tmp_value,count)))
|
||||
goto err;
|
||||
@ -1816,7 +1822,8 @@ String *Item_func_lpad::val_str(String *str)
|
||||
return (res);
|
||||
}
|
||||
length_pad= lpad->length();
|
||||
if (count > max_allowed_packet || args[2]->null_value || !length_pad)
|
||||
if (count > current_thd->variables.max_allowed_packet ||
|
||||
args[2]->null_value || !length_pad)
|
||||
goto err;
|
||||
|
||||
if (res->alloced_length() < count)
|
||||
@ -1937,7 +1944,7 @@ String *Item_load_file::val_str(String *str)
|
||||
/* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */
|
||||
goto err;
|
||||
}
|
||||
if (stat_info.st_size > (long) max_allowed_packet)
|
||||
if (stat_info.st_size > (long) current_thd->variables.max_allowed_packet)
|
||||
{
|
||||
/* my_error(ER_TOO_LONG_STRING, MYF(0), file_name->c_ptr()); */
|
||||
goto err;
|
||||
|
@ -59,7 +59,7 @@ int find_ref_key(TABLE *table,Field *field, uint *key_length)
|
||||
{
|
||||
if (key_part->offset == fieldpos)
|
||||
return(i); /* Use this key */
|
||||
*key_length+=key_part->length;
|
||||
*key_length+=key_part->store_length;
|
||||
}
|
||||
}
|
||||
return(-1); /* No key is ok */
|
||||
|
22
sql/lex.h
22
sql/lex.h
@ -61,7 +61,6 @@ static SYMBOL symbols[] = {
|
||||
{ "AVG", SYM(AVG_SYM),0,0},
|
||||
{ "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH),0,0},
|
||||
{ "AUTO_INCREMENT", SYM(AUTO_INC),0,0},
|
||||
{ "AUTOCOMMIT", SYM(AUTOCOMMIT),0,0},
|
||||
{ "BACKUP", SYM(BACKUP_SYM),0,0},
|
||||
{ "BEGIN", SYM(BEGIN_SYM),0,0},
|
||||
{ "BERKELEYDB", SYM(BERKELEY_DB_SYM),0,0},
|
||||
@ -117,7 +116,6 @@ static SYMBOL symbols[] = {
|
||||
{ "DELAYED", SYM(DELAYED_SYM),0,0},
|
||||
{ "DELAY_KEY_WRITE", SYM(DELAY_KEY_WRITE_SYM),0,0},
|
||||
{ "DELETE", SYM(DELETE_SYM),0,0},
|
||||
{ "DEMAND", SYM(DEMAND_SYM),0,0},
|
||||
{ "DESC", SYM(DESC),0,0},
|
||||
{ "DESCRIBE", SYM(DESCRIBE),0,0},
|
||||
{ "DIRECTORY", SYM(DIRECTORY_SYM),0,0},
|
||||
@ -182,7 +180,6 @@ static SYMBOL symbols[] = {
|
||||
{ "INNOBASE", SYM(INNOBASE_SYM),0,0},
|
||||
{ "INNODB", SYM(INNOBASE_SYM),0,0},
|
||||
{ "INSERT", SYM(INSERT),0,0},
|
||||
{ "INSERT_ID", SYM(INSERT_ID),0,0},
|
||||
{ "INSERT_METHOD", SYM(INSERT_METHOD),0,0},
|
||||
{ "INT", SYM(INT_SYM),0,0},
|
||||
{ "INTEGER", SYM(INT_SYM),0,0},
|
||||
@ -204,7 +201,6 @@ static SYMBOL symbols[] = {
|
||||
{ "KEYS", SYM(KEYS),0,0},
|
||||
{ "KILL", SYM(KILL_SYM),0,0},
|
||||
{ "LAST", SYM(LAST_SYM),0,0},
|
||||
{ "LAST_INSERT_ID", SYM(LAST_INSERT_ID),0,0},
|
||||
{ "LEADING", SYM(LEADING),0,0},
|
||||
{ "LEFT", SYM(LEFT),0,0},
|
||||
{ "LEVEL", SYM(LEVEL_SYM),0,0},
|
||||
@ -257,7 +253,6 @@ static SYMBOL symbols[] = {
|
||||
{ "NOT", SYM(NOT),0,0},
|
||||
{ "NULL", SYM(NULL_SYM),0,0},
|
||||
{ "NUMERIC", SYM(NUMERIC_SYM),0,0},
|
||||
{ "OFF", SYM(OFF),0,0},
|
||||
{ "ON", SYM(ON),0,0},
|
||||
{ "OPEN", SYM(OPEN_SYM),0,0},
|
||||
{ "OPTIMIZE", SYM(OPTIMIZE),0,0},
|
||||
@ -317,27 +312,13 @@ static SYMBOL symbols[] = {
|
||||
{ "SLAVE", SYM(SLAVE),0,0},
|
||||
{ "SMALLINT", SYM(SMALLINT),0,0},
|
||||
{ "SONAME", SYM(UDF_SONAME_SYM),0,0},
|
||||
{ "SQL_AUTO_IS_NULL", SYM(SQL_AUTO_IS_NULL),0,0},
|
||||
{ "SQL_BIG_RESULT", SYM(SQL_BIG_RESULT),0,0},
|
||||
{ "SQL_BIG_SELECTS", SYM(SQL_BIG_SELECTS),0,0},
|
||||
{ "SQL_BIG_TABLES", SYM(SQL_BIG_TABLES),0,0},
|
||||
{ "SQL_BUFFER_RESULT", SYM(SQL_BUFFER_RESULT),0,0},
|
||||
{ "SQL_CACHE", SYM(SQL_CACHE_SYM), 0, 0},
|
||||
{ "SQL_CALC_FOUND_ROWS", SYM(SQL_CALC_FOUND_ROWS),0,0},
|
||||
{ "SQL_LOG_BIN", SYM(SQL_LOG_BIN),0,0},
|
||||
{ "SQL_LOG_OFF", SYM(SQL_LOG_OFF),0,0},
|
||||
{ "SQL_LOG_UPDATE", SYM(SQL_LOG_UPDATE),0,0},
|
||||
{ "SQL_LOW_PRIORITY_UPDATES", SYM(SQL_LOW_PRIORITY_UPDATES),0,0},
|
||||
{ "SQL_MAX_JOIN_SIZE",SYM(SQL_MAX_JOIN_SIZE), 0, 0},
|
||||
{ "SQL_NO_CACHE", SYM(SQL_NO_CACHE_SYM), 0, 0},
|
||||
{ "SQL_QUERY_CACHE_TYPE",SYM(SQL_QUERY_CACHE_TYPE_SYM), 0, 0},
|
||||
{ "SQL_QUOTE_SHOW_CREATE",SYM(SQL_QUOTE_SHOW_CREATE), 0, 0},
|
||||
{ "SQL_SAFE_UPDATES", SYM(SQL_SAFE_UPDATES),0,0},
|
||||
{ "SQL_SELECT_LIMIT", SYM(SQL_SELECT_LIMIT),0,0},
|
||||
{ "SQL_SLAVE_SKIP_COUNTER", SYM(SQL_SLAVE_SKIP_COUNTER),0,0},
|
||||
{ "SQL_SMALL_RESULT", SYM(SQL_SMALL_RESULT),0,0},
|
||||
{ "SQL_THREAD", SYM(SQL_THREAD),0,0},
|
||||
{ "SQL_WARNINGS", SYM(SQL_WARNINGS),0,0},
|
||||
{ "SQL_THREAD", SYM(SQL_THREAD),0,0},
|
||||
{ "SSL", SYM(SSL_SYM),0,0},
|
||||
{ "STRAIGHT_JOIN", SYM(STRAIGHT_JOIN),0,0},
|
||||
{ "START", SYM(START_SYM),0,0},
|
||||
@ -458,6 +439,7 @@ static SYMBOL sql_functions[] = {
|
||||
{ "INSTR", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_instr)},
|
||||
{ "ISNULL", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_isnull)},
|
||||
{ "IS_FREE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_is_free_lock)},
|
||||
{ "LAST_INSERT_ID", SYM(LAST_INSERT_ID),0,0},
|
||||
{ "LCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_lcase)},
|
||||
{ "LEAST", SYM(LEAST_SYM),0,0},
|
||||
{ "LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_length)},
|
||||
|
@ -937,11 +937,11 @@ bool MYSQL_LOG::write(Log_event* event_info)
|
||||
if (e.write(file))
|
||||
goto err;
|
||||
}
|
||||
if (thd && thd->convert_set)
|
||||
if (thd && thd->variables.convert_set)
|
||||
{
|
||||
char buf[1024] = "SET CHARACTER SET ";
|
||||
char* p = strend(buf);
|
||||
p = strmov(p, thd->convert_set->name);
|
||||
p = strmov(p, thd->variables.convert_set->name);
|
||||
int save_query_length = thd->query_length;
|
||||
// just in case somebody wants it later
|
||||
thd->query_length = (uint)(p - buf);
|
||||
|
@ -446,7 +446,8 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
|
||||
goto end;
|
||||
}
|
||||
data_len= uint4korr(buf + EVENT_LEN_OFFSET);
|
||||
if (data_len < LOG_EVENT_HEADER_LEN || data_len > max_allowed_packet)
|
||||
if (data_len < LOG_EVENT_HEADER_LEN ||
|
||||
data_len > current_thd->variables.max_allowed_packet)
|
||||
{
|
||||
|
||||
result= ((data_len < LOG_EVENT_HEADER_LEN) ? LOG_READ_BOGUS :
|
||||
@ -480,6 +481,7 @@ end:
|
||||
#ifndef MYSQL_CLIENT
|
||||
#define UNLOCK_MUTEX if (log_lock) pthread_mutex_unlock(log_lock);
|
||||
#define LOCK_MUTEX if (log_lock) pthread_mutex_lock(log_lock);
|
||||
#define max_allowed_packet current_thd->variables.max_allowed_packet
|
||||
#else
|
||||
#define UNLOCK_MUTEX
|
||||
#define LOCK_MUTEX
|
||||
@ -753,7 +755,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
|
||||
error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno),
|
||||
thread_id(thd_arg->thread_id),
|
||||
cache_stmt(using_trans &&
|
||||
(thd_arg->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)))
|
||||
(thd_arg->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
|
||||
{
|
||||
time_t end_time;
|
||||
time(&end_time);
|
||||
@ -1649,7 +1651,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
|
||||
{
|
||||
// master could be inconsistent, abort and tell DBA to check/fix it
|
||||
thd->db = thd->query = 0;
|
||||
thd->convert_set = 0;
|
||||
thd->variables.convert_set = 0;
|
||||
close_thread_tables(thd);
|
||||
free_root(&thd->mem_root,0);
|
||||
return 1;
|
||||
@ -1658,7 +1660,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
|
||||
thd->db= 0; // prevent db from being freed
|
||||
thd->query= 0; // just to be sure
|
||||
// assume no convert for next query unless set explictly
|
||||
thd->convert_set = 0;
|
||||
thd->variables.convert_set = 0;
|
||||
close_thread_tables(thd);
|
||||
|
||||
if (thd->query_error || thd->fatal_error)
|
||||
|
@ -214,8 +214,6 @@ class MYSQL_LOG;
|
||||
class THD;
|
||||
#endif
|
||||
|
||||
extern uint32 server_id;
|
||||
|
||||
struct st_relay_log_info;
|
||||
|
||||
class Log_event
|
||||
|
@ -20,12 +20,7 @@
|
||||
|
||||
Note: all file-global symbols must begin with mc_ , even the static ones, just
|
||||
in case we decide to make them external at some point
|
||||
*/
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define net_read_timeout net_read_timeout1
|
||||
#define net_write_timeout net_write_timeout1
|
||||
#endif
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
/* my_pthread must be included early to be able to fix things */
|
||||
@ -51,8 +46,6 @@
|
||||
#define ER CER
|
||||
#endif
|
||||
|
||||
extern ulong net_read_timeout;
|
||||
|
||||
extern "C" { // Because of SCO 3.2V4.2
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
@ -404,7 +397,8 @@ int mc_mysql_errno(MYSQL *mysql)
|
||||
return (mysql)->net.last_errno;
|
||||
}
|
||||
|
||||
my_bool mc_mysql_reconnect(MYSQL *mysql)
|
||||
|
||||
my_bool mc_mysql_reconnect(MYSQL *mysql)
|
||||
{
|
||||
MYSQL tmp_mysql;
|
||||
DBUG_ENTER("mc_mysql_reconnect");
|
||||
@ -415,8 +409,8 @@ my_bool mc_mysql_reconnect(MYSQL *mysql)
|
||||
mc_mysql_init(&tmp_mysql);
|
||||
tmp_mysql.options=mysql->options;
|
||||
if (!mc_mysql_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
|
||||
mysql->db, mysql->port, mysql->unix_socket,
|
||||
mysql->client_flag))
|
||||
mysql->db, mysql->port, mysql->unix_socket,
|
||||
mysql->client_flag, mysql->net.read_timeout))
|
||||
{
|
||||
tmp_mysql.reconnect=0;
|
||||
mc_mysql_close(&tmp_mysql);
|
||||
@ -489,8 +483,9 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command,
|
||||
|
||||
MYSQL *
|
||||
mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
const char *passwd, const char *db,
|
||||
uint port, const char *unix_socket,uint client_flag)
|
||||
const char *passwd, const char *db,
|
||||
uint port, const char *unix_socket,uint client_flag,
|
||||
uint net_read_timeout)
|
||||
{
|
||||
char buff[100],*end,*host_info;
|
||||
my_socket sock;
|
||||
@ -499,7 +494,8 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
ulong pkt_length;
|
||||
NET *net= &mysql->net;
|
||||
thr_alarm_t alarmed;
|
||||
ALARM alarm_buff;
|
||||
ALARM alarm_buff;
|
||||
ulong max_allowed_packet;
|
||||
|
||||
#ifdef __WIN__
|
||||
HANDLE hPipe=INVALID_HANDLE_VALUE;
|
||||
@ -514,7 +510,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
db ? db : "(Null)",
|
||||
user ? user : "(Null)"));
|
||||
thr_alarm_init(&alarmed);
|
||||
thr_alarm(&alarmed,(uint) net_read_timeout,&alarm_buff);
|
||||
thr_alarm(&alarmed, net_read_timeout, &alarm_buff);
|
||||
|
||||
bzero((char*) &mysql->options,sizeof(mysql->options));
|
||||
net->vio = 0; /* If something goes wrong */
|
||||
@ -778,6 +774,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
DBUG_PRINT("info", ("IO layer change done!"));
|
||||
}
|
||||
#endif /* HAVE_OPENSSL */
|
||||
max_allowed_packet=mysql->net.max_packet;
|
||||
int3store(buff+2,max_allowed_packet);
|
||||
|
||||
|
||||
|
@ -19,23 +19,18 @@
|
||||
|
||||
|
||||
MYSQL* mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
const char *passwd, const char *db,
|
||||
uint port, const char *unix_socket,uint client_flag);
|
||||
|
||||
int mc_simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
|
||||
uint length, my_bool skipp_check);
|
||||
const char *passwd, const char *db,
|
||||
uint port, const char *unix_socket,uint client_flag,
|
||||
uint net_read_timeout);
|
||||
int mc_simple_command(MYSQL *mysql,enum enum_server_command command,
|
||||
const char *arg, uint length, my_bool skipp_check);
|
||||
void mc_mysql_close(MYSQL *mysql);
|
||||
|
||||
MYSQL * mc_mysql_init(MYSQL *mysql);
|
||||
|
||||
MYSQL *mc_mysql_init(MYSQL *mysql);
|
||||
void mc_mysql_debug(const char *debug);
|
||||
|
||||
ulong mc_net_safe_read(MYSQL *mysql);
|
||||
|
||||
char * mc_mysql_error(MYSQL *mysql);
|
||||
char *mc_mysql_error(MYSQL *mysql);
|
||||
int mc_mysql_errno(MYSQL *mysql);
|
||||
my_bool mc_mysql_reconnect(MYSQL* mysql);
|
||||
|
||||
int mc_mysql_send_query(MYSQL* mysql, const char* query, uint length);
|
||||
int mc_mysql_read_query_result(MYSQL *mysql);
|
||||
int mc_mysql_query(MYSQL *mysql, const char *query, uint length);
|
||||
|
136
sql/mysql_priv.h
136
sql/mysql_priv.h
@ -14,14 +14,11 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifndef _MYSQL_PRIV_H
|
||||
#define _MYSQL_PRIV_H
|
||||
|
||||
#include <my_global.h>
|
||||
#include "mysql_embed.h"
|
||||
#include <mysql_version.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql_version.h>
|
||||
#include <hash.h>
|
||||
#include <signal.h>
|
||||
#include <thr_lock.h>
|
||||
@ -165,15 +162,14 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
|
||||
#define OPTION_BIG_SELECTS 1024 /* for SQL OPTION */
|
||||
#define OPTION_LOG_OFF 2048
|
||||
#define OPTION_UPDATE_LOG 4096 /* update log flag */
|
||||
#define OPTION_LOW_PRIORITY_UPDATES 8192
|
||||
#define OPTION_WARNINGS 16384
|
||||
#define OPTION_AUTO_IS_NULL 32768
|
||||
#define OPTION_FOUND_COMMENT 65536L
|
||||
#define OPTION_SAFE_UPDATES OPTION_FOUND_COMMENT*2
|
||||
#define OPTION_BUFFER_RESULT OPTION_SAFE_UPDATES*2
|
||||
#define OPTION_BIN_LOG OPTION_BUFFER_RESULT*2
|
||||
#define OPTION_NOT_AUTO_COMMIT OPTION_BIN_LOG*2
|
||||
#define OPTION_BEGIN OPTION_NOT_AUTO_COMMIT*2
|
||||
#define OPTION_NOT_AUTOCOMMIT OPTION_BIN_LOG*2
|
||||
#define OPTION_BEGIN OPTION_NOT_AUTOCOMMIT*2
|
||||
#define OPTION_TABLE_LOCK OPTION_BEGIN*2
|
||||
#define OPTION_QUICK OPTION_TABLE_LOCK*2
|
||||
#define OPTION_QUOTE_SHOW_CREATE OPTION_QUICK*2
|
||||
@ -295,6 +291,9 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags);
|
||||
int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists);
|
||||
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
bool log_query);
|
||||
int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables,
|
||||
bool if_exists,
|
||||
bool log_query);
|
||||
int quick_rm_table(enum db_type base,const char *db,
|
||||
const char *table_name);
|
||||
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list);
|
||||
@ -469,7 +468,7 @@ void mysqld_list_processes(THD *thd,const char *user,bool verbose);
|
||||
int mysqld_show_status(THD *thd);
|
||||
int mysqld_show_variables(THD *thd,const char *wild);
|
||||
int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
|
||||
struct system_variables *variable_values);
|
||||
enum enum_var_type value_type);
|
||||
|
||||
/* sql_handler.cc */
|
||||
int mysql_ha_open(THD *thd, TABLE_LIST *tables);
|
||||
@ -579,29 +578,66 @@ void open_log(MYSQL_LOG *log, const char *hostname,
|
||||
enum_log_type type, bool read_append = 0,
|
||||
bool no_auto_events = 0);
|
||||
|
||||
extern uint32 server_id;
|
||||
/*
|
||||
External variables
|
||||
*/
|
||||
|
||||
extern time_t start_time;
|
||||
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
|
||||
max_sort_char, mysql_real_data_home[];
|
||||
max_sort_char, mysql_real_data_home[], *charsets_list;
|
||||
extern my_string mysql_tmpdir;
|
||||
extern const char *command_name[];
|
||||
extern const char *first_keyword, *localhost, *delayed_user;
|
||||
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables,
|
||||
created_tmp_tables, created_tmp_disk_tables,
|
||||
aborted_threads,aborted_connects,
|
||||
delayed_insert_timeout,
|
||||
delayed_insert_limit, delayed_queue_size,
|
||||
delayed_insert_threads, delayed_insert_writes,
|
||||
delayed_rows_in_use,delayed_insert_errors;
|
||||
extern const char **errmesg; /* Error messages */
|
||||
extern const char *myisam_recover_options_str;
|
||||
extern uchar *days_in_month;
|
||||
extern char language[LIBLEN],reg_ext[FN_EXTLEN];
|
||||
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
|
||||
extern char pidfile_name[FN_REFLEN], time_zone[30], *opt_init_file;
|
||||
extern char blob_newline;
|
||||
extern double log_10[32];
|
||||
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables;
|
||||
extern ulong created_tmp_tables, created_tmp_disk_tables;
|
||||
extern ulong aborted_threads,aborted_connects;
|
||||
extern ulong delayed_insert_timeout;
|
||||
extern ulong delayed_insert_limit, delayed_queue_size;
|
||||
extern ulong delayed_insert_threads, delayed_insert_writes;
|
||||
extern ulong delayed_rows_in_use,delayed_insert_errors;
|
||||
extern ulong filesort_rows, filesort_range_count, filesort_scan_count;
|
||||
extern ulong filesort_merge_passes;
|
||||
extern ulong select_range_check_count, select_range_count, select_scan_count;
|
||||
extern ulong select_full_range_join_count,select_full_join_count,
|
||||
slave_open_temp_tables;
|
||||
extern uint test_flags,select_errors,ha_open_options;
|
||||
extern ulong select_full_range_join_count,select_full_join_count;
|
||||
extern ulong slave_open_temp_tables, query_cache_size;
|
||||
extern ulong thd_startup_options, slow_launch_threads, slow_launch_time;
|
||||
extern ulong query_cache_startup_type;
|
||||
extern time_t start_time;
|
||||
extern const char *command_name[];
|
||||
extern I_List<THD> threads;
|
||||
extern ulong server_id;
|
||||
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count;
|
||||
extern ulong ha_read_key_count, ha_read_next_count, ha_read_prev_count;
|
||||
extern ulong ha_read_first_count, ha_read_last_count;
|
||||
extern ulong ha_read_rnd_count, ha_read_rnd_next_count;
|
||||
extern ulong ha_commit_count, ha_rollback_count, mysqld_net_retry_count;
|
||||
extern ulong keybuff_size,table_cache_size;
|
||||
extern ulong max_connections,max_connect_errors, connect_timeout;
|
||||
extern ulong max_insert_delayed_threads, max_user_connections;
|
||||
extern ulong long_query_count, what_to_log,flush_time,opt_sql_mode;
|
||||
extern ulong query_buff_size, thread_stack,thread_stack_min;
|
||||
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
|
||||
extern ulong max_binlog_size, rpl_recovery_rank, thread_cache_size;
|
||||
extern ulong com_stat[(uint) SQLCOM_END], com_other, back_log;
|
||||
extern ulong specialflag, current_pid;
|
||||
|
||||
extern uint test_flags,select_errors,ha_open_options;
|
||||
extern uint protocol_version,dropping_tables;
|
||||
extern bool opt_endinfo, using_udf_functions, locked_in_memory;
|
||||
extern bool opt_using_transactions, use_temp_pool, mysql_embedded;
|
||||
extern bool using_update_log, opt_large_files;
|
||||
extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
|
||||
extern bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
|
||||
extern bool opt_disable_networking, opt_skip_show_db;
|
||||
extern bool volatile abort_loop, shutdown_in_progress, grant_option;
|
||||
extern uint volatile thread_count, thread_running, global_read_lock;
|
||||
extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names;
|
||||
extern char f_fyllchar;
|
||||
|
||||
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
|
||||
extern FILE *bootstrap_file;
|
||||
extern pthread_key(MEM_ROOT*,THR_MALLOC);
|
||||
@ -613,53 +649,22 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
|
||||
LOCK_server_id, LOCK_slave_list, LOCK_active_mi, LOCK_manager,
|
||||
LOCK_global_system_variables;
|
||||
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
|
||||
|
||||
extern pthread_attr_t connection_attrib;
|
||||
extern bool opt_endinfo, using_udf_functions, locked_in_memory,
|
||||
opt_using_transactions, use_temp_pool, mysql_embedded;
|
||||
extern char f_fyllchar;
|
||||
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
|
||||
ha_read_key_count, ha_read_next_count, ha_read_prev_count,
|
||||
ha_read_first_count, ha_read_last_count,
|
||||
ha_read_rnd_count, ha_read_rnd_next_count,
|
||||
ha_commit_count, ha_rollback_count;
|
||||
extern I_List<THD> threads;
|
||||
extern MY_BITMAP temp_pool;
|
||||
extern uchar *days_in_month;
|
||||
extern DATE_FORMAT dayord;
|
||||
extern double log_10[32];
|
||||
extern uint protocol_version,dropping_tables;
|
||||
extern ulong keybuff_size,table_cache_size,
|
||||
max_connections,max_connect_errors,
|
||||
max_insert_delayed_threads, max_user_connections,
|
||||
long_query_count,
|
||||
net_read_timeout,net_write_timeout,
|
||||
what_to_log,flush_time,opt_sql_mode,
|
||||
query_buff_size, lower_case_table_names,
|
||||
thread_stack,thread_stack_min,
|
||||
binlog_cache_size, max_binlog_cache_size;
|
||||
extern ulong com_stat[(uint) SQLCOM_END], com_other;
|
||||
extern ulong specialflag, current_pid;
|
||||
extern bool low_priority_updates, using_update_log;
|
||||
extern bool opt_sql_bin_update, opt_safe_show_db,
|
||||
opt_safe_user_create, opt_no_mix_types;
|
||||
extern char language[LIBLEN],reg_ext[FN_EXTLEN],blob_newline;
|
||||
extern const char **errmesg; /* Error messages */
|
||||
extern const char *default_tx_isolation_name;
|
||||
extern String empty_string;
|
||||
extern struct show_var_st init_vars[];
|
||||
extern struct show_var_st status_vars[];
|
||||
extern SHOW_VAR init_vars[],status_vars[], internal_vars[];
|
||||
extern struct system_variables global_system_variables;
|
||||
extern enum db_type default_table_type;
|
||||
extern enum enum_tx_isolation default_tx_isolation;
|
||||
extern char glob_hostname[FN_REFLEN];
|
||||
extern struct system_variables max_system_variables;
|
||||
|
||||
extern SHOW_COMP_OPTION have_isam, have_raid, have_openssl, have_symlink;
|
||||
extern SHOW_COMP_OPTION have_query_cache;
|
||||
|
||||
#ifndef __WIN__
|
||||
extern pthread_t signal_thread;
|
||||
#endif
|
||||
|
||||
extern bool volatile abort_loop, shutdown_in_progress, grant_option;
|
||||
extern uint volatile thread_count, thread_running, global_read_lock;
|
||||
|
||||
MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **table,uint count);
|
||||
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
|
||||
void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
|
||||
@ -757,11 +762,14 @@ void hostname_cache_free();
|
||||
void hostname_cache_refresh(void);
|
||||
bool get_interval_info(const char *str,uint length,uint count,
|
||||
long *values);
|
||||
/* sql_cache */
|
||||
/* sql_cache.cc */
|
||||
extern bool sql_cache_init();
|
||||
extern void sql_cache_free();
|
||||
extern int sql_cache_hit(THD *thd, char *inBuf, uint length);
|
||||
|
||||
/* item.cc */
|
||||
Item *get_system_var(enum_var_type var_type, LEX_STRING name);
|
||||
|
||||
/* Some inline functions for more speed */
|
||||
|
||||
inline bool add_item_to_list(Item *item)
|
||||
@ -786,5 +794,3 @@ inline void mark_as_null_row(TABLE *table)
|
||||
table->status|=STATUS_NULL_ROW;
|
||||
bfill(table->null_flags,table->null_bytes,255);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
529
sql/mysqld.cc
529
sql/mysqld.cc
@ -15,7 +15,6 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "mysql_priv.h"
|
||||
#include <mysql.h>
|
||||
#include <m_ctype.h>
|
||||
#include <my_dir.h>
|
||||
#include "sql_acl.h"
|
||||
@ -240,31 +239,41 @@ SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_YES;
|
||||
SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_NO;
|
||||
#endif
|
||||
|
||||
bool opt_skip_slave_start = 0; // If set, slave is not autostarted
|
||||
bool opt_large_files= sizeof(my_off_t) > 4;
|
||||
|
||||
/*
|
||||
Variables to store startup options
|
||||
*/
|
||||
|
||||
bool opt_skip_slave_start = 0; // If set, slave is not autostarted
|
||||
/*
|
||||
If set, some standard measures to enforce slave data integrity will not
|
||||
be performed
|
||||
*/
|
||||
bool opt_reckless_slave = 0;
|
||||
|
||||
ulong back_log, connect_timeout;
|
||||
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
|
||||
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
|
||||
bool opt_disable_networking=0, opt_skip_show_db=0;
|
||||
my_bool opt_local_infile;
|
||||
|
||||
static bool opt_do_pstack = 0;
|
||||
static ulong opt_specialflag=SPECIAL_ENGLISH;
|
||||
static ulong back_log,connect_timeout,concurrency;
|
||||
static ulong concurrency;
|
||||
static ulong opt_myisam_block_size;
|
||||
static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET;
|
||||
static my_string opt_logname=0,opt_update_logname=0,
|
||||
opt_binlog_index_name = 0,opt_slow_logname=0;
|
||||
static char mysql_home[FN_REFLEN],pidfile_name[FN_REFLEN];
|
||||
|
||||
static char* mysql_home_ptr= mysql_home;
|
||||
static char* pidfile_name_ptr= pidfile_name;
|
||||
static pthread_t select_thread;
|
||||
static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl,
|
||||
opt_disable_networking=0, opt_bootstrap=0,opt_skip_show_db=0,
|
||||
opt_myisam_log=0,
|
||||
opt_large_files=sizeof(my_off_t) > 4;
|
||||
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0, opt_safe_show_db=0,
|
||||
opt_show_slave_auth_info = 0, opt_old_rpl_compat = 0,
|
||||
opt_safe_user_create = 0, opt_no_mix_types = 0;
|
||||
static bool opt_noacl, opt_bootstrap=0, opt_myisam_log=0;
|
||||
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0;
|
||||
bool opt_safe_user_create = 0, opt_no_mix_types = 0;
|
||||
my_bool opt_safe_show_db=0, lower_case_table_names, opt_old_rpl_compat;
|
||||
my_bool opt_show_slave_auth_info;
|
||||
volatile bool mqh_used = 0;
|
||||
FILE *bootstrap_file=0;
|
||||
int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice
|
||||
@ -277,8 +286,7 @@ int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice
|
||||
static bool kill_in_progress=FALSE;
|
||||
static struct rand_struct sql_rand;
|
||||
static int cleanup_done;
|
||||
static char **defaults_argv,time_zone[30];
|
||||
static const char *default_table_type_name;
|
||||
static char **defaults_argv;
|
||||
char glob_hostname[FN_REFLEN];
|
||||
|
||||
#include "sslopt-vars.h"
|
||||
@ -293,7 +301,7 @@ I_List<i_string> replicate_do_db, replicate_ignore_db;
|
||||
I_List<i_string> binlog_do_db, binlog_ignore_db;
|
||||
|
||||
/* if we guessed server_id , we need to know about it */
|
||||
uint32 server_id = 0;
|
||||
ulong server_id= 0; // Must be long becasue of set_var.cc
|
||||
bool server_id_supplied = 0;
|
||||
|
||||
uint mysql_port;
|
||||
@ -308,16 +316,16 @@ struct system_variables max_system_variables;
|
||||
ulong keybuff_size,table_cache_size,
|
||||
thread_stack,
|
||||
thread_stack_min,what_to_log= ~ (1L << (uint) COM_TIME),
|
||||
query_buff_size, lower_case_table_names, mysqld_net_retry_count,
|
||||
query_buff_size, mysqld_net_retry_count,
|
||||
slow_launch_time = 2L,
|
||||
net_read_timeout,net_write_timeout,slave_open_temp_tables=0,
|
||||
slave_open_temp_tables=0,
|
||||
open_files_limit=0, max_binlog_size;
|
||||
ulong com_stat[(uint) SQLCOM_END], com_other;
|
||||
ulong slave_net_timeout;
|
||||
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
|
||||
ulong query_cache_size=0;
|
||||
#ifdef HAVE_QUERY_CACHE
|
||||
ulong query_cache_limit=0, query_cache_startup_type=1;
|
||||
ulong query_cache_limit=0;
|
||||
Query_cache query_cache;
|
||||
#endif
|
||||
|
||||
@ -339,7 +347,7 @@ bool master_ssl = 0;
|
||||
ulong master_retry_count=0;
|
||||
ulong bytes_sent = 0L, bytes_received = 0L;
|
||||
|
||||
bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory;
|
||||
bool opt_endinfo,using_udf_functions, locked_in_memory;
|
||||
bool opt_using_transactions, using_update_log;
|
||||
bool volatile abort_loop,select_thread_in_use,grant_option;
|
||||
bool volatile ready_to_exit,shutdown_in_progress;
|
||||
@ -361,11 +369,10 @@ ulong slow_launch_threads = 0;
|
||||
|
||||
char mysql_real_data_home[FN_REFLEN],
|
||||
language[LIBLEN],reg_ext[FN_EXTLEN],
|
||||
default_charset[LIBLEN],mysql_charsets_dir[FN_REFLEN], *charsets_list,
|
||||
mysql_charsets_dir[FN_REFLEN], *charsets_list,
|
||||
blob_newline,f_fyllchar,max_sort_char,*mysqld_user,*mysqld_chroot,
|
||||
*opt_init_file;
|
||||
char *language_ptr= language;
|
||||
char *default_charset_ptr= default_charset;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
char mysql_data_home_buff[2], *mysql_data_home=mysql_data_home_buff;
|
||||
bool mysql_embedded=0;
|
||||
@ -381,12 +388,9 @@ const char *first_keyword="first";
|
||||
const char **errmesg; /* Error messages */
|
||||
const char *myisam_recover_options_str="OFF";
|
||||
const char *sql_mode_str="OFF";
|
||||
const char *default_tx_isolation_name;
|
||||
enum_tx_isolation default_tx_isolation=ISO_READ_COMMITTED;
|
||||
ulong rpl_recovery_rank=0;
|
||||
|
||||
uint rpl_recovery_rank=0;
|
||||
|
||||
my_string mysql_unix_port=NULL, mysql_tmpdir=NULL, allocated_mysql_tmpdir=NULL;
|
||||
my_string mysql_unix_port=NULL, opt_mysql_tmpdir=NULL, mysql_tmpdir=NULL;
|
||||
ulong my_bind_addr; /* the address we bind to */
|
||||
DATE_FORMAT dayord;
|
||||
double log_10[32]; /* 10 potences */
|
||||
@ -414,12 +418,11 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
|
||||
LOCK_server_id, LOCK_global_system_variables,
|
||||
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
|
||||
|
||||
pthread_cond_t COND_refresh,COND_thread_count,COND_binlog_update,
|
||||
COND_slave_stopped, COND_slave_start;
|
||||
pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped,
|
||||
COND_slave_start;
|
||||
pthread_cond_t COND_thread_cache,COND_flush_thread_cache;
|
||||
pthread_t signal_thread;
|
||||
pthread_attr_t connection_attrib;
|
||||
enum db_type default_table_type=DB_TYPE_MYISAM;
|
||||
|
||||
#ifdef __WIN__
|
||||
#undef getpid
|
||||
@ -766,7 +769,7 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
|
||||
|
||||
static sig_handler print_signal_warning(int sig)
|
||||
{
|
||||
if (current_thd->variables.opt_warnings)
|
||||
if (global_system_variables.log_warnings)
|
||||
sql_print_error("Warning: Got signal %d from thread %d",
|
||||
sig,my_thread_id());
|
||||
#ifdef DONT_REMEMBER_SIGNAL
|
||||
@ -813,6 +816,7 @@ void clean_up(bool print_message)
|
||||
hostname_cache_free();
|
||||
item_user_lock_free();
|
||||
lex_free(); /* Free some memory */
|
||||
set_var_free();
|
||||
#ifdef HAVE_DLOPEN
|
||||
if (!opt_noacl)
|
||||
udf_free();
|
||||
@ -832,9 +836,10 @@ void clean_up(bool print_message)
|
||||
opt_ssl_key=opt_ssl_cert=opt_ssl_ca=opt_ssl_capath=0;
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
free_defaults(defaults_argv);
|
||||
if (defaults_argv)
|
||||
free_defaults(defaults_argv);
|
||||
my_free(charsets_list, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(allocated_mysql_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
x_free(opt_bin_logname);
|
||||
x_free(opt_relay_logname);
|
||||
@ -1048,8 +1053,8 @@ static void server_init(void)
|
||||
PIPE_READMODE_BYTE |
|
||||
PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
(int) net_buffer_length,
|
||||
(int) net_buffer_length,
|
||||
(int) global_variables.net_buffer_length,
|
||||
(int) global_variables.net_buffer_length,
|
||||
NMPWAIT_USE_DEFAULT_WAIT,
|
||||
&saPipeSecurity )) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -1334,14 +1339,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\
|
||||
the problem, but since we have already crashed, something is definitely wrong\n\
|
||||
and this may fail.\n\n");
|
||||
fprintf(stderr, "key_buffer_size=%ld\n", keybuff_size);
|
||||
fprintf(stderr, "record_buffer=%ld\n", my_default_record_cache_size);
|
||||
fprintf(stderr, "sort_buffer=%ld\n", thd->variables.sortbuff_size);
|
||||
fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size);
|
||||
fprintf(stderr, "sort_buffer_size=%ld\n", thd->variables.sortbuff_size);
|
||||
fprintf(stderr, "max_used_connections=%ld\n", max_used_connections);
|
||||
fprintf(stderr, "max_connections=%ld\n", max_connections);
|
||||
fprintf(stderr, "threads_connected=%d\n", thread_count);
|
||||
fprintf(stderr, "It is possible that mysqld could use up to \n\
|
||||
key_buffer_size + (record_buffer + sort_buffer)*max_connections = %ld K\n\
|
||||
bytes of memory\n", (keybuff_size + (my_default_record_cache_size +
|
||||
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\
|
||||
bytes of memory\n", (keybuff_size + (global_system_variables.read_buff_size +
|
||||
thd->variables.sortbuff_size) *
|
||||
max_connections)/ 1024);
|
||||
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
|
||||
@ -1793,15 +1798,17 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
load_defaults("my",load_default_groups,&argc,&argv);
|
||||
defaults_argv=argv;
|
||||
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(argc,argv);
|
||||
@ -1841,7 +1848,7 @@ int main(int argc, char **argv)
|
||||
(void) pthread_cond_init(&COND_rpl_status, NULL);
|
||||
init_signals();
|
||||
|
||||
if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
|
||||
if (set_default_charset_by_name(sys_charset.value, MYF(MY_WME)))
|
||||
exit(1);
|
||||
charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS));
|
||||
|
||||
@ -1900,6 +1907,7 @@ int main(int argc, char **argv)
|
||||
init_errmessage(); /* Read error messages from file */
|
||||
lex_init();
|
||||
item_init();
|
||||
set_var_init();
|
||||
mysys_uses_curses=0;
|
||||
#ifdef USE_REGEX
|
||||
regex_init();
|
||||
@ -2284,10 +2292,11 @@ static int bootstrap(FILE *file)
|
||||
{
|
||||
THD *thd= new THD;
|
||||
int error;
|
||||
|
||||
thd->bootstrap=1;
|
||||
thd->client_capabilities=0;
|
||||
my_net_init(&thd->net,(st_vio*) 0);
|
||||
thd->max_packet_length=thd->net.max_packet;
|
||||
thd->max_client_packet_length= thd->net.max_packet;
|
||||
thd->master_access= ~0;
|
||||
thd->thread_id=thread_id++;
|
||||
thread_count++;
|
||||
@ -2332,7 +2341,7 @@ static void create_new_thread(THD *thd)
|
||||
DBUG_ENTER("create_new_thread");
|
||||
|
||||
NET *net=&thd->net; // For easy ref
|
||||
net->timeout = (uint) connect_timeout; // Timeout for read
|
||||
net->read_timeout = (uint) connect_timeout;
|
||||
if (protocol_version > 9)
|
||||
net->return_errno=1;
|
||||
|
||||
@ -2663,8 +2672,8 @@ pthread_handler_decl(handle_connections_namedpipes,arg)
|
||||
PIPE_READMODE_BYTE |
|
||||
PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
(int) net_buffer_length,
|
||||
(int) net_buffer_length,
|
||||
(int) global_variables.net_buffer_length,
|
||||
(int) global_variables.net_buffer_length,
|
||||
NMPWAIT_USE_DEFAULT_WAIT,
|
||||
&saPipeSecurity )) ==
|
||||
INVALID_HANDLE_VALUE )
|
||||
@ -2681,8 +2690,8 @@ pthread_handler_decl(handle_connections_namedpipes,arg)
|
||||
PIPE_READMODE_BYTE |
|
||||
PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
(int) net_buffer_length,
|
||||
(int) net_buffer_length,
|
||||
(int) global_variables.net_buffer_length,
|
||||
(int) global_variables.net_buffer_length,
|
||||
NMPWAIT_USE_DEFAULT_WAIT,
|
||||
&saPipeSecurity)) ==
|
||||
INVALID_HANDLE_VALUE)
|
||||
@ -2800,14 +2809,14 @@ enum options {
|
||||
OPT_MAX_DELAYED_THREADS, OPT_MAX_HEP_TABLE_SIZE,
|
||||
OPT_MAX_JOIN_SIZE, OPT_MAX_SORT_LENGTH,
|
||||
OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
|
||||
OPT_MAX_WRITE_LOCK_COUNT, OPT_MYISAM_BULK_INSERT_TREE_SIZE,
|
||||
OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
|
||||
OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
|
||||
OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
|
||||
OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT,
|
||||
OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
|
||||
OPT_OPEN_FILES_LIMIT, OPT_QUERY_BUFFER_SIZE,
|
||||
OPT_OPEN_FILES_LIMIT,
|
||||
OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE,
|
||||
OPT_QUERY_CACHE_STARTUP_TYPE, OPT_RECORD_BUFFER,
|
||||
OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER,
|
||||
OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT,
|
||||
OPT_SLAVE_NET_TIMEOUT, OPT_SLOW_LAUNCH_TIME,
|
||||
OPT_SORT_BUFFER, OPT_TABLE_CACHE,
|
||||
@ -2832,7 +2841,7 @@ enum options {
|
||||
|
||||
#define LONG_TIMEOUT ((ulong) 3600L*24L*365L)
|
||||
|
||||
static struct my_option my_long_options[] =
|
||||
struct my_option my_long_options[] =
|
||||
{
|
||||
{"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -2911,12 +2920,11 @@ static struct my_option my_long_options[] =
|
||||
0, 0, 0, 0, 0, 0},
|
||||
#endif /* HAVE_OPENSSL */
|
||||
{"default-character-set", 'C', "Set the default character set",
|
||||
(gptr*) &default_charset_ptr, (gptr*) &default_charset_ptr, 0, GET_STR,
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
(gptr*) &sys_charset.value, (gptr*) &sys_charset.value, 0, GET_STR,
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
||||
{"default-table-type", OPT_TABLE_TYPE,
|
||||
"Set the default table type for tables", (gptr*) &default_table_type_name,
|
||||
(gptr*) &default_table_type_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0,
|
||||
0},
|
||||
"Set the default table type for tables", 0, 0,
|
||||
0, GET_NO_ARG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE,
|
||||
"Don't flush key buffers between writes for any MyISAM table", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -2980,8 +2988,8 @@ static struct my_option my_long_options[] =
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"local-infile", OPT_LOCAL_INFILE,
|
||||
"Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)",
|
||||
(gptr*) &global_system_variables.opt_local_infile,
|
||||
(gptr*) &max_system_variables.opt_local_infile, 0, GET_BOOL, OPT_ARG,
|
||||
(gptr*) &opt_local_infile,
|
||||
(gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
|
||||
1, 0, 0, 0, 0, 0},
|
||||
{"log-bin", OPT_BIN_LOG,
|
||||
"Log queries in new binary format (for replication)",
|
||||
@ -3006,12 +3014,14 @@ static struct my_option my_long_options[] =
|
||||
"Log some extra information to update log", 0, 0, 0, GET_NO_ARG, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
|
||||
"Tells the slave to log the updates from the slave thread to the binary log. Off by default. You will need to turn it on if you plan to daisy-chain the slaves.",
|
||||
"Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
|
||||
(gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"low-priority-updates", OPT_LOW_PRIORITY_UPDATES,
|
||||
"INSERT/DELETE/UPDATE has lower priority than selects", 0, 0, 0, GET_NO_ARG,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
"INSERT/DELETE/UPDATE has lower priority than selects",
|
||||
(gptr*) &global_system_variables.low_priority_updates,
|
||||
(gptr*) &max_system_variables.low_priority_updates,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"master-host", OPT_MASTER_HOST,
|
||||
"Master hostname or IP address for replication. If not set, the slave thread will not be started. Note that the setting of master-host will be ignored if there exists a valid master.info file.",
|
||||
(gptr*) &master_host, (gptr*) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
|
||||
@ -3083,14 +3093,15 @@ static struct my_option my_long_options[] =
|
||||
{"new", 'n', "Use very new possible 'unsafe' functions", 0, 0, 0, GET_NO_ARG,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef NOT_YET
|
||||
{"no-mix-table-types", OPT_NO_MIX_TYPE, "Undocumented",
|
||||
{"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different table types",
|
||||
(gptr*) &opt_no_mix_types, (gptr*) &opt_no_mix_types, 0, GET_BOOL, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"old-protocol", 'o', "Use the old (3.20) protocol",
|
||||
(gptr*) &protocol_version, (gptr*) &protocol_version, 0, GET_UINT, NO_ARG,
|
||||
PROTOCOL_VERSION, 0, 0, 0, 0, 0},
|
||||
{"old-rpl-compat", OPT_OLD_RPL_COMPAT, "Undocumented",
|
||||
{"old-rpl-compat", OPT_OLD_RPL_COMPAT,
|
||||
"Use old LOAD DATA format in the binary log (don't save data in file)",
|
||||
(gptr*) &opt_old_rpl_compat, (gptr*) &opt_old_rpl_compat, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef ONE_THREAD
|
||||
@ -3103,7 +3114,7 @@ static struct my_option my_long_options[] =
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"port", 'P', "Port number to use for connection.", (gptr*) &mysql_port,
|
||||
(gptr*) &mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"reckless-slave", OPT_RECKLESS_SLAVE, "Undocumented", 0, 0, 0, GET_NO_ARG,
|
||||
{"reckless-slave", OPT_RECKLESS_SLAVE, "For debugging", 0, 0, 0, GET_NO_ARG,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"replicate-do-db", OPT_REPLICATE_DO_DB,
|
||||
"Tells the slave thread to restrict replication to the specified database. To specify more than one database, use the directive multiple times, once for each database. Note that this will only work if you do not use cross-database queries such as UPDATE some_db.some_table SET foo='bar' while having selected a different or no database. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-do-table=db_name.%.",
|
||||
@ -3151,28 +3162,31 @@ static struct my_option my_long_options[] =
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifndef TO_BE_DELETED
|
||||
{"safe-show-database", OPT_SAFE_SHOW_DB,
|
||||
"Depricated option; One should use GRANT SHOW DATABASES instead...",
|
||||
(gptr*) &opt_safe_show_db, (gptr*) &opt_safe_show_db, 0, GET_BOOL, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"safe-user-create", OPT_SAFE_USER_CREATE,
|
||||
"Don't allow new user creation by the user who has no write privileges to the mysql.user table",
|
||||
(gptr*) &opt_safe_user_create, (gptr*) &opt_safe_user_create, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"server-id", OPT_SERVER_ID,
|
||||
"Uniquely identifies the server instance in the community of replication partners",
|
||||
(gptr*) &server_id, (gptr*) &server_id, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0,
|
||||
(gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
{"set-variable", 'O',
|
||||
"Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO, "Undocumented",
|
||||
{"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO,
|
||||
"Show user and password in SHOW SLAVE STATUS",
|
||||
(gptr*) &opt_show_slave_auth_info, (gptr*) &opt_show_slave_auth_info, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"concurrent-insert", OPT_CONCURRENT_INSERT,
|
||||
"Use concurrent insert with MyISAM. Disable with prefix --skip-",
|
||||
(gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"delay-key-write", OPT_USE_DELAY_KEY_WRITE,
|
||||
"Use delay_key_write option for all tables. Disable with prefix --skip-",
|
||||
(gptr*) &myisam_delay_key_write, (gptr*) &myisam_delay_key_write, 0,
|
||||
@ -3237,11 +3251,11 @@ static struct my_option my_long_options[] =
|
||||
"Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.",
|
||||
(gptr*) &use_temp_pool, (gptr*) &use_temp_pool, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"tmpdir", 't', "Path for temporary files", (gptr*) &mysql_tmpdir,
|
||||
(gptr*) &mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"tmpdir", 't', "Path for temporary files", (gptr*) &opt_mysql_tmpdir,
|
||||
(gptr*) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"transaction-isolation", OPT_TX_ISOLATION,
|
||||
"Default transaction isolation level", (gptr*) &default_tx_isolation_name,
|
||||
(gptr*) &default_tx_isolation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
|
||||
"Default transaction isolation level", 0, 0, 0, GET_NO_ARG, REQUIRED_ARG, 0,
|
||||
0, 0, 0,
|
||||
0, 0},
|
||||
{"use-locking", OPT_USE_LOCKING, "Use system (external) locking",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -3256,9 +3270,13 @@ static struct my_option my_long_options[] =
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"version", 'v', "Synonym for option -v", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"warnings", 'W', "Log some not critical warnings to the log file",
|
||||
(gptr*) &global_system_variables.opt_warnings,
|
||||
(gptr*) &max_system_variables.opt_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||
{"log-warnings", 'W', "Log some not critical warnings to the log file",
|
||||
(gptr*) &global_system_variables.log_warnings,
|
||||
(gptr*) &max_system_variables.log_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
{"warnings", 'W', "Deprecated ; Use --log-warnings instead",
|
||||
(gptr*) &global_system_variables.log_warnings,
|
||||
(gptr*) &max_system_variables.log_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
{ "back_log", OPT_BACK_LOG,
|
||||
"The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.", (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG,
|
||||
@ -3287,8 +3305,8 @@ static struct my_option my_long_options[] =
|
||||
REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
|
||||
{"connect_timeout", OPT_CONNECT_TIMEOUT,
|
||||
"The number of seconds the mysqld server is waiting for a connect packet before responding with Bad handshake",
|
||||
(gptr*) &connect_timeout, (gptr*) &connect_timeout, 0, GET_ULONG,
|
||||
REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
|
||||
(gptr*) &connect_timeout, (gptr*) &connect_timeout,
|
||||
0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
|
||||
{"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT,
|
||||
"How long a INSERT DELAYED thread should wait for INSERT statements before terminating.",
|
||||
(gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0,
|
||||
@ -3385,11 +3403,11 @@ static struct my_option my_long_options[] =
|
||||
"If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive.",
|
||||
(gptr*) &lower_case_table_names,
|
||||
(gptr*) &lower_case_table_names, 0,
|
||||
GET_ULONG, REQUIRED_ARG, IF_WIN(1,0), 0, 1, 0, 1, 0},
|
||||
GET_BOOL, REQUIRED_ARG, IF_WIN(1,0), 0, 1, 0, 1, 0},
|
||||
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
|
||||
"Max packetlength to send/receive from to server.",
|
||||
(gptr*) &max_allowed_packet,
|
||||
(gptr*) &max_allowed_packet, 0, GET_ULONG,
|
||||
(gptr*) &global_system_variables.max_allowed_packet,
|
||||
(gptr*) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
|
||||
{"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
|
||||
"Can be used to restrict the total size used to cache a multi-transaction query.",
|
||||
@ -3423,8 +3441,8 @@ static struct my_option my_long_options[] =
|
||||
~0L, 1, ~0L, 0, 1, 0},
|
||||
{"max_sort_length", OPT_MAX_SORT_LENGTH,
|
||||
"The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).",
|
||||
(gptr*) &global_system_variables.max_item_sort_length,
|
||||
(gptr*) &max_system_variables.max_item_sort_length, 0, GET_ULONG,
|
||||
(gptr*) &global_system_variables.max_sort_length,
|
||||
(gptr*) &max_system_variables.max_sort_length, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
|
||||
{"max_tmp_tables", OPT_MAX_TMP_TABLES,
|
||||
"Maximum number of temporary tables a client can keep open at a time.",
|
||||
@ -3439,58 +3457,56 @@ static struct my_option my_long_options[] =
|
||||
"After this many write locks, allow some read locks to run in between.",
|
||||
(gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG,
|
||||
REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0},
|
||||
{"myisam_bulk_insert_tree_size", OPT_MYISAM_BULK_INSERT_TREE_SIZE,
|
||||
{"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
|
||||
"Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!",
|
||||
(gptr*) &myisam_bulk_insert_tree_size,
|
||||
(gptr*) &myisam_bulk_insert_tree_size,
|
||||
(gptr*) &global_system_variables.bulk_insert_buff_size,
|
||||
(gptr*) &max_system_variables.bulk_insert_buff_size,
|
||||
0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0},
|
||||
{"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
|
||||
"Undocumented", (gptr*) &opt_myisam_block_size,
|
||||
"Block size to be used for MyISAM index pages",
|
||||
(gptr*) &opt_myisam_block_size,
|
||||
(gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
|
||||
MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH,
|
||||
0, MI_MIN_KEY_BLOCK_LENGTH, 0},
|
||||
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
|
||||
"Used to help MySQL to decide when to use the slow but safe key cache index create method. Note that this parameter is given in megabytes!",
|
||||
"Used to help MySQL to decide when to use the slow but safe key cache index create method",
|
||||
(gptr*) &global_system_variables.myisam_max_extra_sort_file_size,
|
||||
(gptr*) &max_system_variables.myisam_max_extra_sort_file_size,
|
||||
0, GET_ULONG, REQUIRED_ARG, (long) (MI_MAX_TEMP_LENGTH/(1024L*1024L)),
|
||||
0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH,
|
||||
0, ~0L, 0, 1, 0},
|
||||
{"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
|
||||
"Don't use the fast sort index method to created index if the temporary file would get bigger than this. Note that this paramter is given in megabytes!",
|
||||
"Don't use the fast sort index method to created index if the temporary file would get bigger than this!",
|
||||
(gptr*) &global_system_variables.myisam_max_sort_file_size,
|
||||
(gptr*) &max_system_variables.myisam_max_sort_file_size, 0,
|
||||
GET_ULONG, REQUIRED_ARG, (long) (LONG_MAX/(1024L*1024L)), 0, ~0L, 0, 1, 0},
|
||||
GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, ~0L, 0, 1024*1024, 0},
|
||||
{"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
|
||||
"The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
|
||||
(gptr*) &myisam_sort_buffer_size, (gptr*) &myisam_sort_buffer_size, 0,
|
||||
(gptr*) &global_system_variables.myisam_sort_buff_size,
|
||||
(gptr*) &max_system_variables.myisam_sort_buff_size, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
|
||||
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
|
||||
"Buffer for TCP/IP and socket communication.",
|
||||
(gptr*) &net_buffer_length,
|
||||
(gptr*) &net_buffer_length, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 16384, 1024, 1024*1024L, MALLOC_OVERHEAD, 1024, 0},
|
||||
"Buffer length for TCP/IP and socket communication.",
|
||||
(gptr*) &global_system_variables.net_buffer_length,
|
||||
(gptr*) &max_system_variables.net_buffer_length, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
|
||||
{"net_retry_count", OPT_NET_RETRY_COUNT,
|
||||
"If a read on a communication port is interrupted, retry this many times before giving up.",
|
||||
(gptr*) &mysqld_net_retry_count, (gptr*) &mysqld_net_retry_count, 0,
|
||||
GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0},
|
||||
{"net_read_timeout", OPT_NET_READ_TIMEOUT,
|
||||
"Number of seconds to wait for more data from a connection before aborting the read.",
|
||||
(gptr*) &net_read_timeout,
|
||||
(gptr*) &net_read_timeout, 0, GET_ULONG,
|
||||
(gptr*) &global_system_variables.net_read_timeout,
|
||||
(gptr*) &max_system_variables.net_read_timeout, 0, GET_ULONG,
|
||||
REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
|
||||
{"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
|
||||
"Number of seconds to wait for a block to be written to a connection before aborting the write.",
|
||||
(gptr*) &net_write_timeout,
|
||||
(gptr*) &net_write_timeout, 0, GET_ULONG,
|
||||
(gptr*) &global_system_variables.net_write_timeout,
|
||||
(gptr*) &max_system_variables.net_write_timeout, 0, GET_ULONG,
|
||||
REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
|
||||
{"open_files_limit", OPT_OPEN_FILES_LIMIT,
|
||||
"If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.",
|
||||
(gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 0, 0, 65535, 0, 1, 0},
|
||||
{"query_buffer_size", OPT_QUERY_BUFFER_SIZE,
|
||||
"The initial allocation of the query buffer.", (gptr*) &query_buff_size,
|
||||
(gptr*) &query_buff_size, 0, GET_ULONG, REQUIRED_ARG, 0, MALLOC_OVERHEAD,
|
||||
(long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0},
|
||||
#ifdef HAVE_QUERY_CACHE
|
||||
{"query_cache_limit", OPT_QUERY_CACHE_LIMIT,
|
||||
"Don't cache results that are bigger than this.",
|
||||
@ -3500,24 +3516,30 @@ static struct my_option my_long_options[] =
|
||||
{"query_cache_size", OPT_QUERY_CACHE_SIZE,
|
||||
"The memory allocated to store results from old queries.",
|
||||
(gptr*) &query_cache_size, (gptr*) &query_cache_size, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1, 0},
|
||||
REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1024, 0},
|
||||
#ifdef HAVE_QUERY_CACHE
|
||||
{"query_cache_startup_type", OPT_QUERY_CACHE_STARTUP_TYPE,
|
||||
{"query_cache_type", OPT_QUERY_CACHE_TYPE,
|
||||
"0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results except SELECT SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT SQL_CACHE ... queries.",
|
||||
(gptr*) &query_cache_startup_type, (gptr*) &query_cache_startup_type, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0},
|
||||
(gptr*) &global_system_variables.query_cache_type,
|
||||
(gptr*) &max_system_variables.query_cache_type,
|
||||
0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0},
|
||||
#endif /*HAVE_QUERY_CACHE*/
|
||||
{"record_buffer", OPT_RECORD_BUFFER,
|
||||
{"read_buffer_size", OPT_RECORD_BUFFER,
|
||||
"Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
|
||||
(gptr*) &my_default_record_cache_size,
|
||||
(gptr*) &my_default_record_cache_size, 0, GET_ULONG, REQUIRED_ARG,
|
||||
(gptr*) &global_system_variables.read_buff_size,
|
||||
(gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
|
||||
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
|
||||
{"record_rnd_buffer", OPT_RECORD_RND_BUFFER,
|
||||
{"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
|
||||
"When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.",
|
||||
(gptr*) &global_system_variables.record_rnd_cache_size,
|
||||
(gptr*) &max_system_variables.record_rnd_cache_size, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 0, IO_SIZE*2+MALLOC_OVERHEAD,
|
||||
(gptr*) &global_system_variables.read_rnd_buff_size,
|
||||
(gptr*) &max_system_variables.read_rnd_buff_size, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD,
|
||||
~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
|
||||
{"record_buffer", OPT_RECORD_BUFFER,
|
||||
"Alias for read_buffer_size",
|
||||
(gptr*) &global_system_variables.read_buff_size,
|
||||
(gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
|
||||
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
|
||||
{"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
|
||||
"Undocumented", (gptr*) &relay_log_space_limit,
|
||||
(gptr*) &relay_log_space_limit, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L,
|
||||
@ -3530,7 +3552,7 @@ static struct my_option my_long_options[] =
|
||||
"If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.",
|
||||
(gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0},
|
||||
{"sort_buffer", OPT_SORT_BUFFER,
|
||||
{"sort_buffer_size", OPT_SORT_BUFFER,
|
||||
"Each thread that needs to do a sort allocates a buffer of this size.",
|
||||
(gptr*) &global_system_variables.sortbuff_size,
|
||||
(gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
|
||||
@ -3565,176 +3587,6 @@ static struct my_option my_long_options[] =
|
||||
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
struct show_var_st init_vars[]= {
|
||||
{"back_log", (char*) &back_log, SHOW_LONG},
|
||||
{"basedir", mysql_home, SHOW_CHAR},
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
{"bdb_cache_size", (char*) &berkeley_cache_size, SHOW_LONG},
|
||||
{"bdb_log_buffer_size", (char*) &berkeley_log_buffer_size, SHOW_LONG},
|
||||
{"bdb_home", (char*) &berkeley_home, SHOW_CHAR_PTR},
|
||||
{"bdb_max_lock", (char*) &berkeley_max_lock, SHOW_LONG},
|
||||
{"bdb_logdir", (char*) &berkeley_logdir, SHOW_CHAR_PTR},
|
||||
{"bdb_shared_data", (char*) &berkeley_shared_data, SHOW_BOOL},
|
||||
{"bdb_tmpdir", (char*) &berkeley_tmpdir, SHOW_CHAR_PTR},
|
||||
{"bdb_version", (char*) DB_VERSION_STRING, SHOW_CHAR},
|
||||
#endif
|
||||
{"binlog_cache_size", (char*) &binlog_cache_size, SHOW_LONG},
|
||||
{"character_set", default_charset, SHOW_CHAR},
|
||||
{"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR},
|
||||
{"concurrent_insert", (char*) &myisam_concurrent_insert, SHOW_MY_BOOL},
|
||||
{"connect_timeout", (char*) &connect_timeout, SHOW_LONG},
|
||||
{"datadir", mysql_real_data_home, SHOW_CHAR},
|
||||
{"delay_key_write", (char*) &myisam_delay_key_write, SHOW_MY_BOOL},
|
||||
{"delayed_insert_limit", (char*) &delayed_insert_limit, SHOW_LONG},
|
||||
{"delayed_insert_timeout", (char*) &delayed_insert_timeout, SHOW_LONG},
|
||||
{"delayed_queue_size", (char*) &delayed_queue_size, SHOW_LONG},
|
||||
{"flush", (char*) &myisam_flush, SHOW_MY_BOOL},
|
||||
{"flush_time", (char*) &flush_time, SHOW_LONG},
|
||||
{"ft_min_word_len", (char*) &ft_min_word_len, SHOW_LONG},
|
||||
{"ft_max_word_len", (char*) &ft_max_word_len, SHOW_LONG},
|
||||
{"ft_max_word_len_for_sort",(char*) &ft_max_word_len_for_sort, SHOW_LONG},
|
||||
{"ft_boolean_syntax", (char*) ft_boolean_syntax, SHOW_CHAR},
|
||||
{"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE},
|
||||
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
|
||||
{"have_isam", (char*) &have_isam, SHOW_HAVE},
|
||||
{"have_raid", (char*) &have_raid, SHOW_HAVE},
|
||||
{"have_symlink", (char*) &have_symlink, SHOW_HAVE},
|
||||
{"have_openssl", (char*) &have_openssl, SHOW_HAVE},
|
||||
{"have_query_cache", (char*) &have_query_cache, SHOW_HAVE},
|
||||
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
{"innodb_additional_mem_pool_size", (char*) &innobase_additional_mem_pool_size, SHOW_LONG },
|
||||
{"innodb_buffer_pool_size", (char*) &innobase_buffer_pool_size, SHOW_LONG },
|
||||
{"innodb_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR},
|
||||
{"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
|
||||
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
|
||||
{"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
|
||||
{"innodb_thread_concurrency", (char*) &innobase_thread_concurrency, SHOW_LONG },
|
||||
{"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_MY_BOOL},
|
||||
{"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL},
|
||||
{"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
|
||||
{"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
|
||||
{"innodb_log_arch_dir", (char*) &innobase_log_arch_dir, SHOW_CHAR_PTR},
|
||||
{"innodb_log_archive", (char*) &innobase_log_archive, SHOW_MY_BOOL},
|
||||
{"innodb_log_buffer_size", (char*) &innobase_log_buffer_size, SHOW_LONG },
|
||||
{"innodb_log_file_size", (char*) &innobase_log_file_size, SHOW_LONG},
|
||||
{"innodb_log_files_in_group", (char*) &innobase_log_files_in_group, SHOW_LONG},
|
||||
{"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
|
||||
{"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG},
|
||||
#endif
|
||||
{"interactive_timeout",
|
||||
(char*) offsetof(struct system_variables, net_interactive_timeout),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"join_buffer_size",
|
||||
(char*) offsetof(struct system_variables, join_buff_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"key_buffer_size", (char*) &keybuff_size, SHOW_LONG},
|
||||
{"language", language, SHOW_CHAR},
|
||||
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
|
||||
{"local_infile",
|
||||
(char*) offsetof(struct system_variables, opt_local_infile),
|
||||
SHOW_MY_BOOL_OFFSET},
|
||||
#ifdef HAVE_MLOCKALL
|
||||
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
|
||||
#endif
|
||||
{"log", (char*) &opt_log, SHOW_BOOL},
|
||||
{"log_update", (char*) &opt_update_log, SHOW_BOOL},
|
||||
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
|
||||
{"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_BOOL},
|
||||
{"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL},
|
||||
{"long_query_time",
|
||||
(char*) offsetof(struct system_variables, long_query_time),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL},
|
||||
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG},
|
||||
{"max_allowed_packet", (char*) &max_allowed_packet, SHOW_LONG},
|
||||
{"max_binlog_cache_size", (char*) &max_binlog_cache_size, SHOW_LONG},
|
||||
{"max_binlog_size", (char*) &max_binlog_size, SHOW_LONG},
|
||||
{"max_connections", (char*) &max_connections, SHOW_LONG},
|
||||
{"max_connect_errors", (char*) &max_connect_errors, SHOW_LONG},
|
||||
{"max_delayed_threads", (char*) &max_insert_delayed_threads, SHOW_LONG},
|
||||
{"max_heap_table_size",
|
||||
(char*) offsetof(struct system_variables, max_heap_table_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"max_join_size",
|
||||
(char*) offsetof(struct system_variables, max_join_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"max_sort_length",
|
||||
(char*) offsetof(struct system_variables, max_item_sort_length),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"max_user_connections", (char*) &max_user_connections, SHOW_LONG},
|
||||
{"max_tmp_tables",
|
||||
(char*) offsetof(struct system_variables, max_tmp_tables),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"max_write_lock_count", (char*) &max_write_lock_count, SHOW_LONG},
|
||||
{"myisam_bulk_insert_tree_size", (char*) &myisam_bulk_insert_tree_size, SHOW_INT},
|
||||
{"myisam_max_extra_sort_file_size",
|
||||
(char*) offsetof(struct system_variables,
|
||||
myisam_max_extra_sort_file_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"myisam_max_sort_file_size",
|
||||
(char*) offsetof(struct system_variables, myisam_max_sort_file_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
|
||||
{"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG},
|
||||
#ifdef __NT__
|
||||
{"named_pipe", (char*) &opt_enable_named_pipe, SHOW_BOOL},
|
||||
#endif
|
||||
{"net_buffer_length", (char*) &net_buffer_length, SHOW_LONG},
|
||||
{"net_read_timeout", (char*) &net_read_timeout, SHOW_LONG},
|
||||
{"net_retry_count", (char*) &mysqld_net_retry_count, SHOW_LONG},
|
||||
{"net_write_timeout", (char*) &net_write_timeout, SHOW_LONG},
|
||||
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
|
||||
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
|
||||
{"port", (char*) &mysql_port, SHOW_INT},
|
||||
{"protocol_version", (char*) &protocol_version, SHOW_INT},
|
||||
{"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG},
|
||||
{"record_rnd_buffer",
|
||||
(char*) offsetof(struct system_variables, record_rnd_cache_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"rpl_recovery_rank", (char*) &rpl_recovery_rank, SHOW_LONG},
|
||||
{"query_buffer_size", (char*) &query_buff_size, SHOW_LONG},
|
||||
#ifdef HAVE_QUERY_CACHE
|
||||
{"query_cache_limit", (char*) &query_cache.query_cache_limit, SHOW_LONG},
|
||||
{"query_cache_size", (char*) &query_cache.query_cache_size, SHOW_LONG},
|
||||
{"query_cache_startup_type",(char*) &query_cache_startup_type, SHOW_LONG},
|
||||
#endif /*HAVE_QUERY_CACHE*/
|
||||
{"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL},
|
||||
{"server_id", (char*) &server_id, SHOW_LONG},
|
||||
{"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG},
|
||||
{"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
|
||||
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
|
||||
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
|
||||
{"slow_launch_time", (char*) &slow_launch_time, SHOW_LONG},
|
||||
{"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR},
|
||||
{"sort_buffer",
|
||||
(char*) offsetof(struct system_variables, sortbuff_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"sql_mode", (char*) &opt_sql_mode, SHOW_LONG},
|
||||
{"table_cache", (char*) &table_cache_size, SHOW_LONG},
|
||||
{"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR},
|
||||
{"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
|
||||
#ifdef HAVE_THR_SETCONCURRENCY
|
||||
{"thread_concurrency", (char*) &concurrency, SHOW_LONG},
|
||||
#endif
|
||||
{"thread_stack", (char*) &thread_stack, SHOW_LONG},
|
||||
{"transaction_isolation", (char*) &default_tx_isolation_name, SHOW_CHAR_PTR},
|
||||
#ifdef HAVE_TZNAME
|
||||
{"timezone", time_zone, SHOW_CHAR},
|
||||
#endif
|
||||
{"tmp_table_size",
|
||||
(char*) offsetof(struct system_variables, tmp_table_size),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"tmpdir", (char*) &mysql_tmpdir, SHOW_CHAR_PTR},
|
||||
{"version", server_version, SHOW_CHAR},
|
||||
{"wait_timeout",
|
||||
(char*) offsetof(struct system_variables, net_wait_timeout),
|
||||
SHOW_LONG_OFFSET},
|
||||
{"warnings",
|
||||
(char*) offsetof(struct system_variables, opt_warnings),
|
||||
SHOW_MY_BOOL_OFFSET},
|
||||
{NullS, NullS, SHOW_LONG}
|
||||
};
|
||||
|
||||
struct show_var_st status_vars[]= {
|
||||
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONG},
|
||||
@ -3943,38 +3795,9 @@ Starts the MySQL server\n");
|
||||
my_print_help(my_long_options);
|
||||
my_print_variables(my_long_options);
|
||||
|
||||
printf("\
|
||||
puts("\n\
|
||||
To see what values a running MySQL server is using, type\n\
|
||||
'mysqladmin variables' instead of 'mysqld --help'.\n\
|
||||
The default values (after parsing the command line arguments) are:\n\n");
|
||||
|
||||
printf("basedir: %s\n",mysql_home);
|
||||
printf("datadir: %s\n",mysql_real_data_home);
|
||||
printf("tmpdir: %s\n",mysql_tmpdir);
|
||||
printf("language: %s\n",language);
|
||||
#ifndef __WIN__
|
||||
printf("pid file: %s\n",pidfile_name);
|
||||
#endif
|
||||
if (opt_logname)
|
||||
printf("logfile: %s\n",opt_logname);
|
||||
if (opt_update_logname)
|
||||
printf("update log: %s\n",opt_update_logname);
|
||||
if (opt_bin_log)
|
||||
{
|
||||
printf("binary log: %s\n",opt_bin_logname ? opt_bin_logname : "");
|
||||
printf("binary log index: %s\n",
|
||||
opt_binlog_index_name ? opt_binlog_index_name : "");
|
||||
}
|
||||
if (opt_slow_logname)
|
||||
printf("update log: %s\n",opt_slow_logname);
|
||||
printf("TCP port: %d\n",mysql_port);
|
||||
#if defined(HAVE_SYS_UN_H)
|
||||
printf("Unix socket: %s\n",mysql_unix_port);
|
||||
#endif
|
||||
if (my_disable_locking)
|
||||
puts("\nsystem locking is not in use");
|
||||
if (opt_noacl)
|
||||
puts("\nGrant tables are not used. All users have full access rights");
|
||||
'mysqladmin variables' instead of 'mysqld --help'.");
|
||||
}
|
||||
|
||||
|
||||
@ -3984,10 +3807,19 @@ static void set_options(void)
|
||||
opt_specialflag |= SPECIAL_NO_PRIOR;
|
||||
#endif
|
||||
|
||||
(void) strmake(default_charset, MYSQL_CHARSET, sizeof(default_charset)-1);
|
||||
sys_charset.value= (char*) MYSQL_CHARSET;
|
||||
(void) strmake(language, LANGUAGE, sizeof(language)-1);
|
||||
(void) strmake(mysql_real_data_home, get_relative_path(DATADIR),
|
||||
sizeof(mysql_real_data_home-1));
|
||||
|
||||
/* Set default values for some variables */
|
||||
global_system_variables.table_type=DB_TYPE_MYISAM;
|
||||
global_system_variables.tx_isolation=ISO_READ_COMMITTED;
|
||||
global_system_variables.select_limit= (ulong) HA_POS_ERROR;
|
||||
max_system_variables.select_limit= (ulong) HA_POS_ERROR;
|
||||
global_system_variables.max_join_size= (ulong) HA_POS_ERROR;
|
||||
max_system_variables.max_join_size= (ulong) HA_POS_ERROR;
|
||||
|
||||
#ifdef __WIN__
|
||||
/* Allow Win32 users to move MySQL anywhere */
|
||||
{
|
||||
@ -4025,7 +3857,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
opt_sql_mode = (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT |
|
||||
MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE
|
||||
| MODE_ONLY_FULL_GROUP_BY);
|
||||
default_tx_isolation= ISO_SERIALIZABLE;
|
||||
global_system_variables.tx_isolation= ISO_SERIALIZABLE;
|
||||
break;
|
||||
case 'b':
|
||||
strmake(mysql_home,argument,sizeof(mysql_home)-1);
|
||||
@ -4313,9 +4145,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
flush_time=0; // No auto flush
|
||||
break;
|
||||
case OPT_LOW_PRIORITY_UPDATES:
|
||||
thd_startup_options|=OPTION_LOW_PRIORITY_UPDATES;
|
||||
thr_upgraded_concurrent_insert_lock= TL_WRITE_LOW_PRIORITY;
|
||||
low_priority_updates=1;
|
||||
global_system_variables.low_priority_updates=1;
|
||||
break;
|
||||
case OPT_BOOTSTRAP:
|
||||
opt_noacl=opt_bootstrap=1;
|
||||
@ -4328,7 +4159,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
fprintf(stderr,"Unknown table type: %s\n",argument);
|
||||
exit(1);
|
||||
}
|
||||
default_table_type= (enum db_type) type;
|
||||
global_system_variables.table_type= type-1;
|
||||
break;
|
||||
}
|
||||
case OPT_SERVER_ID:
|
||||
@ -4338,9 +4169,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
ha_open_options|=HA_OPEN_DELAY_KEY_WRITE;
|
||||
myisam_delay_key_write=1;
|
||||
break;
|
||||
case 'C':
|
||||
strmake(default_charset, argument, sizeof(default_charset)-1);
|
||||
break;
|
||||
case OPT_CHARSETS_DIR:
|
||||
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir)-1);
|
||||
charsets_dir = mysql_charsets_dir;
|
||||
@ -4361,7 +4189,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
fprintf(stderr,"Unknown transaction isolation type: %s\n",argument);
|
||||
exit(1);
|
||||
}
|
||||
default_tx_isolation= (enum_tx_isolation) (type-1);
|
||||
global_system_variables.tx_isolation= (type-1);
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
@ -4450,9 +4278,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
fprintf(stderr, "Unknown option to sql-mode: %s\n", argument);
|
||||
exit(1);
|
||||
}
|
||||
default_tx_isolation= ((opt_sql_mode & MODE_SERIALIZABLE) ?
|
||||
ISO_SERIALIZABLE :
|
||||
ISO_READ_COMMITTED);
|
||||
global_system_variables.tx_isolation= ((opt_sql_mode & MODE_SERIALIZABLE) ?
|
||||
ISO_SERIALIZABLE :
|
||||
ISO_READ_COMMITTED);
|
||||
break;
|
||||
}
|
||||
case OPT_MASTER_PASSWORD:
|
||||
@ -4490,22 +4318,20 @@ static void get_options(int argc,char **argv)
|
||||
if (mysqld_chroot)
|
||||
set_root(mysqld_chroot);
|
||||
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];
|
||||
/* To be deleted in MySQL 4.0 */
|
||||
if (!thd->variables.record_rnd_cache_size)
|
||||
thd->variables.record_rnd_cache_size= my_default_record_cache_size;
|
||||
|
||||
/* Fix variables that are base 1024*1024 */
|
||||
/*
|
||||
Set some global variables from the global_system_variables
|
||||
In most cases the global variables will not be used
|
||||
*/
|
||||
my_default_record_cache_size=global_system_variables.read_buff_size;
|
||||
myisam_max_temp_length=
|
||||
(my_off_t) min(((ulonglong)
|
||||
thd->variables.myisam_max_sort_file_size)*1024 * 1024,
|
||||
(my_off_t) min(global_system_variables.myisam_max_sort_file_size,
|
||||
(ulonglong) MAX_FILE_SIZE);
|
||||
myisam_max_extra_temp_length=
|
||||
(my_off_t) min(((ulonglong)
|
||||
thd->variables.myisam_max_extra_sort_file_size)*1024*1024,
|
||||
(my_off_t) min(global_system_variables.myisam_max_extra_sort_file_size,
|
||||
(ulonglong) MAX_FILE_SIZE);
|
||||
|
||||
/* Set global variables based on startup options */
|
||||
myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
|
||||
}
|
||||
|
||||
@ -4548,6 +4374,7 @@ fn_format_relative_to_data_home(my_string to, const char *name,
|
||||
|
||||
static void fix_paths(void)
|
||||
{
|
||||
char buff[FN_REFLEN];
|
||||
(void) fn_format(mysql_home,mysql_home,"","",16); // Remove symlinks
|
||||
convert_dirname(mysql_home,mysql_home,NullS);
|
||||
convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
|
||||
@ -4556,7 +4383,7 @@ static void fix_paths(void)
|
||||
(void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
|
||||
(void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
|
||||
|
||||
char buff[FN_REFLEN],*sharedir=get_relative_path(SHAREDIR);
|
||||
char *sharedir=get_relative_path(SHAREDIR);
|
||||
if (test_if_hard_path(sharedir))
|
||||
strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
|
||||
else
|
||||
@ -4572,24 +4399,18 @@ static void fix_paths(void)
|
||||
charsets_dir=mysql_charsets_dir;
|
||||
}
|
||||
|
||||
/* Add '/' to TMPDIR if needed */
|
||||
char *tmp= (char*) my_malloc(FN_REFLEN,MYF(MY_FAE));
|
||||
if (tmp)
|
||||
{
|
||||
char *end=convert_dirname(tmp, mysql_tmpdir, NullS);
|
||||
|
||||
mysql_tmpdir=(char*) my_realloc(tmp,(uint) (end-tmp)+1,
|
||||
MYF(MY_HOLD_ON_ERROR));
|
||||
allocated_mysql_tmpdir=mysql_tmpdir;
|
||||
}
|
||||
char *end=convert_dirname(buff, opt_mysql_tmpdir, NullS);
|
||||
if (!(mysql_tmpdir= my_memdup(buff,(uint) (end-buff)+1, MYF(MY_FAE))))
|
||||
exit(1);
|
||||
if (!slave_load_tmpdir)
|
||||
{
|
||||
// no need to check return value, if we fail, my_malloc() never returns
|
||||
slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE));
|
||||
if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef SET_RLIMIT_NOFILE
|
||||
static uint set_maximum_open_files(uint max_file_limit)
|
||||
{
|
||||
|
@ -87,6 +87,7 @@ void send_warning(NET *net, uint sql_errno, const char *err)
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Write error package and flush to client
|
||||
It's a little too low level, but I don't want to allow another buffer
|
||||
@ -369,3 +370,18 @@ net_store_data(String *packet, CONVERT *convert, const char *from)
|
||||
return convert->store(packet, from, length);
|
||||
return net_store_data(packet,from,length);
|
||||
}
|
||||
|
||||
/*
|
||||
Function called by my_net_init() to set some check variables
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
void my_net_local_init(NET *net)
|
||||
{
|
||||
net->max_packet= (uint) global_system_variables.net_buffer_length;
|
||||
net->read_timeout= (uint) global_system_variables.net_read_timeout;
|
||||
net->write_timeout=(uint) global_system_variables.net_write_timeout;
|
||||
net->max_packet_size= max(global_system_variables.net_buffer_length,
|
||||
global_system_variables.max_allowed_packet);
|
||||
}
|
||||
}
|
||||
|
@ -14,17 +14,14 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/* Write and read of logical packets to/from socket
|
||||
** Writes are cached into net_buffer_length big packets.
|
||||
** Read packets are reallocated dynamicly when reading big packets.
|
||||
** Each logical packet has the following pre-info:
|
||||
** 3 byte length & 1 byte package-number.
|
||||
*/
|
||||
/*
|
||||
Write and read of logical packets to/from socket
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define net_read_timeout net_read_timeout1
|
||||
#define net_write_timeout net_write_timeout1
|
||||
#endif
|
||||
Writes are cached into net_buffer_length big packets.
|
||||
Read packets are reallocated dynamicly when reading big packets.
|
||||
Each logical packet has the following pre-info:
|
||||
3 byte length & 1 byte package-number.
|
||||
*/
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <winsock.h>
|
||||
@ -51,15 +48,10 @@
|
||||
*/
|
||||
|
||||
#ifdef MYSQL_SERVER
|
||||
ulong max_allowed_packet=65536;
|
||||
extern ulong net_read_timeout,net_write_timeout;
|
||||
extern uint test_flags;
|
||||
#define USE_QUERY_CACHE
|
||||
extern uint test_flags;
|
||||
extern void query_cache_insert(NET *net, const char *packet, ulong length);
|
||||
#else
|
||||
ulong max_allowed_packet=16*1024*1024L;
|
||||
ulong net_read_timeout= NET_READ_TIMEOUT;
|
||||
ulong net_write_timeout= NET_WRITE_TIMEOUT;
|
||||
#endif
|
||||
|
||||
#if defined(__WIN__) || !defined(MYSQL_SERVER)
|
||||
@ -86,8 +78,6 @@ extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
|
||||
#define TEST_BLOCKING 8
|
||||
#define MAX_THREE_BYTES 255L*255L*255L
|
||||
|
||||
ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */
|
||||
|
||||
static int net_write_buff(NET *net,const char *packet,ulong len);
|
||||
|
||||
|
||||
@ -95,17 +85,15 @@ static int net_write_buff(NET *net,const char *packet,ulong len);
|
||||
|
||||
int my_net_init(NET *net, Vio* vio)
|
||||
{
|
||||
if (!(net->buff=(uchar*) my_malloc((uint32) net_buffer_length+
|
||||
my_net_local_init(net); /* Set some limits */
|
||||
if (!(net->buff=(uchar*) my_malloc((uint32) net->max_packet+
|
||||
NET_HEADER_SIZE + COMP_HEADER_SIZE,
|
||||
MYF(MY_WME))))
|
||||
return 1;
|
||||
if (net_buffer_length > max_allowed_packet)
|
||||
max_allowed_packet=net_buffer_length;
|
||||
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
|
||||
net->buff_end=net->buff+net->max_packet;
|
||||
net->vio = vio;
|
||||
net->no_send_ok = 0;
|
||||
net->error=0; net->return_errno=0; net->return_status=0;
|
||||
net->timeout=(uint) net_read_timeout; /* Timeout for read */
|
||||
net->pkt_nr=net->compress_pkt_nr=0;
|
||||
net->write_pos=net->read_pos = net->buff;
|
||||
net->last_error[0]=0;
|
||||
@ -126,19 +114,21 @@ int my_net_init(NET *net, Vio* vio)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void net_end(NET *net)
|
||||
{
|
||||
my_free((gptr) net->buff,MYF(MY_ALLOW_ZERO_PTR));
|
||||
net->buff=0;
|
||||
}
|
||||
|
||||
|
||||
/* Realloc the packet buffer */
|
||||
|
||||
static my_bool net_realloc(NET *net, ulong length)
|
||||
{
|
||||
uchar *buff;
|
||||
ulong pkt_length;
|
||||
if (length >= max_allowed_packet)
|
||||
if (length >= net->max_packet_size)
|
||||
{
|
||||
DBUG_PRINT("error",("Packet too large (%lu)", length));
|
||||
net->error=1;
|
||||
@ -146,8 +136,10 @@ static my_bool net_realloc(NET *net, ulong length)
|
||||
return 1;
|
||||
}
|
||||
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
|
||||
/* We must allocate some extra bytes for the end 0 and to be able to
|
||||
read big compressed blocks */
|
||||
/*
|
||||
We must allocate some extra bytes for the end 0 and to be able to
|
||||
read big compressed blocks
|
||||
*/
|
||||
if (!(buff=(uchar*) my_realloc((char*) net->buff, (uint32) pkt_length +
|
||||
NET_HEADER_SIZE + COMP_HEADER_SIZE,
|
||||
MYF(MY_WME))))
|
||||
@ -374,7 +366,7 @@ net_real_write(NET *net,const char *packet,ulong len)
|
||||
#ifndef NO_ALARM
|
||||
thr_alarm_init(&alarmed);
|
||||
if (net_blocking)
|
||||
thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff);
|
||||
thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff);
|
||||
#else
|
||||
alarmed=0;
|
||||
#endif /* NO_ALARM */
|
||||
@ -388,7 +380,7 @@ net_real_write(NET *net,const char *packet,ulong len)
|
||||
#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
|
||||
if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
|
||||
if (!thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff))
|
||||
{ /* Always true for client */
|
||||
if (!vio_is_blocking(net->vio))
|
||||
{
|
||||
@ -471,7 +463,7 @@ static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
|
||||
uint retry_count=0;
|
||||
if (!thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
if (!thr_alarm(alarmed,net->timeout,&alarm_buff) ||
|
||||
if (!thr_alarm(alarmed,net->read_timeout,&alarm_buff) ||
|
||||
(!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0))
|
||||
return; /* Can't setup, abort */
|
||||
}
|
||||
@ -521,7 +513,7 @@ my_real_read(NET *net, ulong *complen)
|
||||
thr_alarm_init(&alarmed);
|
||||
#ifndef NO_ALARM
|
||||
if (net_blocking)
|
||||
thr_alarm(&alarmed,net->timeout,&alarm_buff);
|
||||
thr_alarm(&alarmed,net->read_timeout,&alarm_buff);
|
||||
#endif /* NO_ALARM */
|
||||
|
||||
pos = net->buff + net->where_b; /* net->packet -4 */
|
||||
@ -544,7 +536,7 @@ my_real_read(NET *net, ulong *complen)
|
||||
*/
|
||||
if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed))
|
||||
{
|
||||
if (!thr_alarm(&alarmed,net->timeout,&alarm_buff)) /* Don't wait too long */
|
||||
if (!thr_alarm(&alarmed,net->read_timeout,&alarm_buff)) /* Don't wait too long */
|
||||
{
|
||||
if (!vio_is_blocking(net->vio))
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
|
||||
table->file->rnd_init(0);
|
||||
|
||||
if (! (specialflag & SPECIAL_SAFE_MODE) &&
|
||||
thd->variables.record_rnd_cache_size &&
|
||||
thd->variables.read_rnd_buff_size &&
|
||||
!table->file->fast_key_read() &&
|
||||
(table->db_stat & HA_READ_ONLY ||
|
||||
table->reginfo.lock_type <= TL_READ_NO_INSERT) &&
|
||||
@ -103,7 +103,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
|
||||
!(table->db_options_in_use & HA_OPTION_PACK_RECORD) ||
|
||||
(use_record_cache < 0 &&
|
||||
!(table->file->table_flags() & HA_NOT_DELETE_WITH_CACHE)))
|
||||
VOID(table->file->extra(HA_EXTRA_CACHE)); // Cache reads
|
||||
VOID(table->file->extra_opt(HA_EXTRA_CACHE,
|
||||
thd->variables.read_buff_size));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
} /* init_read_record */
|
||||
@ -239,7 +240,7 @@ static int init_rr_cache(READ_RECORD *info)
|
||||
info->reclength=ALIGN_SIZE(info->struct_length);
|
||||
|
||||
info->error_offset=info->table->reclength;
|
||||
info->cache_records= thd->variables.record_rnd_cache_size /
|
||||
info->cache_records= thd->variables.read_rnd_buff_size /
|
||||
(info->reclength+info->struct_length);
|
||||
rec_cache_size=info->cache_records*info->reclength;
|
||||
info->rec_cache_size=info->cache_records*info->ref_length;
|
||||
|
@ -59,8 +59,8 @@ static int init_failsafe_rpl_thread(THD* thd)
|
||||
thd->system_thread = thd->bootstrap = 1;
|
||||
thd->client_capabilities = 0;
|
||||
my_net_init(&thd->net, 0);
|
||||
thd->net.timeout = slave_net_timeout;
|
||||
thd->max_packet_length=thd->net.max_packet;
|
||||
thd->net.read_timeout = slave_net_timeout;
|
||||
thd->max_client_packet_length=thd->net.max_packet;
|
||||
thd->master_access= ~0;
|
||||
thd->priv_user = 0;
|
||||
thd->system_thread = 1;
|
||||
@ -68,10 +68,7 @@ static int init_failsafe_rpl_thread(THD* thd)
|
||||
thd->thread_id = thread_id++;
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
if (init_thr_lock() ||
|
||||
my_pthread_setspecific_ptr(THR_THD, thd) ||
|
||||
my_pthread_setspecific_ptr(THR_MALLOC, &thd->mem_root) ||
|
||||
my_pthread_setspecific_ptr(THR_NET, &thd->net))
|
||||
if (init_thr_lock() || thd->store_globals())
|
||||
{
|
||||
close_connection(&thd->net,ER_OUT_OF_RESOURCES); // is this needed?
|
||||
end_thread(thd,0);
|
||||
@ -87,8 +84,8 @@ static int init_failsafe_rpl_thread(THD* thd)
|
||||
#endif
|
||||
|
||||
thd->mem_root.free=thd->mem_root.used=0;
|
||||
if (thd->max_join_size == (ulong) ~0L)
|
||||
thd->options |= OPTION_BIG_SELECTS;
|
||||
if ((ulong) thd->variables.max_join_size == (ulong) HA_POS_ERROR)
|
||||
thd->options|= OPTION_BIG_SELECTS;
|
||||
|
||||
thd->proc_info="Thread initialized";
|
||||
thd->version=refresh_version;
|
||||
@ -626,7 +623,8 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
|
||||
return 1;
|
||||
|
||||
if (!mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0,
|
||||
mi->port, 0, 0))
|
||||
mi->port, 0, 0,
|
||||
slave_net_timeout))
|
||||
{
|
||||
sql_print_error("Connection to master failed: %s",
|
||||
mc_mysql_error(mysql));
|
||||
|
@ -14,7 +14,6 @@ extern RPL_STATUS rpl_status;
|
||||
extern pthread_mutex_t LOCK_rpl_status;
|
||||
extern pthread_cond_t COND_rpl_status;
|
||||
extern TYPELIB rpl_role_typelib, rpl_status_typelib;
|
||||
extern uint rpl_recovery_rank;
|
||||
extern const char* rpl_role_type[], *rpl_status_type[];
|
||||
|
||||
pthread_handler_decl(handle_failsafe_rpl,arg);
|
||||
|
1293
sql/set_var.cc
Normal file
1293
sql/set_var.cc
Normal file
File diff suppressed because it is too large
Load Diff
419
sql/set_var.h
Normal file
419
sql/set_var.h
Normal file
@ -0,0 +1,419 @@
|
||||
/* 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 */
|
||||
|
||||
/* Classes to support the SET command */
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
Variables that are changable runtime are declared using the
|
||||
following classes
|
||||
****************************************************************************/
|
||||
|
||||
class sys_var;
|
||||
class set_var;
|
||||
typedef struct system_variables SV;
|
||||
extern TYPELIB bool_typelib;
|
||||
|
||||
enum enum_var_type
|
||||
{
|
||||
OPT_DEFAULT, OPT_SESSION, OPT_GLOBAL
|
||||
};
|
||||
|
||||
typedef bool (*sys_check_func)(THD *, set_var *);
|
||||
typedef bool (*sys_update_func)(THD *, set_var *);
|
||||
typedef void (*sys_after_update_func)(THD *,enum_var_type);
|
||||
typedef void (*sys_set_default_func)(THD *, enum_var_type);
|
||||
|
||||
class sys_var
|
||||
{
|
||||
public:
|
||||
struct my_option *option_limits; /* Updated by by set_var_init() */
|
||||
uint name_length; /* Updated by by set_var_init() */
|
||||
const char *name;
|
||||
sys_after_update_func after_update;
|
||||
sys_var(const char *name_arg) :name(name_arg),after_update(0)
|
||||
{}
|
||||
sys_var(const char *name_arg,sys_after_update_func func)
|
||||
:name(name_arg),after_update(func)
|
||||
{}
|
||||
virtual ~sys_var() {}
|
||||
virtual bool check(THD *thd, set_var *var) { return 0; }
|
||||
bool check_enum(THD *thd, set_var *var, TYPELIB *enum_names);
|
||||
virtual bool update(THD *thd, set_var *var)=0;
|
||||
virtual void set_default(THD *thd, enum_var_type type) {}
|
||||
virtual SHOW_TYPE type() { return SHOW_UNDEF; }
|
||||
virtual byte *value_ptr(THD *thd, enum_var_type type) { return 0; }
|
||||
virtual bool check_type(enum_var_type type)
|
||||
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */
|
||||
virtual bool check_update_type(Item_result type)
|
||||
{ return type != INT_RESULT; } /* Assume INT */
|
||||
virtual bool check_default(enum_var_type type)
|
||||
{ return option_limits == 0; }
|
||||
Item *item(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
class sys_var_long_ptr :public sys_var
|
||||
{
|
||||
public:
|
||||
ulong *value;
|
||||
sys_var_long_ptr(const char *name_arg, ulong *value_ptr)
|
||||
:sys_var(name_arg),value(value_ptr) {}
|
||||
sys_var_long_ptr(const char *name_arg, ulong *value_ptr,
|
||||
sys_after_update_func func)
|
||||
:sys_var(name_arg,func), value(value_ptr) {}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
SHOW_TYPE type() { return SHOW_LONG; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type) { return (byte*) value; }
|
||||
};
|
||||
|
||||
|
||||
class sys_var_bool_ptr :public sys_var
|
||||
{
|
||||
public:
|
||||
my_bool *value;
|
||||
sys_var_bool_ptr(const char *name_arg, my_bool *value_arg)
|
||||
:sys_var(name_arg),value(value_arg)
|
||||
{}
|
||||
bool check(THD *thd, set_var *var)
|
||||
{
|
||||
return check_enum(thd, var, &bool_typelib);
|
||||
}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
SHOW_TYPE type() { return SHOW_MY_BOOL; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type) { return (byte*) value; }
|
||||
bool check_update_type(Item_result type) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
class sys_var_str :public sys_var
|
||||
{
|
||||
public:
|
||||
char *value; // Pointer to allocated string
|
||||
sys_check_func check_func;
|
||||
sys_update_func update_func;
|
||||
sys_set_default_func set_default_func;
|
||||
sys_var_str(const char *name_arg,
|
||||
sys_check_func check_func_arg,
|
||||
sys_update_func update_func_arg,
|
||||
sys_set_default_func set_default_func_arg)
|
||||
:sys_var(name_arg), check_func(check_func_arg),
|
||||
update_func(update_func_arg),set_default_func(set_default_func_arg)
|
||||
{}
|
||||
bool check(THD *thd, set_var *var)
|
||||
{
|
||||
return check_func ? (*check_func)(thd, var) : 0;
|
||||
}
|
||||
bool update(THD *thd, set_var *var)
|
||||
{
|
||||
return (*update_func)(thd, var);
|
||||
}
|
||||
void set_default(THD *thd, enum_var_type type)
|
||||
{
|
||||
return (*set_default_func)(thd, type);
|
||||
}
|
||||
SHOW_TYPE type() { return SHOW_CHAR; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type) { return (byte*) value; }
|
||||
bool check_update_type(Item_result type)
|
||||
{
|
||||
return type != STRING_RESULT; /* Only accept strings */
|
||||
}
|
||||
bool check_default(enum_var_type type) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd :public sys_var
|
||||
{
|
||||
public:
|
||||
sys_var_thd(const char *name_arg)
|
||||
:sys_var(name_arg)
|
||||
{}
|
||||
sys_var_thd(const char *name_arg, sys_after_update_func func)
|
||||
:sys_var(name_arg,func)
|
||||
{}
|
||||
bool check_type(enum_var_type type) { return 0; }
|
||||
bool check_default(enum_var_type type)
|
||||
{
|
||||
return type == OPT_GLOBAL && !option_limits;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd_ulong :public sys_var_thd
|
||||
{
|
||||
public:
|
||||
ulong SV::*offset;
|
||||
sys_var_thd_ulong(const char *name_arg, ulong SV::*offset_arg)
|
||||
:sys_var_thd(name_arg), offset(offset_arg)
|
||||
{}
|
||||
sys_var_thd_ulong(const char *name_arg, ulong SV::*offset_arg,
|
||||
sys_after_update_func func)
|
||||
:sys_var_thd(name_arg,func), offset(offset_arg)
|
||||
{}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
SHOW_TYPE type() { return SHOW_LONG; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd_ulonglong :public sys_var_thd
|
||||
{
|
||||
public:
|
||||
ulonglong SV::*offset;
|
||||
sys_var_thd_ulonglong(const char *name_arg, ulonglong SV::*offset_arg)
|
||||
:sys_var_thd(name_arg), offset(offset_arg)
|
||||
{}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
SHOW_TYPE type() { return SHOW_LONGLONG; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd_bool :public sys_var_thd
|
||||
{
|
||||
public:
|
||||
my_bool SV::*offset;
|
||||
sys_var_thd_bool(const char *name_arg, my_bool SV::*offset_arg)
|
||||
:sys_var_thd(name_arg), offset(offset_arg)
|
||||
{}
|
||||
sys_var_thd_bool(const char *name_arg, my_bool SV::*offset_arg,
|
||||
sys_after_update_func func)
|
||||
:sys_var_thd(name_arg,func), offset(offset_arg)
|
||||
{}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
SHOW_TYPE type() { return SHOW_MY_BOOL; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
bool check(THD *thd, set_var *var)
|
||||
{
|
||||
return check_enum(thd, var, &bool_typelib);
|
||||
}
|
||||
bool check_update_type(Item_result type) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd_enum :public sys_var_thd
|
||||
{
|
||||
ulong SV::*offset;
|
||||
TYPELIB *enum_names;
|
||||
public:
|
||||
sys_var_thd_enum(const char *name_arg, ulong SV::*offset_arg,
|
||||
TYPELIB *typelib)
|
||||
:sys_var_thd(name_arg), offset(offset_arg), enum_names(typelib)
|
||||
{}
|
||||
sys_var_thd_enum(const char *name_arg, ulong SV::*offset_arg,
|
||||
TYPELIB *typelib,
|
||||
sys_after_update_func func)
|
||||
:sys_var_thd(name_arg,func), offset(offset_arg), enum_names(typelib)
|
||||
{}
|
||||
bool check(THD *thd, set_var *var)
|
||||
{
|
||||
return check_enum(thd, var, enum_names);
|
||||
}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
SHOW_TYPE type() { return SHOW_CHAR; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
bool check_update_type(Item_result type) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd_bit :public sys_var_thd
|
||||
{
|
||||
sys_update_func update_func;
|
||||
public:
|
||||
ulong bit_flag;
|
||||
bool reverse;
|
||||
sys_var_thd_bit(const char *name_arg, sys_update_func func, ulong bit,
|
||||
bool reverse_arg=0)
|
||||
:sys_var_thd(name_arg), update_func(func), bit_flag(bit),
|
||||
reverse(reverse_arg)
|
||||
{}
|
||||
bool check(THD *thd, set_var *var)
|
||||
{
|
||||
return check_enum(thd, var, &bool_typelib);
|
||||
}
|
||||
bool update(THD *thd, set_var *var);
|
||||
bool check_update_type(Item_result type) { return 0; }
|
||||
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
|
||||
SHOW_TYPE type() { return SHOW_MY_BOOL; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
/* some variables that require special handling */
|
||||
|
||||
class sys_var_timestamp :public sys_var
|
||||
{
|
||||
public:
|
||||
sys_var_timestamp(const char *name_arg) :sys_var(name_arg) {}
|
||||
bool update(THD *thd, set_var *var);
|
||||
void set_default(THD *thd, enum_var_type type);
|
||||
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
|
||||
bool check_default(enum_var_type type) { return 0; }
|
||||
SHOW_TYPE type() { return SHOW_LONG; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
class sys_var_last_insert_id :public sys_var
|
||||
{
|
||||
public:
|
||||
sys_var_last_insert_id(const char *name_arg) :sys_var(name_arg) {}
|
||||
bool update(THD *thd, set_var *var);
|
||||
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
|
||||
SHOW_TYPE type() { return SHOW_LONGLONG; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
class sys_var_insert_id :public sys_var
|
||||
{
|
||||
public:
|
||||
sys_var_insert_id(const char *name_arg) :sys_var(name_arg) {}
|
||||
bool update(THD *thd, set_var *var);
|
||||
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
|
||||
SHOW_TYPE type() { return SHOW_LONGLONG; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
};
|
||||
|
||||
|
||||
class sys_var_slave_skip_counter :public sys_var
|
||||
{
|
||||
public:
|
||||
sys_var_slave_skip_counter(const char *name_arg) :sys_var(name_arg) {}
|
||||
bool check(THD *thd, set_var *var);
|
||||
bool update(THD *thd, set_var *var);
|
||||
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
|
||||
/*
|
||||
We can't retrieve the value of this, so we don't have to define
|
||||
type() or value_ptr()
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
class sys_var_thd_conv_charset :public sys_var_thd
|
||||
{
|
||||
public:
|
||||
sys_var_thd_conv_charset(const char *name_arg)
|
||||
:sys_var_thd(name_arg)
|
||||
{}
|
||||
bool check(THD *thd, set_var *var);
|
||||
bool update(THD *thd, set_var *var);
|
||||
SHOW_TYPE type() { return SHOW_CHAR; }
|
||||
byte *value_ptr(THD *thd, enum_var_type type);
|
||||
bool check_update_type(Item_result type)
|
||||
{
|
||||
return type != STRING_RESULT; /* Only accept strings */
|
||||
}
|
||||
bool check_default(enum_var_type type) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
Classes for parsing of the SET command
|
||||
****************************************************************************/
|
||||
|
||||
class set_var_base :public Sql_alloc
|
||||
{
|
||||
public:
|
||||
set_var_base() {}
|
||||
virtual ~set_var_base() {}
|
||||
virtual bool check(THD *thd)=0; /* To check privileges etc. */
|
||||
virtual bool update(THD *thd)=0; /* To set the value */
|
||||
};
|
||||
|
||||
|
||||
/* MySQL internal variables, like query_cache_size */
|
||||
|
||||
class set_var :public set_var_base
|
||||
{
|
||||
public:
|
||||
sys_var *var;
|
||||
Item *value;
|
||||
enum_var_type type;
|
||||
union
|
||||
{
|
||||
CONVERT *convert;
|
||||
ulong ulong_value;
|
||||
} save_result;
|
||||
|
||||
set_var(enum_var_type type_arg, sys_var *var_arg, Item *value_arg)
|
||||
:var(var_arg), type(type_arg)
|
||||
{
|
||||
/*
|
||||
If the set value is a field, change it to a string to allow things like
|
||||
SET table_type=MYISAM;
|
||||
*/
|
||||
if (value_arg && value_arg->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
Item_field *item= (Item_field*) value_arg;
|
||||
if (!(value=new Item_string(item->field_name, strlen(item->field_name))))
|
||||
value=value_arg; /* Give error message later */
|
||||
}
|
||||
else
|
||||
value=value_arg;
|
||||
}
|
||||
bool check(THD *thd);
|
||||
bool update(THD *thd);
|
||||
};
|
||||
|
||||
|
||||
/* User variables like @my_own_variable */
|
||||
|
||||
class set_var_user: public set_var_base
|
||||
{
|
||||
Item_func_set_user_var *user_var_item;
|
||||
public:
|
||||
set_var_user(Item_func_set_user_var *item)
|
||||
:user_var_item(item)
|
||||
{}
|
||||
bool check(THD *thd);
|
||||
bool update(THD *thd);
|
||||
};
|
||||
|
||||
/* For SET PASSWORD */
|
||||
|
||||
class set_var_password: public set_var_base
|
||||
{
|
||||
LEX_USER *user;
|
||||
char *password;
|
||||
public:
|
||||
set_var_password(LEX_USER *user_arg,char *password_arg)
|
||||
:user(user_arg), password(password_arg)
|
||||
{}
|
||||
bool check(THD *thd);
|
||||
bool update(THD *thd);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Prototypes for helper functions
|
||||
*/
|
||||
|
||||
void set_var_init();
|
||||
void set_var_free();
|
||||
sys_var *find_sys_var(const char *str, uint length=0);
|
||||
bool sql_set_variables(THD *thd, List<set_var_base> *var_list);
|
||||
|
||||
extern sys_var_str sys_charset;
|
@ -238,3 +238,9 @@
|
||||
"Option '%s' used twice in statement",
|
||||
"User '%-.64s' has exceeded the '%s' resource (current value: %ld)",
|
||||
"Access denied. You need the %-.128s privilege for this operation",
|
||||
"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL",
|
||||
"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL",
|
||||
"Variable '%-.64s' doesn't have a default value",
|
||||
"Variable '%-.64s' can't be set to the value of '%-.64s'",
|
||||
"Wrong argument type to variable '%-.64s'",
|
||||
"Variable '%-.64s' can only be set, not read",
|
||||
|
@ -232,3 +232,9 @@
|
||||
"Option '%s' used twice in statement",
|
||||
"User '%-.64s' has exceeded the '%s' resource (current value: %ld)",
|
||||
"Access denied. You need the %-.128s privilege for this operation",
|
||||
"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL",
|
||||
"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL",
|
||||
"Variable '%-.64s' doesn't have a default value",
|
||||
"Variable '%-.64s' can't be set to the value of '%-.64s'",
|
||||
"Wrong argument type to variable '%-.64s'",
|
||||
"Variable '%-.64s' can only be set, not read",
|
||||
|
@ -238,3 +238,9 @@
|
||||
"Optie '%s' tweemaal gebruikt in opdracht",
|
||||
"Gebruiker '%-.64s' heeft het maximale gebruik van de '%s' faciliteit overschreden (huidige waarde: %ld)",
|
||||
"Toegang geweigerd. U moet het %-.128s privilege hebben voor deze operatie",
|
||||
"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL",
|
||||
"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL",
|
||||
"Variable '%-.64s' doesn't have a default value",
|
||||
"Variable '%-.64s' can't be set to the value of '%-.64s'",
|
||||
"Wrong argument type to variable '%-.64s'",
|
||||
"Variable '%-.64s' can only be set, not read",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user