Hi,
The mysqlconn.inc uses macros. This is unnecessary and has some disadvantages.
Here is a patch that replaces the macros with simple type aliases.
As far as I can see mysqlconn.inc is the same for fpc 2.3.1 and fpc 2.2.x, so
the patch should work for both.
Mattias
Index: packages/fcl-db/src/sqldb/mysql/mysqlconn.inc
===
--- packages/fcl-db/src/sqldb/mysql/mysqlconn.inc (revision 12078)
+++ packages/fcl-db/src/sqldb/mysql/mysqlconn.inc (working copy)
@@ -1,6 +1,5 @@
{$mode objfpc}{$H+}
-{$MACRO on}
interface
@@ -8,30 +7,14 @@
Classes, SysUtils,bufdataset,sqldb,db,dynlibs,
{$IfDef mysql50}
mysql50dyn;
- {$DEFINE TConnectionName:=TMySQL50Connection}
- {$DEFINE TMySQLConnectionDef:=TMySQL50ConnectionDef}
- {$DEFINE TTransactionName:=TMySQL50Transaction}
- {$DEFINE TCursorName:=TMySQL50Cursor}
{$ELSE}
{$IfDef mysql41}
mysql41dyn;
-{$DEFINE TConnectionName:=TMySQL41Connection}
-{$DEFINE TMySQLConnectionDef:=TMySQL41ConnectionDef}
-{$DEFINE TTransactionName:=TMySQL41Transaction}
-{$DEFINE TCursorName:=TMySQL41Cursor}
{$ELSE}
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
mysql40dyn;
- {$DEFINE TConnectionName:=TMySQLConnection}
- {$DEFINE TMySQLConnectionDef:=TMySQL40ConnectionDef}
- {$DEFINE TTransactionName:=TMySQLTransaction}
- {$DEFINE TCursorName:=TMySQLCursor}
{$ELSE}
mysql40dyn;
- {$DEFINE TConnectionName:=TMySQL40Connection}
- {$DEFINE TMySQLConnectionDef:=TMySQL40ConnectionDef}
- {$DEFINE TTransactionName:=TMySQL40Transaction}
- {$DEFINE TCursorName:=TMySQL40Cursor}
{$EndIf}
{$EndIf}
{$EndIf}
@@ -149,6 +132,33 @@
EMySQLError = Class(Exception);
+{$IfDef mysql50}
+ TMySQL50Connection = TConnectionName;
+ TMySQL50ConnectionDef = TMySQLConnectionDef;
+ TMySQL50Transaction = TTransactionName;
+ TMySQL50Cursor = TCursorName;
+{$ELSE}
+ {$IfDef mysql41}
+TMySQL41Connection = TConnectionName;
+TMySQL41ConnectionDef = TMySQLConnectionDef;
+TMySQL41Transaction = TTransactionName;
+TMySQL41Cursor = TCursorName;
+ {$ELSE}
+{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
+ TMySQLConnection = TConnectionName;
+ TMySQL40ConnectionDef = TMySQLConnectionDef;
+ TMySQLTransaction = TTransactionName;
+ TMySQLCursor = TCursorName;
+{$ELSE}
+ TMySQL40Connection = TConnectionName;
+ TMySQL40ConnectionDef = TMySQLConnectionDef;
+ TMySQL40Transaction = TTransactionName;
+ TMySQL40Cursor = TCursorName;
+{$EndIf}
+ {$EndIf}
+{$EndIf}
+
+
implementation
uses dbconst,ctypes,strutils;
@@ -349,7 +359,19 @@
function TConnectionName.AllocateCursorHandle: TSQLCursor;
begin
- Result:=TCursorName.Create;
+ {$IfDef mysql50}
+Result:=TMySQL50Cursor.Create;
+ {$ELSE}
+{$IfDef mysql41}
+ Result:=TMySQL41Cursor.Create;
+{$ELSE}
+ {$IFDEF mysql4} // temporary backwards compatibility for Lazarus
+Result:=TMySQLCursor.Create;
+ {$ELSE}
+Result:=TMySQL40Cursor.Create;
+ {$EndIf}
+{$EndIf}
+ {$EndIf}
end;
Procedure TConnectionName.DeAllocateCursorHandle(var cursor : TSQLCursor);
@@ -957,7 +979,19 @@
class function TMySQLConnectionDef.ConnectionClass: TSQLConnectionClass;
begin
- Result:=TConnectionName;
+ {$IfDef mysql50}
+Result:=TMySQL50Connection;
+ {$ELSE}
+{$IfDef mysql41}
+ Result:=TMySQL41Connection;
+{$ELSE}
+ {$IFDEF mysql4} // temporary backwards compatibility for Lazarus
+Result:=TMySQLConnection;
+ {$ELSE}
+Result:=TMySQL40Connection;
+ {$EndIf}
+{$EndIf}
+ {$EndIf}
end;
class function TMySQLConnectionDef.Description: String;
@@ -965,8 +999,30 @@
Result:='Connect to a MySQL '+MySQLVersion+'database directly via the client library';
end;
-initialization
- RegisterConnection(TMySQLConnectionDef);
-finalization
- UnRegisterConnection(TMySQLConnectionDef);
+{$IfDef mysql50}
+ initialization
+RegisterConnection(TMySQL50ConnectionDef);
+ finalization
+UnRegisterConnection(TMySQL50ConnectionDef);
+{$ELSE}
+ {$IfDef mysql41}
+initialization
+ RegisterConnection(TMySQL41ConnectionDef);
+finalization
+ UnRegisterConnection(TMySQL41ConnectionDef);
+ {$ELSE}
+{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
+ initialization
+RegisterConnection(TMySQL40ConnectionDef);
+ finalization
+UnRegisterConnection(TMySQL40ConnectionDef);
+{$ELSE}
+ initialization
+RegisterConnection(TMySQL40ConnectionDef);
+ finalization
+UnRegisterConnection(TMySQL40ConnectionDef);
+{$EndIf}
+ {$EndIf}
+{$EndIf}
+
end.
___
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel