summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.fi>2001-04-25 01:11:29 +0300
committerunknown <monty@donna.mysql.fi>2001-04-25 01:11:29 +0300
commitdbd56fcdc575d522e8cac6046b85e29d496a37e9 (patch)
treeb35002c3218b71a338dff899023d7799c6cc4829 /libmysqld
parent7337a193b1bb590c127daa9d92839e476e9b219f (diff)
downloadmariadb-git-dbd56fcdc575d522e8cac6046b85e29d496a37e9.tar.gz
Fixes for embedded MySQL
Some limit optimization BitKeeper/deleted/.del-ib_config.h.in~9e57db8504e55b7: Delete: innobase/ib_config.h.in BitKeeper/deleted/.del-ib_config.h~7539e26ffc614439: Delete: innobase/ib_config.h client/errmsg.c: Moved error messages from libmysqld/ client/mysql.cc: Removed warnings include/errmsg.h: New info for embedded versions include/mysql_com.h: Fixes for embedded MySQL libmysql/errmsg.c: Fixes for embedded MySQL libmysqld/Makefile.am: Added HANDLER code libmysqld/lib_sql.cc: Fixes for embedded MySQL libmysqld/lib_vio.c: Fixes for embedded MySQL BitKeeper/etc/ignore: Added libmysqld/sql_handler.cc to the ignore list libmysqld/libmysqld.c: Fixes for embedded MySQL mysql-test/r/null_key.result: Fixed result for 4.0 sql/net_serv.cc: Fixes for embedded MySQL sql/sql_parse.cc: Fixes for embedded MySQL where the query could be a const char* sql/sql_select.cc: Added limit optimization sql/sql_select.h: Added limit optimization
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/Makefile.am6
-rw-r--r--libmysqld/lib_sql.cc45
-rw-r--r--libmysqld/lib_vio.c4
-rw-r--r--libmysqld/libmysqld.c133
4 files changed, 37 insertions, 151 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 396213b7e04..8d8ac3c9a21 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -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 \
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 8a484301b61..b2889079ac8 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -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);
diff --git a/libmysqld/lib_vio.c b/libmysqld/lib_vio.c
index a1cd8ca9565..3238fd59699 100644
--- a/libmysqld/lib_vio.c
+++ b/libmysqld/lib_vio.c
@@ -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);
}
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index a9def5c37ef..732c102c640 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -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)