MYSQL_OPT_RECONNECT
| From: | Rasmus Lerdorf | Date: | Sat, 07 Jul 2012 15:20:38 +0000 |
| Subject: | MYSQL_OPT_RECONNECT | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-61113@lists.php.net to get a copy of this message | ||
I spent a bit of time looking at a mismatch between pdo_mysql and
MYSQL_OPT_RECONNECT. There is some rather odd code in
pdo_mysql/mysql_driver.c:
http://lxr.php.net/xref/PHP_5_4/ext/pdo_mysql/mysql_driver.c#640
There are two main problems here
1. This code is inside an if(driver_options) conditional so unless you
pass a driver option to the constructor this code doesn't get run. if it
wasn't for the second bug, we would have this odd side-effect behaviour
that setting any random option would also turn on automatic reconnects
2. The #ifdef MYSQL_OPT_RECONNECT doesn't work at all because MySQL
options are in an enum and thus obviously not available to the preprocessor.
So, because of these bugs when MySQL turned off auto-reconnects in 5.0.3
everyone has been running with them off despite pdo_mysql's intent to
turn them back on. Fixing these bugs now to make the code do what it was
intended to do would be a BC break. My suggestion is to just expose
MYSQL_OPT_RECONNECT as a normal user-settable option (which wouldn't be
available under mysqlnd) and leaving it off by default.
Looking through the bug db this was actually partially reported a while
ago in bug 58863. Johannes/Stas is exposing MYSQL_OPT_RECONNECT ok for
5.3/5.4? I suppose it is a grey area between a feature change and a bug
fix in this case.
-Rasmus