]> granicus.if.org Git - php/commitdiff
MFH: fix #41083 (mysql_ping() requires MYSQL_OPT_RECONNECT to be set since MySQL...
authorAntony Dovgal <tony2001@php.net>
Sat, 14 Apr 2007 10:19:19 +0000 (10:19 +0000)
committerAntony Dovgal <tony2001@php.net>
Sat, 14 Apr 2007 10:19:19 +0000 (10:19 +0000)
NEWS
ext/mysql/php_mysql.c

diff --git a/NEWS b/NEWS
index e2e19095e51dae4306e5befe3e2a9f547de0633b..22db2104ac404ffc9328365277c19073c8f86d71 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Apr 2007, PHP 5.2.2RC2
+- Fixed bug #41083 (mysql_ping() requires MYSQL_OPT_RECONNECT to be set since 
+  MySQL 5.0.13). (xiaojb at gmail dot com, Tony)
 - Fixed bug #41075 (memleak when creating default object caused exception). 
   (Dmitry)
 - Fixed bug #41063 (chdir doesn't like root paths). (Dmitry)
index 91df858c96832f39f89f120368aceeeea8787f45..b0e54ad47bfb154e1939975544759395a387c8bf 100644 (file)
@@ -486,6 +486,9 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
        php_mysql_conn *mysql=NULL;
 #if MYSQL_VERSION_ID <= 32230
        void (*handler) (int);
+#endif
+#if MYSQL_VERSION_ID > 50012
+       my_bool my_true = 1;
 #endif
        zval **z_host=NULL, **z_user=NULL, **z_passwd=NULL, **z_new_link=NULL, **z_client_flags=NULL;
        zend_bool free_host=0, new_link=0;
@@ -669,8 +672,14 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                        mysql_init(&mysql->conn);
 
-                       if (connect_timeout != -1)
+#if MYSQL_VERSION_ID > 50012
+                       /* Reconnect has been off by default since MySQL 5.0.3; 
+                          this option is new in 5.0.13 and provides a way to set reconnection behavior explicitly. */
+                       mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, (const char *)&my_true);
+#endif
+                       if (connect_timeout != -1) {
                                mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+                       }
 
                        if (mysql_real_connect(&mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
 #else
@@ -774,8 +783,15 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                mysql_init(&mysql->conn);
 
-               if (connect_timeout != -1)
-                               mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+#if MYSQL_VERSION_ID > 50012
+               /* Reconnect has been off by default since MySQL 5.0.3; 
+                this option is new in 5.0.13 and provides a way to set reconnection behavior explicitly. */
+               mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, (const char *)&my_true);
+#endif
+
+               if (connect_timeout != -1) {
+                       mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+               }
 
                if (mysql_real_connect(&mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
 #else