mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
mysqlxx: added timeouts.
This commit is contained in:
parent
4c8f946f70
commit
b45adb47fc
@ -9,6 +9,8 @@
|
||||
|
||||
#include <mysqlxx/Query.h>
|
||||
|
||||
#define MYSQLXX_TIMEOUT 60
|
||||
|
||||
|
||||
namespace mysqlxx
|
||||
{
|
||||
|
@ -41,6 +41,12 @@ void Connection::connect(const char* db,
|
||||
if (!mysql_init(&driver))
|
||||
throw ConnectionFailed(mysql_error(&driver), mysql_errno(&driver));
|
||||
|
||||
/// Установим таймауты
|
||||
unsigned int timeout = MYSQLXX_TIMEOUT;
|
||||
if (!mysql_options(&driver, MYSQL_OPT_CONNECT_TIMEOUT, &timeout)
|
||||
|| !mysql_options(&driver, MYSQL_OPT_READ_TIMEOUT, &timeout))
|
||||
throw ConnectionFailed(mysql_error(&driver), mysql_errno(&driver));
|
||||
|
||||
if (!mysql_real_connect(&driver, server, user, password, db, port, NULL, driver.client_flag))
|
||||
throw ConnectionFailed(mysql_error(&driver), mysql_errno(&driver));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user