diff --git a/include/mysql.h b/include/mysql.h index d71d049f69d..1fc164f62b2 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -848,6 +848,7 @@ int STDCALL mysql_close_start(MYSQL *sock); int STDCALL mysql_close_cont(MYSQL *sock, int status); my_socket STDCALL mysql_get_socket(const MYSQL *mysql); unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql); +unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql); /* status return codes */ #define MYSQL_NO_DATA 100 diff --git a/include/mysql.h.pp b/include/mysql.h.pp index ce577146581..48ce79046ff 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -729,3 +729,4 @@ int mysql_close_start(MYSQL *sock); int mysql_close_cont(MYSQL *sock, int status); my_socket mysql_get_socket(const MYSQL *mysql); unsigned int mysql_get_timeout_value(const MYSQL *mysql); +unsigned int mysql_get_timeout_value_ms(const MYSQL *mysql); diff --git a/sql-common/mysql_async.c b/sql-common/mysql_async.c index c130eab5061..c7e720076ea 100644 --- a/sql-common/mysql_async.c +++ b/sql-common/mysql_async.c @@ -246,6 +246,28 @@ mysql_get_timeout_value(const MYSQL *mysql) } +/* + In 10.0, VIO timeouts are in milliseconds, so we support getting the + millisecond timeout value from async applications. + + In 5.5, timeouts are always in seconds, but we support the 10.0 version + that provides milliseconds, so applications can work with either version + of the library easily. + + When merging this to 10.0, this function must be removed and the 10.0 + version used. +*/ +unsigned int STDCALL +mysql_get_timeout_value_ms(const MYSQL *mysql) +{ + unsigned int timeout= mysql->options.extension->async_context->timeout_value; + if (timeout <= UINT_MAX / 1000) + return timeout*1000; + else + return UINT_MAX; +} + + /* Now create non-blocking definitions for all the calls that may block.