Loading sql-common/client.c +38 −22 Original line number Diff line number Diff line Loading @@ -318,7 +318,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, { net->last_errno=CR_NAMEDPIPEOPEN_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading @@ -327,7 +328,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, { net->last_errno=CR_NAMEDPIPEWAIT_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading @@ -336,7 +338,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, { net->last_errno=CR_NAMEDPIPEOPEN_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading @@ -346,7 +349,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, CloseHandle( hPipe ); net->last_errno=CR_NAMEDPIPESETSTATE_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno),host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading Loading @@ -560,9 +564,11 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) net->last_errno=error_allow; strmov(net->sqlstate, unknown_sqlstate); if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR) sprintf(net->last_error,ER(net->last_errno),suffix_pos,error_code); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),suffix_pos,error_code); else sprintf(net->last_error,ER(net->last_errno),error_code); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),error_code); return(INVALID_HANDLE_VALUE); } return(handle_map); Loading Loading @@ -792,7 +798,8 @@ static int check_license(MYSQL *mysql) if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE) { net->last_errno= CR_WRONG_LICENSE; sprintf(net->last_error, ER(net->last_errno), required_license); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), required_license); } return 1; } Loading @@ -809,7 +816,8 @@ static int check_license(MYSQL *mysql) strncmp(row[0], required_license, sizeof(required_license)))) { net->last_errno= CR_WRONG_LICENSE; sprintf(net->last_error, ER(net->last_errno), required_license); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), required_license); } mysql_free_result(res); return net->last_errno; Loading Loading @@ -1647,7 +1655,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, sock=0; unix_socket = 0; host=mysql->options.shared_memory_base_name; sprintf(host_info=buff, ER(CR_SHARED_MEMORY_CONNECTION), host); my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_SHARED_MEMORY_CONNECTION), host); } } #endif /* HAVE_SMEM */ Loading @@ -1667,7 +1676,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { net->last_errno=CR_SOCKET_CREATE_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),socket_errno); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); Loading @@ -1681,7 +1691,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, socket_errno)); net->last_errno=CR_CONNECTION_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),unix_socket,socket_errno); goto error; } mysql->options.protocol=MYSQL_PROTOCOL_SOCKET; Loading Loading @@ -1711,7 +1722,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, else { net->vio=vio_new_win32pipe(hPipe); sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), unix_socket); my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_NAMEDPIPE_CONNECTION), unix_socket); } } #endif Loading @@ -1724,7 +1736,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, port=mysql_port; if (!host) host=LOCAL_HOST; sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); my_snprintf(host_info=buff,sizeof(buff)-1,ER(CR_TCP_CONNECTION),host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); #ifdef MYSQL_SERVER thr_alarm_init(&alarmed); Loading @@ -1739,7 +1751,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { net->last_errno=CR_IPSOCK_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),socket_errno); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE); Loading @@ -1766,7 +1779,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, my_gethostbyname_r_free(); net->last_errno=CR_UNKNOWN_HOST; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(CR_UNKNOWN_HOST), host, tmp_errno); goto error; } memcpy(&sock_addr.sin_addr, hp->h_addr, Loading @@ -1781,7 +1795,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, host)); net->last_errno= CR_CONN_HOST_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(CR_CONN_HOST_ERROR), host, socket_errno); goto error; } } Loading Loading @@ -1834,7 +1849,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { strmov(net->sqlstate, unknown_sqlstate); net->last_errno= CR_VERSION_ERROR; sprintf(net->last_error, ER(CR_VERSION_ERROR), mysql->protocol_version, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(CR_VERSION_ERROR), mysql->protocol_version, PROTOCOL_VERSION); goto error; } Loading sql/examples/ha_archive.cc +17 −13 Original line number Diff line number Diff line Loading @@ -333,10 +333,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL) goto error2; if (my_hash_insert(&archive_open_tables, (byte*) share)) goto error2; thr_lock_init(&share->lock); if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST)) goto error3; thr_lock_init(&share->lock); } share->use_count++; pthread_mutex_unlock(&archive_mutex); Loading @@ -344,14 +342,13 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) return share; error3: VOID(pthread_mutex_destroy(&share->mutex)); thr_lock_delete(&share->lock); /* We close, but ignore errors since we already have errors */ (void)gzclose(share->archive_write); error2: my_close(share->meta_file,MYF(0)); error: pthread_mutex_unlock(&archive_mutex); VOID(pthread_mutex_destroy(&share->mutex)); my_free((gptr) share, MYF(0)); return NULL; Loading Loading @@ -485,22 +482,29 @@ int ha_archive::create(const char *name, TABLE *table_arg, if ((archive= gzdopen(create_file, "ab")) == NULL) { error= errno; delete_table(name); goto error; goto error2; } if (write_data_header(archive)) { gzclose(archive); goto error2; error= errno; goto error3; } if (gzclose(archive)) { error= errno; goto error2; } my_close(create_file, MYF(0)); DBUG_RETURN(0); error3: /* We already have an error, so ignore results of gzclose. */ (void)gzclose(archive); error2: error= errno; my_close(create_file, MYF(0)); delete_table(name); error: /* Return error number, if we got one */ Loading Loading @@ -751,7 +755,7 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) if ((rebuild_file= gzopen(data_file_name, "rb")) == NULL) DBUG_RETURN(errno ? errno : -1); if (rc= read_data_header(rebuild_file)) if ((rc= read_data_header(rebuild_file))) goto error; /* Loading Loading @@ -823,7 +827,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) DBUG_RETURN(-1); } while (read= gzread(reader, block, IO_SIZE)) while ((read= gzread(reader, block, IO_SIZE))) gzwrite(writer, block, read); gzclose(reader); Loading Loading
sql-common/client.c +38 −22 Original line number Diff line number Diff line Loading @@ -318,7 +318,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, { net->last_errno=CR_NAMEDPIPEOPEN_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading @@ -327,7 +328,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, { net->last_errno=CR_NAMEDPIPEWAIT_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading @@ -336,7 +338,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, { net->last_errno=CR_NAMEDPIPEOPEN_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading @@ -346,7 +349,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, CloseHandle( hPipe ); net->last_errno=CR_NAMEDPIPESETSTATE_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),host, unix_socket, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno),host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } Loading Loading @@ -560,9 +564,11 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) net->last_errno=error_allow; strmov(net->sqlstate, unknown_sqlstate); if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR) sprintf(net->last_error,ER(net->last_errno),suffix_pos,error_code); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),suffix_pos,error_code); else sprintf(net->last_error,ER(net->last_errno),error_code); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),error_code); return(INVALID_HANDLE_VALUE); } return(handle_map); Loading Loading @@ -792,7 +798,8 @@ static int check_license(MYSQL *mysql) if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE) { net->last_errno= CR_WRONG_LICENSE; sprintf(net->last_error, ER(net->last_errno), required_license); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), required_license); } return 1; } Loading @@ -809,7 +816,8 @@ static int check_license(MYSQL *mysql) strncmp(row[0], required_license, sizeof(required_license)))) { net->last_errno= CR_WRONG_LICENSE; sprintf(net->last_error, ER(net->last_errno), required_license); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(net->last_errno), required_license); } mysql_free_result(res); return net->last_errno; Loading Loading @@ -1647,7 +1655,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, sock=0; unix_socket = 0; host=mysql->options.shared_memory_base_name; sprintf(host_info=buff, ER(CR_SHARED_MEMORY_CONNECTION), host); my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_SHARED_MEMORY_CONNECTION), host); } } #endif /* HAVE_SMEM */ Loading @@ -1667,7 +1676,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { net->last_errno=CR_SOCKET_CREATE_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),socket_errno); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); Loading @@ -1681,7 +1691,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, socket_errno)); net->last_errno=CR_CONNECTION_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),unix_socket,socket_errno); goto error; } mysql->options.protocol=MYSQL_PROTOCOL_SOCKET; Loading Loading @@ -1711,7 +1722,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, else { net->vio=vio_new_win32pipe(hPipe); sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), unix_socket); my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_NAMEDPIPE_CONNECTION), unix_socket); } } #endif Loading @@ -1724,7 +1736,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, port=mysql_port; if (!host) host=LOCAL_HOST; sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); my_snprintf(host_info=buff,sizeof(buff)-1,ER(CR_TCP_CONNECTION),host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); #ifdef MYSQL_SERVER thr_alarm_init(&alarmed); Loading @@ -1739,7 +1751,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { net->last_errno=CR_IPSOCK_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error,ER(net->last_errno),socket_errno); my_snprintf(net->last_error,sizeof(net->last_error)-1, ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE); Loading @@ -1766,7 +1779,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, my_gethostbyname_r_free(); net->last_errno=CR_UNKNOWN_HOST; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(CR_UNKNOWN_HOST), host, tmp_errno); goto error; } memcpy(&sock_addr.sin_addr, hp->h_addr, Loading @@ -1781,7 +1795,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, host)); net->last_errno= CR_CONN_HOST_ERROR; strmov(net->sqlstate, unknown_sqlstate); sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno); my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(CR_CONN_HOST_ERROR), host, socket_errno); goto error; } } Loading Loading @@ -1834,7 +1849,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { strmov(net->sqlstate, unknown_sqlstate); net->last_errno= CR_VERSION_ERROR; sprintf(net->last_error, ER(CR_VERSION_ERROR), mysql->protocol_version, my_snprintf(net->last_error, sizeof(net->last_error)-1, ER(CR_VERSION_ERROR), mysql->protocol_version, PROTOCOL_VERSION); goto error; } Loading
sql/examples/ha_archive.cc +17 −13 Original line number Diff line number Diff line Loading @@ -333,10 +333,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL) goto error2; if (my_hash_insert(&archive_open_tables, (byte*) share)) goto error2; thr_lock_init(&share->lock); if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST)) goto error3; thr_lock_init(&share->lock); } share->use_count++; pthread_mutex_unlock(&archive_mutex); Loading @@ -344,14 +342,13 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) return share; error3: VOID(pthread_mutex_destroy(&share->mutex)); thr_lock_delete(&share->lock); /* We close, but ignore errors since we already have errors */ (void)gzclose(share->archive_write); error2: my_close(share->meta_file,MYF(0)); error: pthread_mutex_unlock(&archive_mutex); VOID(pthread_mutex_destroy(&share->mutex)); my_free((gptr) share, MYF(0)); return NULL; Loading Loading @@ -485,22 +482,29 @@ int ha_archive::create(const char *name, TABLE *table_arg, if ((archive= gzdopen(create_file, "ab")) == NULL) { error= errno; delete_table(name); goto error; goto error2; } if (write_data_header(archive)) { gzclose(archive); goto error2; error= errno; goto error3; } if (gzclose(archive)) { error= errno; goto error2; } my_close(create_file, MYF(0)); DBUG_RETURN(0); error3: /* We already have an error, so ignore results of gzclose. */ (void)gzclose(archive); error2: error= errno; my_close(create_file, MYF(0)); delete_table(name); error: /* Return error number, if we got one */ Loading Loading @@ -751,7 +755,7 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) if ((rebuild_file= gzopen(data_file_name, "rb")) == NULL) DBUG_RETURN(errno ? errno : -1); if (rc= read_data_header(rebuild_file)) if ((rc= read_data_header(rebuild_file))) goto error; /* Loading Loading @@ -823,7 +827,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) DBUG_RETURN(-1); } while (read= gzread(reader, block, IO_SIZE)) while ((read= gzread(reader, block, IO_SIZE))) gzwrite(writer, block, read); gzclose(reader); Loading