[patch_done] Patch for Reconnect-Bug in MySQL lib

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
Lidael
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 18.03.2011, 16:21

[patch_done] Patch for Reconnect-Bug in MySQL lib

Post 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
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

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

Mark
Image
Post Reply