From 1fabe4eaaca8b679b8e65f7ca08fb7ee74548ddc Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Mon, 14 Oct 2013 14:17:54 +0200 Subject: [PATCH] Fixes for DBD:mysql (CONC-57) added missing functions mysql_read_query_result and mysql_get_parameters --- include/mysql.h | 13 ++++++++++++- libmariadb/libmariadb.c | 21 ++++++++++++++++++++- libmariadb/libmariadb_exports.def | 2 ++ libmariadb/net.c | 5 +++++ libmariadb/version_script.txt | 1 + unittest/libmariadb/connection.c | 2 +- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 8d61c00a..d96d8d8b 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -341,6 +341,16 @@ typedef struct character_set unsigned int mbmaxlen; /* max. length for multibyte strings */ } MY_CHARSET_INFO; +typedef struct +{ + unsigned long *p_max_allowed_packet; + unsigned long *p_net_buffer_length; + void *extension; +} MYSQL_PARAMETERS; + +#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length) +#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet) + /* Local infile support functions */ #define LOCAL_INFILE_ERROR_LEN 512 @@ -405,7 +415,7 @@ int STDCALL mysql_select_db(MYSQL *mysql, const char *db); int STDCALL mysql_query(MYSQL *mysql, const char *q); int STDCALL mysql_send_query(MYSQL *mysql, const char *q, unsigned long length); -int STDCALL mysql_read_query_result(MYSQL *mysql); +my_bool STDCALL mysql_read_query_result(MYSQL *mysql); int STDCALL mysql_real_query(MYSQL *mysql, const char *q, unsigned long length); int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); @@ -467,6 +477,7 @@ size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, CHARSE char *to, size_t *to_len, CHARSET_INFO *to_cs, int *errorcode); int STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option, const void *arg1, const void *arg2); +MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void); #include diff --git a/libmariadb/libmariadb.c b/libmariadb/libmariadb.c index 25b5a4b6..e702c8a2 100644 --- a/libmariadb/libmariadb.c +++ b/libmariadb/libmariadb.c @@ -69,6 +69,13 @@ #endif #include +#undef max_allowed_packet +#undef net_buffer_length +extern ulong max_allowed_packet; /* net.c */ +extern ulong net_buffer_length; /* net.c */ +static MYSQL_PARAMETERS mariadb_internal_parameters= +{&max_allowed_packet, &net_buffer_length, 0}; + static my_bool mysql_client_init=0; static void mysql_close_options(MYSQL *mysql); extern my_bool my_init_done; @@ -2233,7 +2240,7 @@ int mthd_my_read_query_result(MYSQL *mysql) ulong field_count; MYSQL_DATA *fields; ulong length; - DBUG_ENTER("mysql_read_query_result"); + DBUG_ENTER("mthd_my_read_query_result"); if (!mysql || (length = net_safe_read(mysql)) == packet_error) DBUG_RETURN(1); @@ -2276,6 +2283,12 @@ get_info: DBUG_RETURN(0); } +my_bool STDCALL +mysql_read_query_result(MYSQL *mysql) +{ + return test(mysql->methods->db_read_query_result(mysql)) ? 1 : 0; +} + int STDCALL mysql_real_query(MYSQL *mysql, const char *query, unsigned long length) { @@ -3377,6 +3390,12 @@ mysql_get_server_name(MYSQL *mysql) return mariadb_connection(mysql) ? "MariaDB" : "MySQL"; } +MYSQL_PARAMETERS *STDCALL +mysql_get_parameters(void) +{ + return &mariadb_internal_parameters; +} + /* * Default methods for a connection. These methods are * stored in mysql->methods and can be overwritten by diff --git a/libmariadb/libmariadb_exports.def b/libmariadb/libmariadb_exports.def index 202d063a..900e5aec 100644 --- a/libmariadb/libmariadb_exports.def +++ b/libmariadb/libmariadb_exports.def @@ -59,6 +59,7 @@ EXPORTS mysql_ping mysql_stmt_result_metadata mysql_query + mysql_read_query_result mysql_real_connect mysql_real_escape_string mysql_real_query @@ -109,6 +110,7 @@ EXPORTS mysql_get_server_name mysql_get_charset_by_name mysql_get_charset_by_nr + mysql_get_parameters mariadb_convert_string mariadb_dyncol_free mariadb_dyncol_create_many_num diff --git a/libmariadb/net.c b/libmariadb/net.c index daf2197a..54ae355b 100644 --- a/libmariadb/net.c +++ b/libmariadb/net.c @@ -37,6 +37,11 @@ #define MAX_PACKET_LENGTH (256L*256L*256L-1) +/* net_buffer_length and max_allowec_packet are defined in mysql.h + See bug conc-57 +*/ +#undef net_buffer_length +#undef max_allowed_packet ulong max_allowed_packet=1024L * 1024L * 1024L; ulong net_read_timeout= NET_READ_TIMEOUT; ulong net_write_timeout= NET_WRITE_TIMEOUT; diff --git a/libmariadb/version_script.txt b/libmariadb/version_script.txt index 83748c1a..06052c03 100644 --- a/libmariadb/version_script.txt +++ b/libmariadb/version_script.txt @@ -36,6 +36,7 @@ global: mysql_get_client_info; mysql_get_host_info; mysql_get_proto_info; + mysql_get_parameters; mysql_get_server_info; mysql_get_client_version; mysql_get_ssl_cipher; diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index 9ef34e20..4a3d6f35 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -597,7 +597,7 @@ int test_connection_timeout(MYSQL *my) return FAIL; } elapsed= time(NULL) - start; - diag("elapsed: %d, timeout: %d", elapsed, timeout); + diag("elapsed: %u", elapsed); mysql_close(mysql); FAIL_IF(elapsed > timeout + 1, "timeout ignored") return OK;