From 1b4032c74e36dfdbb2ba0063796dd7c2b924babd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 22 Nov 2017 08:05:36 +0300 Subject: Explore possibility of supporting mingw --- mysql/libmysql/authentication_win/common.cpp | 18 ++++++------- mysql/libmysql/authentication_win/common.h | 7 ++--- mysql/libmysql/authentication_win/handshake.h | 5 +++- mysql/libmysql/libmysql.c | 38 +++++++++++++-------------- 4 files changed, 36 insertions(+), 32 deletions(-) (limited to 'mysql/libmysql') diff --git a/mysql/libmysql/authentication_win/common.cpp b/mysql/libmysql/authentication_win/common.cpp index 48c400d..aa8f7ee 100644 --- a/mysql/libmysql/authentication_win/common.cpp +++ b/mysql/libmysql/authentication_win/common.cpp @@ -31,8 +31,8 @@ template <> void error_log_print(const char *fmt, ...); 3 - additionally log info notes 4 - also log debug messages - Value of this option should be taken into account in the - implementation of error_log_vprint() function (see + Value of this option should be taken into account in the + implementation of error_log_vprint() function (see log_client.cc). Note: No error or debug messages are logged in production code @@ -365,17 +365,17 @@ UPN::~UPN() @return Pointer to a buffer containing utf8 representation or NULL in case of error. - @note The returned buffer must be freed with @c free() call. + @note The returned buffer must be freed with @c free() call. */ char* wchar_to_utf8(const wchar_t *string, size_t *len) { - char *buf= NULL; + char *buf= NULL; size_t str_len= len && *len ? *len : wcslen(string); /* A conversion from utf8 to wchar_t will never take more than 3 bytes per - character, so a buffer of length 3 * str_len schould be sufficient. + character, so a buffer of length 3 * str_len schould be sufficient. We check that assumption with an assertion later. */ @@ -410,7 +410,7 @@ char* wchar_to_utf8(const wchar_t *string, size_t *len) Error_message_buf error_buf; DBUG_PRINT("error", ("Could not convert string '%S' to utf8" ", WideCharToMultiByte() failed with error %X (%s)", - string, GetLastError(), + string, GetLastError(), get_last_error_message(error_buf))); #endif @@ -433,14 +433,14 @@ char* wchar_to_utf8(const wchar_t *string, size_t *len) @return Pointer to a buffer containing wide-char representation or NULL in case of error. - @note The returned buffer must be freed with @c free() call. + @note The returned buffer must be freed with @c free() call. */ wchar_t* utf8_to_wchar(const char *string, size_t *len) { size_t buf_len; - /* + /* Note: length (in bytes) of an utf8 string is always bigger than the number of characters in this string. Hence a buffer of size len will be sufficient. We add 1 for the terminating null character. @@ -504,7 +504,7 @@ const char* get_last_error_message(Error_message_buf buf) buf[0]= '\0'; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)buf, sizeof(buf), NULL ); + (LPTSTR)buf, ERROR_MESSAGE_BUFF_SZ, NULL ); return buf; } diff --git a/mysql/libmysql/authentication_win/common.h b/mysql/libmysql/authentication_win/common.h index b7525fb..5298195 100644 --- a/mysql/libmysql/authentication_win/common.h +++ b/mysql/libmysql/authentication_win/common.h @@ -48,14 +48,14 @@ void set_log_level(unsigned int); /* If DEBUG_ERROR_LOG is defined then error logging happens only - in debug-copiled code. Otherwise ERROR_LOG() expands to + in debug-copiled code. Otherwise ERROR_LOG() expands to error_log_print() even in production code. Note: Macro ERROR_LOG() can use printf-like format string like this: ERROR_LOG(Level, ("format string", args)); - The implementation should handle it correctly. Currently it is passed + The implementation should handle it correctly. Currently it is passed to fprintf() (see error_log_vprint() function). */ @@ -78,7 +78,8 @@ void error_log_print(const char *fmt, ...) va_end(args); } -typedef char Error_message_buf[1024]; +#define ERROR_MESSAGE_BUFF_SZ 1024 +typedef char Error_message_buf[ERROR_MESSAGE_BUFF_SZ]; const char* get_last_error_message(Error_message_buf); diff --git a/mysql/libmysql/authentication_win/handshake.h b/mysql/libmysql/authentication_win/handshake.h index 14b1386..15c0ca7 100644 --- a/mysql/libmysql/authentication_win/handshake.h +++ b/mysql/libmysql/authentication_win/handshake.h @@ -100,7 +100,10 @@ public: Handshake(const char *ssp, side_t side); virtual ~Handshake(); - int Handshake::packet_processing_loop(); + /* + * error: extra qualification 'Handshake::' on member 'packet_processing_loop' [-fpermissive] + */ + int packet_processing_loop(); bool virtual is_complete() const { diff --git a/mysql/libmysql/libmysql.c b/mysql/libmysql/libmysql.c index 51aab62..82061e1 100644 --- a/mysql/libmysql/libmysql.c +++ b/mysql/libmysql/libmysql.c @@ -763,7 +763,7 @@ MYSQL_FIELD *cli_list_fields(MYSQL *mysql) MYSQL_FIELD *result; MYSQL_TRACE_STAGE(mysql, WAIT_FOR_FIELD_DEF); - query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, + query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, protocol_41(mysql) ? 8 : 6); MYSQL_TRACE_STAGE(mysql, READY_FOR_COMMAND); @@ -1112,10 +1112,10 @@ void my_net_local_init(NET *net) can use in a SQL statement in of the either ways: INSERT INTO blob_column VALUES (0xAABBCC); (any MySQL version) INSERT INTO blob_column VALUES (X'AABBCC'); (4.1 and higher) - + The string in "from" is encoded to a HEX string. The result is placed in "to" and a terminating null byte is appended. - + The string pointed to by "from" must be "length" bytes long. You must allocate the "to" buffer to be at least length*2+1 bytes long. Each character needs two bytes, and you need room for the terminating @@ -1132,7 +1132,7 @@ mysql_hex_string(char *to, const char *from, ulong length) { char *to0= to; const char *end; - + for (end= from + length; from < end; from++) { *to++= _dig_vec_upper[((unsigned char) *from) >> 4]; @@ -1907,7 +1907,7 @@ mysql_stmt_param_metadata(MYSQL_STMT *stmt) TODO: Fix this when server sends the information. Till then keep a dummy prototype. */ - DBUG_RETURN(0); + DBUG_RETURN(0); } @@ -2188,9 +2188,9 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) stmt->insert_id= mysql->insert_id; if (res) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, net); @@ -2233,7 +2233,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt) else { set_stmt_errmsg(stmt, net); - DBUG_RETURN(1); + DBUG_RETURN(1); } /* Reserve place for null-marker bytes */ @@ -2414,9 +2414,9 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, net); @@ -3110,9 +3110,9 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, buff, sizeof(buff), (uchar*) data, length, 1, stmt)) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, &mysql->net); @@ -4337,7 +4337,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt) ((rc= stmt_fetch_row(stmt, row)) && rc != MYSQL_DATA_TRUNCATED)) { stmt->state= MYSQL_STMT_PREPARE_DONE; /* XXX: this is buggy */ - stmt->read_row_func= (rc == MYSQL_NO_DATA) ? + stmt->read_row_func= (rc == MYSQL_NO_DATA) ? stmt_read_row_no_data : stmt_read_row_no_result_set; } else @@ -4586,9 +4586,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, net); -- cgit v1.1