summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c70
-rw-r--r--sql-common/pack.c34
2 files changed, 89 insertions, 15 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 33f2b996971..b70aed2d2c2 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -38,7 +38,34 @@
#include <my_global.h>
#include "mysql.h"
+
+#ifdef EMBEDDED_LIBRARY
+
+#ifdef MYSQL_SERVER
+#undef MYSQL_SERVER
+#endif
+
+#ifndef MYSQL_CLIENT
+#define MYSQL_CLIENT
+#endif
+
+#define CLI_MYSQL_REAL_CONNECT cli_mysql_real_connect
+
+#ifdef net_flush
+#undef net_flush
+#endif
+my_bool net_flush(NET *net);
+
+#else /*EMBEDDED_LIBRARY*/
+#define CLI_MYSQL_REAL_CONNECT mysql_real_connect
+#endif /*EMBEDDED_LIBRARY*/
+
+#ifdef MYSQL_CLIENT
+static my_bool mysql_client_init=0;
+#endif
+
#if !defined(MYSQL_SERVER) && (defined(__WIN__) || defined(_WIN32) || defined(_WIN64))
+
#include <winsock.h>
#include <odbcinst.h>
#endif /* !defined(MYSQL_SERVER) && (defined(__WIN__) ... */
@@ -572,8 +599,8 @@ void free_rows(MYSQL_DATA *cur)
}
}
-my_bool
-advanced_command(MYSQL *mysql, enum enum_server_command command,
+static my_bool
+cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check)
{
@@ -639,7 +666,9 @@ my_bool
simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
ulong length, my_bool skip_check)
{
- return advanced_command(mysql, command, NullS, 0, arg, length, skip_check);
+ return
+ (*mysql->methods->advanced_command)(mysql, command,
+ NullS, 0, arg, length, skip_check);
}
void free_old_query(MYSQL *mysql)
@@ -759,8 +788,8 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
return 0;
}
-static void mysql_read_default_options(struct st_mysql_options *options,
- const char *filename,const char *group)
+void mysql_read_default_options(struct st_mysql_options *options,
+ const char *filename,const char *group)
{
int argc;
char *argv_buff[1],**argv;
@@ -1409,10 +1438,23 @@ error:
before calling mysql_real_connect !
*/
-MYSQL * STDCALL
-mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
- const char *passwd, const char *db,
- uint port, const char *unix_socket,ulong client_flag)
+static void STDCALL cli_mysql_close(MYSQL *mysql);
+static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql);
+static MYSQL_RES * STDCALL cli_mysql_store_result(MYSQL *mysql);
+
+static MYSQL_METHODS client_methods=
+{
+ cli_mysql_close,
+ cli_mysql_read_query_result,
+ cli_advanced_command,
+ cli_mysql_store_result,
+ CLI_MYSQL_USE_RESULT
+};
+
+MYSQL * STDCALL
+CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
+ const char *passwd, const char *db,
+ uint port, const char *unix_socket,ulong client_flag)
{
char buff[NAME_LEN+USERNAME_LENGTH+100],charset_name_buff[16];
char *end,*host_info,*charset_name;
@@ -1441,6 +1483,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
user ? user : "(Null)"));
/* Don't give sigpipe errors if the client doesn't want them */
+ mysql->methods= &client_methods;
set_sigpipe(mysql);
net->vio = 0; /* If something goes wrong */
mysql->client_flag=0; /* For handshake */
@@ -2111,8 +2154,7 @@ static void mysql_close_free(MYSQL *mysql)
}
-void STDCALL
-mysql_close(MYSQL *mysql)
+static void STDCALL cli_mysql_close(MYSQL *mysql)
{
DBUG_ENTER("mysql_close");
if (mysql) /* Some simple safety */
@@ -2164,8 +2206,7 @@ mysql_close(MYSQL *mysql)
DBUG_VOID_RETURN;
}
-
-my_bool STDCALL mysql_read_query_result(MYSQL *mysql)
+static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql)
{
uchar *pos;
ulong field_count;
@@ -2282,8 +2323,7 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length)
mysql_data_seek may be used.
**************************************************************************/
-MYSQL_RES * STDCALL
-mysql_store_result(MYSQL *mysql)
+static MYSQL_RES * STDCALL cli_mysql_store_result(MYSQL *mysql)
{
MYSQL_RES *result;
DBUG_ENTER("mysql_store_result");
diff --git a/sql-common/pack.c b/sql-common/pack.c
index e363d600e20..16cc13eddbd 100644
--- a/sql-common/pack.c
+++ b/sql-common/pack.c
@@ -1,7 +1,28 @@
+/* Copyright (C) 2000-2003 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 */
+
#include <my_global.h>
#include <mysql_com.h>
#include <mysql.h>
+ulong net_buffer_length=8192;
+ulong max_allowed_packet= 1024L*1024L*1024L;
+ulong net_read_timeout= NET_READ_TIMEOUT;
+ulong net_write_timeout= NET_WRITE_TIMEOUT;
+
/* Get the length of next field. Change parameter to point at fieldstart */
ulong STDCALL net_field_length(uchar **packet)
{
@@ -62,3 +83,16 @@ my_ulonglong net_field_length_ll(uchar **packet)
#endif
}
+/*
+ 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->retry_count= 1;
+ net->max_packet_size= max(net_buffer_length, max_allowed_packet);
+}
+