Page 1 of 1

[patch_done] Patch for Reconnect-Bug in MySQL lib

Posted: 20.03.2011, 15:32
by Lidael
This Patch should fix the bug in the mysqllib Versions 5.0.13-5.0.18 and <5.1.6 with the MYSQL_OPT_RECONNECT Flag being resettet by mysql_real_connect.
See note on MYSQL_OPT_RECONNECT on:
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
http://dev.mysql.com/doc/refman/5.1/en/ ... tions.html

Code: Select all

Index: ZDbcMySql.pas
===================================================================
--- ZDbcMySql.pas	(revision 879)
+++ ZDbcMySql.pas	(working copy)
@@ -356,6 +356,7 @@
   sMyOpt: string;
   my_client_Opt:TMYSQL_CLIENT_OPTIONS;
   sMy_client_Opt:String;
+  ClientVersion: Integer;
 begin
    if not Closed then
       Exit;
@@ -461,6 +462,15 @@
     end;
     DriverManager.LogMessage(lcConnect, FPlainDriver.GetProtocol, LogMessage);
 
+    { Fix Bugs in certain Versions where real_conncet resets the Reconnect flag }
+    if StrToBoolEx(Info.Values['MYSQL_OPT_RECONNECT']) then
+    begin
+      ClientVersion := FPlainDriver.GetClientVersion;
+      if ((ClientVersion>=50013) and (ClientVersion<50019)) or
+         ((ClientVersion>=50100) and (ClientVersion<50106)) then
+        FPlainDriver.SetOptions(FHandle, MYSQL_OPT_RECONNECT, 'true');
+    end;
+
     { Sets a client codepage. }
     if FClientCodePage <> '' then
     begin

Posted: 02.04.2011, 21:47
by mdaems
Hi,

I committed your patch in SVN testing branch revision 880 two nights ago.

Mark