diff options
author | unknown <bell@sanja.is.com.ua> | 2003-07-29 20:26:14 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-07-29 20:26:14 +0300 |
commit | 29b230355da3eb1688f20ca8e802f7978692433a (patch) | |
tree | 1295ba2d8bb4884a32ad11e02497332b62590669 /sql-common/client.c | |
parent | ca6c74b7ee8f9a1a94521083215601ef635f1db3 (diff) | |
parent | ec1a433f087d09fd187d4a224394bfa87baa09ce (diff) | |
download | mariadb-git-29b230355da3eb1688f20ca8e802f7978692433a.tar.gz |
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-top3-4.1
sql/item_cmpfunc.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.h:
Auto merged
Diffstat (limited to 'sql-common/client.c')
-rw-r--r-- | sql-common/client.c | 88 |
1 files changed, 61 insertions, 27 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 721164c8301..f9219e5418d 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -38,7 +38,28 @@ #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 +#define CLI_MYSQL_CLOSE cli_mysql_close + +#undef net_flush +my_bool net_flush(NET *net); + +#else /*EMBEDDED_LIBRARY*/ +#define CLI_MYSQL_REAL_CONNECT mysql_real_connect +#define CLI_MYSQL_CLOSE mysql_close +#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__) ... */ @@ -526,6 +547,10 @@ net_safe_read(MYSQL *mysql) { DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", vio_description(net->vio),len)); +#ifdef MYSQL_SERVER + if (socket_errno == SOCKET_EINTR) + return (packet_error); +#endif /*MYSQL_SERVER*/ end_server(mysql); net->last_errno=(net->last_errno == ER_NET_PACKET_TOO_LARGE ? CR_NET_PACKET_TOO_LARGE: @@ -572,8 +597,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 +660,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 +777,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; @@ -951,7 +969,7 @@ static void mysql_read_default_options(struct st_mysql_options *options, else the lengths are calculated from the offset between pointers. **************************************************************************/ -void fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count) +static void cli_fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count) { ulong *prev_length; byte *start=0; @@ -972,7 +990,6 @@ void fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count) } } - /*************************************************************************** Change field rows to field structs ***************************************************************************/ @@ -1000,7 +1017,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, for (row=data->data; row ; row = row->next,field++) { uchar *pos; - fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); + cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); field->catalog = strdup_root(alloc,(char*) row->data[0]); field->db = strdup_root(alloc,(char*) row->data[1]); field->table = strdup_root(alloc,(char*) row->data[2]); @@ -1041,7 +1058,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, /* old protocol, for backward compatibility */ for (row=data->data; row ; row = row->next,field++) { - fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5); + cli_fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5); field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]); field->name= strdup_root(alloc,(char*) row->data[1]); field->length= (uint) uint3korr(row->data[2]); @@ -1278,6 +1295,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 +1427,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 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_read_query_result, + cli_advanced_command, + cli_mysql_store_result, + cli_mysql_use_result, + cli_fetch_lengths +}; + +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 +1472,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 +2144,7 @@ static void mysql_close_free(MYSQL *mysql) } -void STDCALL -mysql_close(MYSQL *mysql) +void STDCALL CLI_MYSQL_CLOSE(MYSQL *mysql) { DBUG_ENTER("mysql_close"); if (mysql) /* Some simple safety */ @@ -2165,8 +2196,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 +2313,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"); @@ -2310,6 +2339,7 @@ mysql_store_result(MYSQL *mysql) strmov(mysql->net.last_error, ER(mysql->net.last_errno)); DBUG_RETURN(0); } + result->methods= mysql->methods; result->eof=1; /* Marker for buffered */ result->lengths=(ulong*) (result+1); if (!(result->data=read_rows(mysql,mysql->fields,mysql->field_count))) @@ -2339,8 +2369,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"); @@ -2361,6 +2390,7 @@ mysql_use_result(MYSQL *mysql) MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(0); result->lengths=(ulong*) (result+1); + result->methods= mysql->methods; if (!(result->row=(MYSQL_ROW) my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME)))) { /* Ptrs: to one row */ @@ -2477,6 +2507,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); |