diff options
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 39 | ||||
-rw-r--r-- | sql-common/client_plugin.c | 4 | ||||
-rw-r--r-- | sql-common/my_time.c | 33 | ||||
-rw-r--r-- | sql-common/my_user.c | 1 | ||||
-rw-r--r-- | sql-common/mysql_async.c | 4 |
5 files changed, 25 insertions, 56 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 25cb3aac2de..d4ba7b6b9f5 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -96,6 +96,7 @@ my_bool net_flush(NET *net); #ifndef _WIN32 #include <errno.h> #define SOCKET_ERROR -1 +#define INVALID_SOCKET -1 #endif #ifdef __WIN__ @@ -264,7 +265,6 @@ HANDLE create_named_pipe(MYSQL *mysql, uint connect_timeout, char **arg_host, char pipe_name[1024]; 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) @@ -375,7 +375,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) char *shared_memory_base_name = mysql->options.shared_memory_base_name; static const char *name_prefixes[] = {"","Global\\"}; const char *prefix; - int i; + uint i; /* If this is NULL, somebody freed the MYSQL* options. mysql_close() @@ -746,7 +746,7 @@ void free_old_query(MYSQL *mysql) if (mysql->fields) free_root(&mysql->field_alloc,MYF(0)); /* Assume rowlength < 8192 */ - init_alloc_root(&mysql->field_alloc, 8192, 0, + init_alloc_root(&mysql->field_alloc, "fields", 8192, 0, MYF(mysql->options.use_thread_specific_memory ? MY_THREAD_SPECIFIC : 0)); mysql->fields= 0; @@ -921,13 +921,6 @@ static int cli_report_progress(MYSQL *mysql, char *pkt, uint length) return 0; } -#ifdef __WIN__ -static my_bool is_NT(void) -{ - char *os=getenv("OS"); - return (os && !strcmp(os, "Windows_NT")) ? 1 : 0; -} -#endif /************************************************************************** Shut down connection @@ -1479,7 +1472,7 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, DBUG_RETURN(0); } /* Assume rowlength < 8192 */ - init_alloc_root(&result->alloc, 8192, 0, + init_alloc_root(&result->alloc, "result", 8192, 0, MYF(mysql->options.use_thread_specific_memory ? MY_THREAD_SPECIFIC : 0)); result->alloc.min_malloc=sizeof(MYSQL_ROWS); @@ -2999,7 +2992,7 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, /* new "use different plugin" packet */ uint len; auth_plugin_name= (char*)mysql->net.read_pos + 1; - len= strlen(auth_plugin_name); /* safe as my_net_read always appends \0 */ + len= (uint)strlen(auth_plugin_name); /* safe as my_net_read always appends \0 */ mpvio.cached_server_reply.pkt_len= pkt_length - len - 2; mpvio.cached_server_reply.pkt= mysql->net.read_pos + len + 2; DBUG_PRINT ("info", ("change plugin packet from server for plugin %s", @@ -3082,6 +3075,7 @@ set_connect_attributes(MYSQL *mysql, char *buff, size_t buf_len) rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_client_name"); rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_os"); rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_platform"); + rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_server_host"); rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_pid"); rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_thread"); rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_client_version"); @@ -3097,6 +3091,8 @@ set_connect_attributes(MYSQL *mysql, char *buff, size_t buf_len) "_os", SYSTEM_TYPE); rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_platform", MACHINE_TYPE); + rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, + "_server_host", mysql->host); #ifdef __WIN__ snprintf(buff, buf_len, "%lu", (ulong) GetCurrentProcessId()); #else @@ -3145,9 +3141,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, DBUG_RETURN(0); } - if (set_connect_attributes(mysql, buff, sizeof(buff))) - DBUG_RETURN(0); - mysql->methods= &client_methods; mysql->client_flag=0; /* For handshake */ @@ -3242,7 +3235,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { my_socket sock= socket(AF_UNIX, SOCK_STREAM, 0); DBUG_PRINT("info", ("Using socket")); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) { set_mysql_extended_error(mysql, CR_SOCKET_CREATE_ERROR, unknown_sqlstate, @@ -3289,7 +3282,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!net->vio && (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || - (! have_tcpip && (unix_socket || !host && is_NT())))) + (! have_tcpip && (unix_socket || !host )))) { if ((hPipe= create_named_pipe(mysql, mysql->options.connect_timeout, (char**) &host, (char**) &unix_socket)) == @@ -3323,7 +3316,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, struct addrinfo *res_lst, hints, *t_res; int gai_errno; char port_buf[NI_MAXSERV]; - my_socket sock= SOCKET_ERROR; + my_socket sock= INVALID_SOCKET; int saved_error= 0, status= -1; unix_socket=0; /* This is not used */ @@ -3371,7 +3364,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol)); sock= socket(t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) { saved_error= socket_errno; continue; @@ -3388,7 +3381,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, DBUG_PRINT("info", ("Connect socket")); status= connect_sync_or_async(mysql, net, sock, - t_res->ai_addr, t_res->ai_addrlen); + t_res->ai_addr, (uint)t_res->ai_addrlen); /* Here we rely on my_connect() to return success only if the connect attempt was really successful. Otherwise we would stop @@ -3413,7 +3406,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, freeaddrinfo(res_lst); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) { set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate, ER(CR_IPSOCK_ERROR), saved_error); @@ -3601,6 +3594,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, mysql->client_flag= client_flag; + set_connect_attributes(mysql, buff, sizeof(buff)); + /* Part 2: invoke the plugin to send the authentication data to the server */ @@ -3676,7 +3671,7 @@ error: end_server(mysql); mysql_close_free(mysql); if (!(client_flag & CLIENT_REMEMBER_OPTIONS) && - !mysql->options.extension->async_context) + !(mysql->options.extension && mysql->options.extension->async_context)) mysql_close_free_options(mysql); } DBUG_RETURN(0); diff --git a/sql-common/client_plugin.c b/sql-common/client_plugin.c index f93e50125c5..4c584d17294 100644 --- a/sql-common/client_plugin.c +++ b/sql-common/client_plugin.c @@ -28,7 +28,7 @@ There is no reference counting and no unloading either. */ -#if _MSC_VER +#if defined(_MSC_VER) /* Silence warnings about variable 'unused' being used. */ #define FORCE_INIT_OF_VARS 1 #endif @@ -251,7 +251,7 @@ int mysql_client_plugin_init() bzero(&mysql, sizeof(mysql)); /* dummy mysql for set_mysql_extended_error */ mysql_mutex_init(0, &LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW); - init_alloc_root(&mem_root, 128, 128, MYF(0)); + init_alloc_root(&mem_root, "client_plugin", 128, 128, MYF(0)); bzero(&plugin_list, sizeof(plugin_list)); diff --git a/sql-common/my_time.c b/sql-common/my_time.c index d7953fe36bf..c4731d6b601 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -15,6 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <my_global.h> #include <my_time.h> #include <m_string.h> #include <m_ctype.h> @@ -292,7 +293,7 @@ static void get_microseconds(ulong *val, MYSQL_TIME_STATUS *status, #define MAX_DATE_PARTS 8 my_bool -str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, +str_to_datetime(const char *str, size_t length, MYSQL_TIME *l_time, ulonglong flags, MYSQL_TIME_STATUS *status) { const char *end=str+length, *pos; @@ -456,7 +457,7 @@ err: TRUE on error */ -my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, +my_bool str_to_time(const char *str, size_t length, MYSQL_TIME *l_time, ulonglong fuzzydate, MYSQL_TIME_STATUS *status) { ulong date[5]; @@ -1425,31 +1426,3 @@ double TIME_to_double(const MYSQL_TIME *my_time) d+= my_time->second_part/(double)TIME_SECOND_PART_FACTOR; return my_time->neg ? -d : d; } - -longlong pack_time(const MYSQL_TIME *my_time) -{ - return ((((((my_time->year * 13ULL + - my_time->month) * 32ULL + - my_time->day) * 24ULL + - my_time->hour) * 60ULL + - my_time->minute) * 60ULL + - my_time->second) * 1000000ULL + - my_time->second_part) * (my_time->neg ? -1 : 1); -} - -#define get_one(WHERE, FACTOR) WHERE= (ulong)(packed % FACTOR); packed/= FACTOR - -MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time) -{ - if ((my_time->neg= packed < 0)) - packed= -packed; - get_one(my_time->second_part, 1000000ULL); - get_one(my_time->second, 60U); - get_one(my_time->minute, 60U); - get_one(my_time->hour, 24U); - get_one(my_time->day, 32U); - get_one(my_time->month, 13U); - my_time->year= (uint)packed; - my_time->time_type= MYSQL_TIMESTAMP_DATETIME; - return my_time; -} diff --git a/sql-common/my_user.c b/sql-common/my_user.c index a486f77bc1e..712101b471f 100644 --- a/sql-common/my_user.c +++ b/sql-common/my_user.c @@ -14,6 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <my_global.h> #include <my_user.h> #include <m_string.h> #include <mysql_com.h> diff --git a/sql-common/mysql_async.c b/sql-common/mysql_async.c index 1bac16edd1e..a19955c49de 100644 --- a/sql-common/mysql_async.c +++ b/sql-common/mysql_async.c @@ -135,7 +135,7 @@ my_recv_async(struct mysql_async_context *b, my_socket fd, for (;;) { - res= recv(fd, buf, size, IF_WIN(0, MSG_DONTWAIT)); + res= recv(fd, buf, (int)size, IF_WIN(0, MSG_DONTWAIT)); if (res >= 0 || IS_BLOCKING_ERROR()) return res; b->events_to_wait_for= MYSQL_WAIT_READ; @@ -163,7 +163,7 @@ my_send_async(struct mysql_async_context *b, my_socket fd, for (;;) { - res= send(fd, buf, size, IF_WIN(0, MSG_DONTWAIT)); + res= send(fd, buf, (int)size, IF_WIN(0, MSG_DONTWAIT)); if (res >= 0 || IS_BLOCKING_ERROR()) return res; b->events_to_wait_for= MYSQL_WAIT_WRITE; |