summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorhf@deer.(none) <>2003-07-04 13:21:14 +0500
committerhf@deer.(none) <>2003-07-04 13:21:14 +0500
commit9d4bae335c59864350297c1f5111d0b0c45174ba (patch)
tree8d9d48e6d2ba9a4f0332cb4bda4fe3dbe23651d6 /sql-common
parent110b497cc32db6cafb65c2661cb459c491377319 (diff)
parentc224b55835a01ad38f6b978fe1e23b9363bae1cc (diff)
downloadmariadb-git-9d4bae335c59864350297c1f5111d0b0c45174ba.tar.gz
Resolving conflicts
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c74
-rw-r--r--sql-common/pack.c61
2 files changed, 112 insertions, 23 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 721164c8301..ea0d079511f 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -38,7 +38,26 @@
#include <my_global.h>
#include "mysql.h"
+
+#ifdef EMBEDDED_LIBRARY
+
+#undef MYSQL_SERVER
+
+#ifndef MYSQL_CLIENT
+#define MYSQL_CLIENT
+#endif
+
+#define CLI_MYSQL_REAL_CONNECT cli_mysql_real_connect
+
+#undef net_flush
+my_bool net_flush(NET *net);
+
+#else /*EMBEDDED_LIBRARY*/
+#define CLI_MYSQL_REAL_CONNECT mysql_real_connect
+#endif /*EMBEDDED_LIBRARY*/
+
#if !defined(MYSQL_SERVER) && (defined(__WIN__) || defined(_WIN32) || defined(_WIN64))
+
#include <winsock.h>
#include <odbcinst.h>
#endif /* !defined(MYSQL_SERVER) && (defined(__WIN__) ... */
@@ -572,8 +591,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)
{
@@ -635,13 +654,6 @@ end:
return result;
}
-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);
-}
-
void free_old_query(MYSQL *mysql)
{
DBUG_ENTER("free_old_query");
@@ -759,8 +771,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;
@@ -1278,6 +1290,7 @@ mysql_init(MYSQL *mysql)
#ifdef HAVE_SMEM
mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name;
#endif
+ mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
return mysql;
}
@@ -1409,10 +1422,24 @@ 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_RES * STDCALL cli_mysql_use_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 +1468,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 */
@@ -2112,8 +2140,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 */
@@ -2165,8 +2192,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;
@@ -2283,8 +2309,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");
@@ -2339,8 +2364,7 @@ mysql_store_result(MYSQL *mysql)
have to wait for the client (and will not wait more than 30 sec/packet).
**************************************************************************/
-MYSQL_RES * STDCALL
-mysql_use_result(MYSQL *mysql)
+static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql)
{
MYSQL_RES *result;
DBUG_ENTER("mysql_use_result");
@@ -2477,6 +2501,10 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME));
#endif
+ case MYSQL_OPT_USE_REMOTE_CONNECTION:
+ case MYSQL_OPT_USE_EMBEDDED_CONNECTION:
+ case MYSQL_OPT_GUESS_CONNECTION:
+ mysql->options.methods_to_use= option;
break;
default:
DBUG_RETURN(1);
diff --git a/sql-common/pack.c b/sql-common/pack.c
index e363d600e20..43e0098bf29 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,43 @@ 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);
+}
+
+char *
+net_store_length(char *pkg, ulonglong length)
+{
+ uchar *packet=(uchar*) pkg;
+ if (length < LL(251))
+ {
+ *packet=(uchar) length;
+ return (char*) packet+1;
+ }
+ /* 251 is reserved for NULL */
+ if (length < LL(65536))
+ {
+ *packet++=252;
+ int2store(packet,(uint) length);
+ return (char*) packet+2;
+ }
+ if (length < LL(16777216))
+ {
+ *packet++=253;
+ int3store(packet,(ulong) length);
+ return (char*) packet+3;
+ }
+ *packet++=254;
+ int8store(packet,length);
+ return (char*) packet+8;
+}
+