mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:49:20 +02:00
* Fixed compilation for version 5.5 of mysql
git-svn-id: trunk@23246 -
This commit is contained in:
parent
33b6b8eef5
commit
b3de56a540
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
{$h+}
|
{$h+}
|
||||||
|
{$linklib pthread}
|
||||||
|
|
||||||
program digest;
|
program digest;
|
||||||
|
|
||||||
|
@ -6,12 +6,7 @@ unit dbtests;
|
|||||||
Interface
|
Interface
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
{$ifndef ver1_0}
|
mysql55dyn, testu;
|
||||||
mysql4,
|
|
||||||
{$else}
|
|
||||||
mysql,
|
|
||||||
{$endif}
|
|
||||||
testu;
|
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
High-level access
|
High-level access
|
||||||
@ -64,7 +59,7 @@ Uses
|
|||||||
|
|
||||||
|
|
||||||
Var
|
Var
|
||||||
Connection : TMYSQL;
|
Connection : PMYSQL;
|
||||||
|
|
||||||
|
|
||||||
Function ConnectToDatabase(DatabaseName,Host,User,Password,Port : String) : Boolean;
|
Function ConnectToDatabase(DatabaseName,Host,User,Password,Port : String) : Boolean;
|
||||||
@ -80,24 +75,22 @@ begin
|
|||||||
Val(Port,PortNb,Error);
|
Val(Port,PortNb,Error);
|
||||||
if Error<>0 then
|
if Error<>0 then
|
||||||
PortNb:=0;
|
PortNb:=0;
|
||||||
end;
|
end
|
||||||
{$ifdef ver1_0}
|
else
|
||||||
Result:=mysql_connect(@Connection,PChar(Host),PChar(User),PChar(Password))<>Nil;
|
PortNB:=0;
|
||||||
{$else}
|
Connection:=mysql_init(Nil);
|
||||||
mysql_init(@Connection);
|
Result:=mysql_real_connect(Connection,PChar(Host),PChar(User),PChar(Password),Nil,PortNb,Nil,CLIENT_MULTI_RESULTS)<>Nil;
|
||||||
Result:=mysql_real_connect(@Connection,PChar(Host),PChar(User),PChar(Password),Nil,PortNb,Nil,0)<>Nil;
|
|
||||||
{$endif}
|
|
||||||
If Not Result then
|
If Not Result then
|
||||||
begin
|
begin
|
||||||
S:=Strpas(mysql_error(@connection));
|
S:=Strpas(mysql_error(connection));
|
||||||
Verbose(V_ERROR,'Failed to connect to database : '+S);
|
Verbose(V_ERROR,'Failed to connect to database : '+S);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result:=Mysql_select_db(@Connection,Pchar(DatabaseName))>=0;
|
Result:=Mysql_select_db(Connection,Pchar(DatabaseName))>=0;
|
||||||
If Not result then
|
If Not result then
|
||||||
begin
|
begin
|
||||||
S:=StrPas(mysql_error(@connection));
|
S:=StrPas(mysql_error(connection));
|
||||||
DisconnectDatabase;
|
DisconnectDatabase;
|
||||||
Verbose(V_Error,'Failed to select database : '+S);
|
Verbose(V_Error,'Failed to select database : '+S);
|
||||||
end;
|
end;
|
||||||
@ -107,18 +100,18 @@ end;
|
|||||||
Procedure DisconnectDatabase;
|
Procedure DisconnectDatabase;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
mysql_close(@Connection);
|
mysql_close(Connection);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function RunQuery (Qry : String; Var res : TQueryResult) : Boolean ;
|
Function RunQuery (Qry : String; Var res : TQueryResult) : Boolean ;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Verbose(V_DEBUG,'Running query:'+Qry);
|
Verbose(V_DEBUG,'Running query:'+Qry);
|
||||||
Result:=mysql_query(@Connection,PChar(qry))=0;
|
Result:=mysql_query(Connection,PChar(qry))=0;
|
||||||
If Not Result then
|
If Not Result then
|
||||||
Verbose(V_WARNING,'Query : '+Qry+'Failed : '+Strpas(mysql_error(@connection)))
|
Verbose(V_WARNING,'Query : '+Qry+'Failed : '+Strpas(mysql_error(connection)))
|
||||||
else
|
else
|
||||||
Res:=Mysql_store_result(@connection);
|
Res:=Mysql_store_result(connection);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ No warning if it fails }
|
{ No warning if it fails }
|
||||||
@ -126,18 +119,18 @@ Function RunSilentQuery (Qry : String; Var res : TQueryResult) : Boolean ;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Verbose(V_DEBUG,'Running silent query:'+Qry);
|
Verbose(V_DEBUG,'Running silent query:'+Qry);
|
||||||
Result:=mysql_query(@Connection,PChar(qry))=0;
|
Result:=mysql_query(Connection,PChar(qry))=0;
|
||||||
If Not Result then
|
If Not Result then
|
||||||
Verbose(V_DEBUG,'Silent query : '+Qry+'Failed : '+Strpas(mysql_error(@connection)))
|
Verbose(V_DEBUG,'Silent query : '+Qry+'Failed : '+Strpas(mysql_error(connection)))
|
||||||
else
|
else
|
||||||
Res:=Mysql_store_result(@connection);
|
Res:=Mysql_store_result(connection);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function GetResultField (Res : TQueryResult; Id : Integer) : String;
|
Function GetResultField (Res : TQueryResult; Id : Integer) : String;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
Row : TMYSQL_ROW;
|
Row : PPchar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Res=Nil then
|
if Res=Nil then
|
||||||
@ -265,7 +258,7 @@ Var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
If RunQuery(Format(SInsertRun,[OSID,CPUID,VERSIONID,CATEGORYID,SQLDate(Date)]),Res) then
|
If RunQuery(Format(SInsertRun,[OSID,CPUID,VERSIONID,CATEGORYID,SQLDate(Date)]),Res) then
|
||||||
Result:=mysql_insert_id(@connection)
|
Result:=mysql_insert_id(connection)
|
||||||
else
|
else
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
end;
|
end;
|
||||||
@ -444,7 +437,7 @@ begin
|
|||||||
Qry:=Format(SInsertRes,
|
Qry:=Format(SInsertRes,
|
||||||
[TestID,RunID,B[OK],B[Skipped],TestRes,EscapeSQL(Log)]);
|
[TestID,RunID,B[OK],B[Skipped],TestRes,EscapeSQL(Log)]);
|
||||||
If RunSilentQuery(Qry,Res) then
|
If RunSilentQuery(Qry,Res) then
|
||||||
Result:=mysql_insert_id(@connection)
|
Result:=mysql_insert_id(connection)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Qry:=format(SSelectId,[TestId,RunId]);
|
Qry:=format(SSelectId,[TestId,RunId]);
|
||||||
@ -486,4 +479,6 @@ begin
|
|||||||
Result:=RunQuery(Format(SDeleteRun,[ID]),Res);
|
Result:=RunQuery(Format(SDeleteRun,[ID]),Res);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
initialisemysql;
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user