Browse Source

- Fixed a mem-leak in TMySQLConnection.ConnectMySQL
- Added ObtainSQLStatementType to TMySQLConnection.PrepareStatement
- RowsAffected and LastInsertID should be QWord s, not int64

joost 20 years ago
parent
commit
9d7562ff73
1 changed files with 4 additions and 5 deletions
  1. 4 5
      fcl/db/sqldb/mysql/mysql4conn.pas

+ 4 - 5
fcl/db/sqldb/mysql/mysql4conn.pas

@@ -26,8 +26,8 @@ Type
     FNeedData : Boolean;
     FNeedData : Boolean;
     FStatement : String;
     FStatement : String;
     Row : TMYSQL_ROW;
     Row : TMYSQL_ROW;
-    RowsAffected : Int64;
-    LastInsertID : Int64;
+    RowsAffected : QWord;
+    LastInsertID : QWord;
   end;
   end;
 
 
   TMySQLConnection = class (TSQLConnection)
   TMySQLConnection = class (TSQLConnection)
@@ -149,9 +149,7 @@ end;
 procedure TMySQLConnection.ConnectMySQL(var HMySQL : PMySQL;H,U,P : pchar);
 procedure TMySQLConnection.ConnectMySQL(var HMySQL : PMySQL;H,U,P : pchar);
 
 
 begin
 begin
-  if (HMySQL=Nil) then
-    New(HMySQL);
-  mysql_init(HMySQL);
+  HMySQL := mysql_init(HMySQL);
   HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,0,Nil,0);
   HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,0,Nil,0);
   If (HMySQL=Nil) then
   If (HMySQL=Nil) then
     MySQlError(Nil,SErrServerConnectFailed,Self);
     MySQlError(Nil,SErrServerConnectFailed,Self);
@@ -238,6 +236,7 @@ procedure TMySQLConnection.PrepareStatement(cursor: TSQLCursor;
 begin
 begin
   if assigned(AParams) and (AParams.count > 0) then
   if assigned(AParams) and (AParams.count > 0) then
     DatabaseError('Parameters (not) yet supported for the MySQL SqlDB connection.',self);
     DatabaseError('Parameters (not) yet supported for the MySQL SqlDB connection.',self);
+  ObtainSQLStatementType(cursor,buf);
   With Cursor as TMysqlCursor do
   With Cursor as TMysqlCursor do
     begin
     begin
     FStatement:=Buf;
     FStatement:=Buf;