mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Fixes for embedded MySQL
Some limit optimization
This commit is contained in:
parent
93de112238
commit
9ee2a297c0
17 changed files with 95 additions and 229 deletions
|
@ -315,3 +315,4 @@ libmysqld/time.cc
|
|||
libmysqld/unireg.cc
|
||||
linked_libmysqld_sources
|
||||
sql-bench/bench-count-distinct
|
||||
libmysqld/sql_handler.cc
|
||||
|
|
|
@ -36,14 +36,17 @@ const char *client_errors[]=
|
|||
"MySQL client got out of memory",
|
||||
"Wrong host info",
|
||||
"Localhost via UNIX socket",
|
||||
"%s via TCP/IP",
|
||||
"%-.64s via TCP/IP",
|
||||
"Error in server handshake",
|
||||
"Lost connection to MySQL server during query",
|
||||
"Commands out of sync; You can't run this command now",
|
||||
"Verbindung ueber Named Pipe; Host: %-.64s",
|
||||
"Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)"
|
||||
"Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't initialize character set %-.64s (path: %-.64s)",
|
||||
"Got packet bigger than 'max_allowed_packet'",
|
||||
"Embedded server",
|
||||
};
|
||||
|
||||
#else /* ENGLISH */
|
||||
|
@ -60,19 +63,22 @@ const char *client_errors[]=
|
|||
"MySQL client run out of memory",
|
||||
"Wrong host info",
|
||||
"Localhost via UNIX socket",
|
||||
"%s via TCP/IP",
|
||||
"%-.64s via TCP/IP",
|
||||
"Error in server handshake",
|
||||
"Lost connection to MySQL server during query",
|
||||
"Commands out of sync; You can't run this command now",
|
||||
"%s via named pipe",
|
||||
"%-.64s via named pipe",
|
||||
"Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't initialize character set %-.64s (path: %-.64s)",
|
||||
"Got packet bigger than 'max_allowed_packet'",
|
||||
"Embedded server",
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
void init_client_errs(void)
|
||||
{
|
||||
errmsg[CLIENT_ERRMAP] = &client_errors[0];
|
||||
my_errmsg[CLIENT_ERRMAP] = &client_errors[0];
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ static String glob_buffer,old_buffer;
|
|||
static int wait_time = 5;
|
||||
static STATUS status;
|
||||
static ulong select_limit,max_join_size,opt_connect_timeout=0;
|
||||
static char *xmlmeta[] = {
|
||||
static const char *xmlmeta[] = {
|
||||
"&", "&",
|
||||
"<", "<",
|
||||
0, 0
|
||||
|
@ -173,8 +173,8 @@ static int sql_connect(char *host,char *database,char *user,char *password,
|
|||
uint silent);
|
||||
static int put_info(const char *str,INFO_TYPE info,uint error=0);
|
||||
static void safe_put_field(const char *pos,ulong length);
|
||||
static char *array_value(char **array, char *key);
|
||||
static char *xmlencode(char *dest, char *src);
|
||||
static const char *array_value(const char **array, char *key);
|
||||
static void xmlencode(char *dest, char *src);
|
||||
static void my_chomp(char *end);
|
||||
static void init_pager();
|
||||
static void end_pager();
|
||||
|
@ -1739,8 +1739,8 @@ print_table_data_vertically(MYSQL_RES *result)
|
|||
}
|
||||
}
|
||||
|
||||
static char
|
||||
*array_value(char **array, char *key) {
|
||||
static const char
|
||||
*array_value(const char **array, char *key) {
|
||||
int x;
|
||||
for(x=0; array[x]; x+=2)
|
||||
if(!strcmp(array[x], key))
|
||||
|
@ -1748,19 +1748,21 @@ static char
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char
|
||||
*xmlencode(char *dest, char *src) {
|
||||
static void
|
||||
xmlencode(char *dest, char *src)
|
||||
{
|
||||
char *p = src;
|
||||
char *t;
|
||||
const char *t;
|
||||
char s[2] = { 0, 0 };
|
||||
*dest = 0;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
s[0] = *p;
|
||||
if(!(t=array_value(xmlmeta, s))) t = s;
|
||||
strcat(dest, t);
|
||||
if (!(t=array_value(xmlmeta, s)))
|
||||
t = s;
|
||||
dest=strmov(dest, t);
|
||||
} while(*p++);
|
||||
return dest;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -53,3 +53,4 @@ extern const char *client_errors[]; /* Error messages */
|
|||
#define CR_NAMEDPIPESETSTATE_ERROR 2018
|
||||
#define CR_CANT_READ_CHARSET 2019
|
||||
#define CR_NET_PACKET_TOO_LARGE 2020
|
||||
#define CR_EMBEDDED_CONNECTION 2021
|
||||
|
|
|
@ -157,6 +157,10 @@ extern unsigned long net_buffer_length;
|
|||
|
||||
#define net_new_transaction(net) ((net)->pkt_nr=0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int my_net_init(NET *net, Vio* vio);
|
||||
void net_end(NET *net);
|
||||
void net_clear(NET *net);
|
||||
|
@ -172,6 +176,10 @@ struct rand_struct {
|
|||
double max_value_dbl;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The following is for user defined functions */
|
||||
|
||||
enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/* ib_config.h. Generated automatically by configure. */
|
||||
/* ib_config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
/* #undef inline */
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* Define if you have the <aio.h> header file. */
|
||||
#define HAVE_AIO_H 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "ib"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.90"
|
||||
|
||||
/* No inlining because gcc broken on HP-UX */
|
||||
/* #undef UNIV_MUST_NOT_INLINE */
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/* ib_config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
#undef inline
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#undef WORDS_BIGENDIAN
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#undef SIZEOF_INT
|
||||
|
||||
/* Define if you have the <aio.h> header file. */
|
||||
#undef HAVE_AIO_H
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* No inlining because gcc broken on HP-UX */
|
||||
#undef UNIV_MUST_NOT_INLINE
|
||||
|
|
@ -45,7 +45,8 @@ const char *client_errors[]=
|
|||
"Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't initialize character set %-.64s (path: %-.64s)",
|
||||
"Got packet bigger than 'max_allowed_packet'"
|
||||
"Got packet bigger than 'max_allowed_packet'",
|
||||
"Embedded server",
|
||||
};
|
||||
|
||||
#else /* ENGLISH */
|
||||
|
@ -71,7 +72,8 @@ const char *client_errors[]=
|
|||
"Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't initialize character set %-.64s (path: %-.64s)",
|
||||
"Got packet bigger than 'max_allowed_packet'"
|
||||
"Got packet bigger than 'max_allowed_packet'",
|
||||
"Embedded server",
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ libmysqlobjects = errmsg.lo get_password.lo password.lo
|
|||
|
||||
sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
||||
ha_berkeley.cc ha_heap.cc ha_isam.cc ha_isammrg.cc \
|
||||
ha_myisam.cc ha_myisammrg.cc handler.cc hostname.cc init.cc \
|
||||
ha_myisam.cc ha_myisammrg.cc handler.cc sql_handler.cc \
|
||||
hostname.cc init.cc \
|
||||
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
|
||||
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
|
||||
item_uniq.cc key.cc lock.cc log.cc log_event.cc md5.c \
|
||||
|
@ -58,7 +59,8 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
|||
## XXX: we should not have to duplicate info from the sources list
|
||||
sqlobjects = convert.lo derror.lo field.lo field_conv.lo filesort.lo \
|
||||
ha_berkeley.lo ha_heap.lo ha_isam.lo ha_isammrg.lo \
|
||||
ha_myisam.lo ha_myisammrg.lo handler.lo hostname.lo init.lo \
|
||||
ha_myisam.lo ha_myisammrg.lo handler.lo sql_handler.lo \
|
||||
hostname.lo init.lo \
|
||||
item.lo item_buff.lo item_cmpfunc.lo item_create.lo \
|
||||
item_func.lo item_strfunc.lo item_sum.lo item_timefunc.lo \
|
||||
item_uniq.lo key.lo lock.lo log.lo log_event.lo md5.lo \
|
||||
|
|
|
@ -126,8 +126,6 @@ void start_embedded_conn1(NET * net)
|
|||
|
||||
if (thd->max_join_size == HA_POS_ERROR)
|
||||
thd->options |= OPTION_BIG_SELECTS;
|
||||
if (thd->client_capabilities & CLIENT_COMPRESS)
|
||||
net->compress=1; // Use compression
|
||||
if (thd->options & OPTION_ANSI_MODE)
|
||||
thd->client_capabilities|=CLIENT_IGNORE_SPACE;
|
||||
|
||||
|
@ -180,9 +178,6 @@ check_connections1(THD *thd)
|
|||
end+=4;
|
||||
memcpy(end,thd->scramble,SCRAMBLE_LENGTH+1);
|
||||
end+=SCRAMBLE_LENGTH +1;
|
||||
#ifdef HAVE_COMPRESS
|
||||
client_flags |= CLIENT_COMPRESS;
|
||||
#endif /* HAVE_COMPRESS */
|
||||
int2store(end,client_flags);
|
||||
end[2]=MY_CHARSET_CURRENT;
|
||||
|
||||
|
@ -391,32 +386,34 @@ void embedded_srv_init(void)
|
|||
|
||||
/* These must be set early */
|
||||
|
||||
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_grant,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_open,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
|
||||
(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_binlog_update, MY_MUTEX_INIT_FAST); // QQ NOT USED
|
||||
(void) pthread_mutex_init(&LOCK_slave, 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_cond_init(&COND_thread_count,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_mysql_create_db,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_Acl,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_grant,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_open,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_thread_count,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_mapped_file,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_status,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_error_log,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_insert,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_status,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_create,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_mutex_init(&LOCK_manager,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_crypt,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_bytes_sent,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_bytes_received,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_timezone,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_binlog_update, NULL);
|
||||
(void) pthread_mutex_init(&LOCK_slave, NULL);
|
||||
(void) pthread_mutex_init(&LOCK_server_id, NULL);
|
||||
(void) pthread_cond_init(&COND_binlog_update, NULL);
|
||||
(void) pthread_cond_init(&COND_slave_stopped, NULL);
|
||||
(void) pthread_cond_init(&COND_slave_start, NULL);
|
||||
|
||||
if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
|
||||
unireg_abort(1);
|
||||
|
|
|
@ -156,13 +156,13 @@ int vio_write(Vio * vio, const gptr buf, int size)
|
|||
{
|
||||
*vio->last_packet = packet;
|
||||
vio->last_packet = (char **)packet;
|
||||
*((char **)packet) = 0; /* safety */
|
||||
*((char **)packet) = 0; /* Set forward link to 0 */
|
||||
packet += sizeof(char *);
|
||||
int4store(packet, size);
|
||||
memcpy(packet + 4, buf, size);
|
||||
}
|
||||
else
|
||||
size=0;
|
||||
size= -1;
|
||||
return (size);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
#define DONT_USE_RAID
|
||||
#include <global.h>
|
||||
#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
|
||||
#include <winsock.h>
|
||||
#include <odbcinst.h>
|
||||
#endif
|
||||
#include <global.h>
|
||||
#include <my_sys.h>
|
||||
#include <mysys_err.h>
|
||||
#include <m_string.h>
|
||||
|
@ -95,20 +96,9 @@ static sig_handler pipe_sig_handler(int sig);
|
|||
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
||||
const char *from, ulong length);
|
||||
|
||||
/*
|
||||
Let the user specify that we don't want SIGPIPE; This doesn't however work
|
||||
with threaded applications as we can have multiple read in progress.
|
||||
*/
|
||||
|
||||
#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
|
||||
#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0;
|
||||
#define set_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
|
||||
#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
|
||||
#else
|
||||
#define init_sigpipe_variables
|
||||
#define set_sigpipe(mysql)
|
||||
#define reset_sigpipe(mysql)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/****************************************************************************
|
||||
|
@ -212,78 +202,6 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
|
|||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/*
|
||||
** Create a named pipe connection
|
||||
*/
|
||||
|
||||
#ifdef __WIN__
|
||||
|
||||
HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
|
||||
char **arg_unix_socket)
|
||||
{
|
||||
HANDLE hPipe=INVALID_HANDLE_VALUE;
|
||||
char szPipeName [ 257 ];
|
||||
DWORD dwMode;
|
||||
int i;
|
||||
my_bool testing_named_pipes=0;
|
||||
char *host= *arg_host, *unix_socket= *arg_unix_socket;
|
||||
|
||||
if ( ! unix_socket || (unix_socket)[0] == 0x00)
|
||||
unix_socket = mysql_unix_port;
|
||||
if (!host || !strcmp(host,LOCAL_HOST))
|
||||
host=LOCAL_HOST_NAMEDPIPE;
|
||||
|
||||
sprintf( szPipeName, "\\\\%s\\pipe\\%s", host, unix_socket);
|
||||
DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s",
|
||||
host, unix_socket));
|
||||
|
||||
for (i=0 ; i < 100 ; i++) /* Don't retry forever */
|
||||
{
|
||||
if ((hPipe = CreateFile(szPipeName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL )) != INVALID_HANDLE_VALUE)
|
||||
break;
|
||||
if (GetLastError() != ERROR_PIPE_BUSY)
|
||||
{
|
||||
net->last_errno=CR_NAMEDPIPEOPEN_ERROR;
|
||||
sprintf(net->last_error,ER(net->last_errno),host, unix_socket,
|
||||
(ulong) GetLastError());
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
/* wait for for an other instance */
|
||||
if (! WaitNamedPipe(szPipeName, connect_timeout*1000) )
|
||||
{
|
||||
net->last_errno=CR_NAMEDPIPEWAIT_ERROR;
|
||||
sprintf(net->last_error,ER(net->last_errno),host, unix_socket,
|
||||
(ulong) GetLastError());
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
if (hPipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
net->last_errno=CR_NAMEDPIPEOPEN_ERROR;
|
||||
sprintf(net->last_error,ER(net->last_errno),host, unix_socket,
|
||||
(ulong) GetLastError());
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
dwMode = PIPE_READMODE_BYTE | PIPE_WAIT;
|
||||
if ( !SetNamedPipeHandleState(hPipe, &dwMode, NULL, NULL) )
|
||||
{
|
||||
CloseHandle( hPipe );
|
||||
net->last_errno=CR_NAMEDPIPESETSTATE_ERROR;
|
||||
sprintf(net->last_error,ER(net->last_errno),host, unix_socket,
|
||||
(ulong) GetLastError());
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
*arg_host=host ; *arg_unix_socket=unix_socket; /* connect arg */
|
||||
return (hPipe);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** read a packet from server. Give error message if socket was down
|
||||
|
@ -1010,6 +928,7 @@ static void mysql_once_init()
|
|||
embedded_srv_init();
|
||||
init_client_errs();
|
||||
mysql_port = MYSQL_PORT;
|
||||
DEBUGGER_ON;
|
||||
mysql_debug(NullS);
|
||||
}
|
||||
#ifdef THREAD
|
||||
|
@ -1052,7 +971,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
uint port, const char *unix_socket,uint client_flag)
|
||||
{
|
||||
char buff[100],charset_name_buff[16],*end,*host_info, *charset_name;
|
||||
my_socket sock;
|
||||
uint pkt_length;
|
||||
NET *net= &mysql->net;
|
||||
DBUG_ENTER("mysql_real_connect");
|
||||
|
@ -1082,40 +1000,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
if (!passwd)
|
||||
{
|
||||
passwd=mysql->options.password;
|
||||
#ifndef DONT_USE_MYSQL_PWD
|
||||
if (!passwd)
|
||||
passwd=getenv("MYSQL_PWD"); /* get it from environment (haneke) */
|
||||
#endif
|
||||
}
|
||||
if (!db || !db[0])
|
||||
db=mysql->options.db;
|
||||
if (!port)
|
||||
port=mysql->options.port;
|
||||
if (!unix_socket)
|
||||
unix_socket=mysql->options.unix_socket;
|
||||
|
||||
port=0;
|
||||
unix_socket=0;
|
||||
mysql->reconnect=1; /* Reconnect as default */
|
||||
mysql->server_status=SERVER_STATUS_AUTOCOMMIT;
|
||||
|
||||
/*
|
||||
** Grab a socket and connect it to the server
|
||||
*/
|
||||
|
||||
unix_socket=0; /* This is not used */
|
||||
if (!port)
|
||||
port=mysql_port;
|
||||
if (!host)
|
||||
host=LOCAL_HOST;
|
||||
sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host);
|
||||
DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port));
|
||||
/* _WIN64 ; Assume that the (int) range is enough for socket() */
|
||||
if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
|
||||
{
|
||||
net->last_errno=CR_IPSOCK_ERROR;
|
||||
sprintf(net->last_error,ER(net->last_errno),ERRNO);
|
||||
goto error;
|
||||
}
|
||||
|
||||
host_info=(char*) ER(CR_EMBEDDED_CONNECTION);
|
||||
if (my_net_init(net, net->vio))
|
||||
{
|
||||
vio_delete(net->vio);
|
||||
|
@ -1199,6 +1091,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
/* Save connection information */
|
||||
if (!user) user="";
|
||||
if (!passwd) passwd="";
|
||||
host=LOCAL_HOST;
|
||||
if (!my_multi_malloc(MYF(0),
|
||||
&mysql->host_info, (uint) strlen(host_info)+1,
|
||||
&mysql->host, (uint) strlen(host)+1,
|
||||
|
@ -1228,14 +1121,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
|
||||
/* Send client information for access check */
|
||||
client_flag|=CLIENT_CAPABILITIES;
|
||||
|
||||
|
||||
client_flag&= ~CLIENT_COMPRESS;
|
||||
if (db)
|
||||
client_flag|=CLIENT_CONNECT_WITH_DB;
|
||||
|
||||
client_flag&= ~CLIENT_COMPRESS;
|
||||
|
||||
|
||||
int2store(buff,client_flag);
|
||||
mysql->client_flag=client_flag;
|
||||
|
||||
|
@ -1251,7 +1139,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
DBUG_PRINT("info",("user: %s",buff+5));
|
||||
end=scramble(strend(buff+5)+1, mysql->scramble_buff, passwd,
|
||||
(my_bool) (mysql->protocol_version == 9));
|
||||
if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
|
||||
|
||||
if (db)
|
||||
{
|
||||
end=strmov(end+1,db);
|
||||
mysql->db=my_strdup(db,MYF(MY_WME));
|
||||
|
@ -1264,8 +1153,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
|
||||
if( net_safe_read(mysql) == packet_error)
|
||||
goto error;
|
||||
if (client_flag & CLIENT_COMPRESS) /* We will use compression */
|
||||
net->compress=1;
|
||||
if (db && mysql_select_db(mysql,db))
|
||||
goto error;
|
||||
if (mysql->options.init_command)
|
||||
|
|
|
@ -53,7 +53,7 @@ t1 ref a,b a 5 const 1 where used
|
|||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 12 where used
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range a,b a 5 NULL 12 where used
|
||||
t1 range a,b a 5 NULL 5 where used
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range a,b a 5 NULL 4 where used
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include <violite.h>
|
||||
#include <assert.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifdef MYSQL_SERVER
|
||||
ulong max_allowed_packet=65536;
|
||||
extern ulong net_read_timeout,net_write_timeout;
|
||||
|
@ -824,3 +826,5 @@ my_net_read(NET *net)
|
|||
#endif /* HAVE_COMPRESS */
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -827,9 +827,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||
pos--;
|
||||
packet_length--;
|
||||
}
|
||||
*pos=0;
|
||||
if (!(thd->query= (char*) thd->memdup((gptr) (packet),packet_length)))
|
||||
if (!(thd->query= (char*) thd->memdup((gptr) (packet),packet_length+1)))
|
||||
break;
|
||||
thd->query[packet_length]=0;
|
||||
thd->packet.shrink(net_buffer_length); // Reclaim some memory
|
||||
if (!(specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),QUERY_PRIOR);
|
||||
|
|
|
@ -275,6 +275,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
|
|||
join.having=0;
|
||||
join.do_send_rows = 1;
|
||||
join.group= group != 0;
|
||||
join.row_limit= ((select_distinct || order || group) ? HA_POS_ERROR :
|
||||
thd->select_limit);
|
||||
|
||||
#ifdef RESTRICTED_GROUP
|
||||
if (join.sum_func_count && !group && (join.func_count || join.field_count))
|
||||
|
@ -812,7 +814,7 @@ err:
|
|||
*****************************************************************************/
|
||||
|
||||
static ha_rows get_quick_record_count(SQL_SELECT *select,TABLE *table,
|
||||
key_map keys)
|
||||
key_map keys,ha_rows limit)
|
||||
{
|
||||
int error;
|
||||
DBUG_ENTER("get_quick_record_count");
|
||||
|
@ -820,7 +822,7 @@ static ha_rows get_quick_record_count(SQL_SELECT *select,TABLE *table,
|
|||
{
|
||||
select->head=table;
|
||||
table->reginfo.impossible_range=0;
|
||||
if ((error=select->test_quick_select(keys,(table_map) 0,HA_POS_ERROR))
|
||||
if ((error=select->test_quick_select(keys,(table_map) 0,limit))
|
||||
== 1)
|
||||
DBUG_RETURN(select->quick->records);
|
||||
if (error == -1)
|
||||
|
@ -1032,7 +1034,8 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
|
|||
s->read_time=(ha_rows) s->table->file->scan_time();
|
||||
|
||||
/* Set a max range of how many seeks we can expect when using keys */
|
||||
s->worst_seeks= (double) (s->read_time*2);
|
||||
/* This was (s->read_time*5), but this was too low with small rows */
|
||||
s->worst_seeks= (double) s->found_records / 5;
|
||||
if (s->worst_seeks < 2.0) // Fix for small tables
|
||||
s->worst_seeks=2.0;
|
||||
|
||||
|
@ -1045,7 +1048,8 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
|
|||
select=make_select(s->table,const_table_map,
|
||||
0,
|
||||
and_conds(conds,s->on_expr),&error);
|
||||
records=get_quick_record_count(select,s->table, s->const_keys);
|
||||
records=get_quick_record_count(select,s->table, s->const_keys,
|
||||
join->row_limit);
|
||||
s->quick=select->quick;
|
||||
s->needed_reg=select->needed_reg;
|
||||
select->quick=0;
|
||||
|
@ -1732,7 +1736,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
|
|||
{
|
||||
/* we can use only index tree */
|
||||
uint keys_per_block= table->file->block_size/2/
|
||||
keyinfo->key_length+1;
|
||||
(keyinfo->key_length+table->file->ref_length)+1;
|
||||
tmp=(record_count*(records+keys_per_block-1)/
|
||||
keys_per_block);
|
||||
}
|
||||
|
@ -1802,7 +1806,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
|
|||
{
|
||||
/* we can use only index tree */
|
||||
uint keys_per_block= table->file->block_size/2/
|
||||
keyinfo->key_length+1;
|
||||
(keyinfo->key_length+table->file->ref_length)+1;
|
||||
tmp=record_count*(tmp+keys_per_block-1)/keys_per_block;
|
||||
}
|
||||
else
|
||||
|
@ -2215,6 +2219,7 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
|
|||
join->send_records=(ha_rows) 0;
|
||||
join->group=0;
|
||||
join->do_send_rows = 1;
|
||||
join->row_limit=HA_POS_ERROR;
|
||||
|
||||
join_tab->cache.buff=0; /* No cacheing */
|
||||
join_tab->table=tmp_table;
|
||||
|
|
|
@ -152,7 +152,7 @@ class JOIN {
|
|||
bool sort_and_group,first_record,full_join,group, no_field_update;
|
||||
bool do_send_rows;
|
||||
table_map const_table_map,outer_join;
|
||||
ha_rows send_records,found_records;
|
||||
ha_rows send_records,found_records,examined_rows,row_limit;
|
||||
POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1];
|
||||
double best_read;
|
||||
List<Item> *fields;
|
||||
|
|
Loading…
Add table
Reference in a new issue