summaryrefslogtreecommitdiff
path: root/_mysql.c
diff options
context:
space:
mode:
authorJean Schurger <jean@schurger.org>2012-10-04 14:20:06 -0400
committerfarcepest <farcepest@gmail.com>2012-10-04 14:32:06 -0400
commit119b6b2c97a57d6aee3dc070f724791936afe54b (patch)
treee03d394f240252bfe8a32c335e481704c96f2518 /_mysql.c
parent4e6c7c0e087242193e538dcec4f4993983e811f0 (diff)
parent417088a3aa3a2591ebb2589e8bca2582246afcb7 (diff)
downloadmysqldb1-119b6b2c97a57d6aee3dc070f724791936afe54b.tar.gz
Merge with jeansch/master
Diffstat (limited to '_mysql.c')
-rw-r--r--_mysql.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/_mysql.c b/_mysql.c
index b721a66..fc0ce24 100644
--- a/_mysql.c
+++ b/_mysql.c
@@ -118,6 +118,12 @@ static int _mysql_server_init_done = 0;
#define HAVE_OPENSSL 1
#endif
+/* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
+ The MYSQL_OPT_READ_TIMEOUT apear in the version 5.1.12 */
+#if MYSQL_VERSION_ID > 50112
+#define HAVE_MYSQL_OPT_READ_TIMEOUT 1
+#endif
+
PyObject *
_mysql_Exception(_mysql_ConnectionObject *c)
{
@@ -557,8 +563,14 @@ _mysql_ConnectionObject_Initialize(
"read_default_file", "read_default_group",
"client_flag", "ssl",
"local_infile",
+#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
+ "read_timeout",
+#endif
NULL } ;
int connect_timeout = 0;
+#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
+ int read_timeout = 0;
+#endif
int compress = -1, named_pipe = -1, local_infile = -1;
char *init_command=NULL,
*read_default_file=NULL,
@@ -567,7 +579,13 @@ _mysql_ConnectionObject_Initialize(
self->converter = NULL;
self->open = 0;
check_server_init(-1);
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiisssiOi:connect",
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
+ "|ssssisOiiisssiOii:connect",
+#else
+ "|ssssisOiiisssiOi:connect",
+#endif
kwlist,
&host, &user, &passwd, &db,
&port, &unix_socket, &conv,
@@ -576,8 +594,11 @@ _mysql_ConnectionObject_Initialize(
&init_command, &read_default_file,
&read_default_group,
&client_flag, &ssl,
- &local_infile /* DO NOT PATCH FOR RECONNECT, IDIOTS
+ &local_infile, /* DO NOT PATCH FOR RECONNECT, IDIOTS
IF YOU DO THIS, I WILL NOT SUPPORT YOUR PACKAGES. */
+#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
+ &read_timeout
+#endif
))
return -1;
@@ -613,6 +634,13 @@ _mysql_ConnectionObject_Initialize(
mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT,
(char *)&timeout);
}
+#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
+ if (read_timeout) {
+ unsigned int timeout = read_timeout;
+ mysql_options(&(self->connection), MYSQL_OPT_READ_TIMEOUT,
+ (char *)&timeout);
+ }
+#endif
if (compress != -1) {
mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0);
client_flag |= CLIENT_COMPRESS;