mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 06:29:16 +02:00
sqldb: implemented TCustomConnection.Close(ForceClose : Boolean = False);
git-svn-id: trunk@23728 -
This commit is contained in:
parent
43e0116f61
commit
bb735aa7e5
@ -541,9 +541,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomConnection.Close;
|
procedure TCustomConnection.Close(ForceClose : Boolean = False);
|
||||||
begin
|
begin
|
||||||
|
try
|
||||||
|
ForcedClose:=ForceClose;
|
||||||
Connected := False;
|
Connected := False;
|
||||||
|
finally
|
||||||
|
ForcedClose:=false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCustomConnection.Destroy;
|
destructor TCustomConnection.Destroy;
|
||||||
|
@ -1882,6 +1882,7 @@ type
|
|||||||
FAfterDisconnect: TNotifyEvent;
|
FAfterDisconnect: TNotifyEvent;
|
||||||
FBeforeConnect: TNotifyEvent;
|
FBeforeConnect: TNotifyEvent;
|
||||||
FBeforeDisconnect: TNotifyEvent;
|
FBeforeDisconnect: TNotifyEvent;
|
||||||
|
FForcedClose: Boolean;
|
||||||
FLoginPrompt: Boolean;
|
FLoginPrompt: Boolean;
|
||||||
FOnLogin: TLoginEvent;
|
FOnLogin: TLoginEvent;
|
||||||
FStreamedConnected: Boolean;
|
FStreamedConnected: Boolean;
|
||||||
@ -1898,9 +1899,10 @@ type
|
|||||||
procedure InternalHandleException; virtual;
|
procedure InternalHandleException; virtual;
|
||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
procedure SetConnected (Value : boolean); virtual;
|
procedure SetConnected (Value : boolean); virtual;
|
||||||
|
property ForcedClose : Boolean read FForcedClose write FForcedClose;
|
||||||
property Streamedconnected: Boolean read FStreamedConnected write FStreamedConnected;
|
property Streamedconnected: Boolean read FStreamedConnected write FStreamedConnected;
|
||||||
public
|
public
|
||||||
procedure Close;
|
procedure Close(ForceClose: Boolean=False);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Open;
|
procedure Open;
|
||||||
property DataSetCount: Longint read GetDataSetCount;
|
property DataSetCount: Longint read GetDataSetCount;
|
||||||
|
@ -572,7 +572,16 @@ begin
|
|||||||
C.FStatement := stringsreplace(C.FStatement,ParamNames,ParamValues,[rfReplaceAll]);
|
C.FStatement := stringsreplace(C.FStatement,ParamNames,ParamValues,[rfReplaceAll]);
|
||||||
end;
|
end;
|
||||||
if mysql_query(FMySQL,Pchar(C.FStatement))<>0 then
|
if mysql_query(FMySQL,Pchar(C.FStatement))<>0 then
|
||||||
|
begin
|
||||||
|
if not ForcedClose then
|
||||||
MySQLError(FMYSQL,SErrExecuting,Self)
|
MySQLError(FMYSQL,SErrExecuting,Self)
|
||||||
|
else //don't return a resulset. We are shutting down, not opening.
|
||||||
|
begin
|
||||||
|
C.RowsAffected:=0;
|
||||||
|
C.FSelectable:= False;
|
||||||
|
C.FRes:=nil;
|
||||||
|
end;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
C.RowsAffected := mysql_affected_rows(FMYSQL);
|
C.RowsAffected := mysql_affected_rows(FMYSQL);
|
||||||
@ -581,7 +590,17 @@ begin
|
|||||||
repeat
|
repeat
|
||||||
Res:=mysql_store_result(FMySQL); //returns a null pointer also if the statement didn't return a result set
|
Res:=mysql_store_result(FMySQL); //returns a null pointer also if the statement didn't return a result set
|
||||||
if mysql_errno(FMySQL)<>0 then
|
if mysql_errno(FMySQL)<>0 then
|
||||||
MySQLError(FMySQL, SErrGettingResult, Self);
|
begin
|
||||||
|
if not ForcedClose then
|
||||||
|
MySQLError(FMySQL, SErrGettingResult, Self)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
C.RowsAffected:=0;
|
||||||
|
C.FSelectable:= False;
|
||||||
|
C.FRes:=nil;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if Res<>nil then
|
if Res<>nil then
|
||||||
begin
|
begin
|
||||||
mysql_free_result(C.FRes);
|
mysql_free_result(C.FRes);
|
||||||
@ -1145,7 +1164,7 @@ end;
|
|||||||
function TConnectionName.Commit(trans: TSQLHandle): boolean;
|
function TConnectionName.Commit(trans: TSQLHandle): boolean;
|
||||||
begin
|
begin
|
||||||
//mysql_commit(FMySQL);
|
//mysql_commit(FMySQL);
|
||||||
Result := mysql_query(FMySQL, 'COMMIT') = 0;
|
Result := (mysql_query(FMySQL, 'COMMIT') = 0) or ForcedClose;
|
||||||
if not Result then
|
if not Result then
|
||||||
MySQLError(FMySQL, SErrExecuting, Self);
|
MySQLError(FMySQL, SErrExecuting, Self);
|
||||||
end;
|
end;
|
||||||
@ -1153,7 +1172,7 @@ end;
|
|||||||
function TConnectionName.RollBack(trans: TSQLHandle): boolean;
|
function TConnectionName.RollBack(trans: TSQLHandle): boolean;
|
||||||
begin
|
begin
|
||||||
//mysql_rollback(FMySQL);
|
//mysql_rollback(FMySQL);
|
||||||
Result := mysql_query(FMySQL, 'ROLLBACK') = 0;
|
Result := (mysql_query(FMySQL, 'ROLLBACK') = 0) or ForcedClose;
|
||||||
if not Result then
|
if not Result then
|
||||||
MySQLError(FMySQL, SErrExecuting, Self);
|
MySQLError(FMySQL, SErrExecuting, Self);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user