Suppress error dialog when process is already gone. Fixes issue #2362.

This commit is contained in:
Ansgar Becker
2011-06-09 17:24:15 +00:00
parent c5ac79f647
commit d3ea4111a3
2 changed files with 25 additions and 6 deletions

View File

@ -396,6 +396,7 @@ type
function GetThreadId: Cardinal; virtual; abstract;
function GetCharacterSet: String; virtual; abstract;
procedure SetCharacterSet(CharsetName: String); virtual; abstract;
function GetLastErrorCode: Cardinal; virtual; abstract;
function GetLastError: String; virtual; abstract;
function GetServerVersionStr: String;
function GetServerVersionInt: Integer; virtual; abstract;
@ -450,6 +451,7 @@ type
property ConnectionUptime: Integer read GetConnectionUptime;
property ServerUptime: Integer read GetServerUptime;
property CharacterSet: String read GetCharacterSet write SetCharacterSet;
property LastErrorCode: Cardinal read GetLastErrorCode;
property LastError: String read GetLastError;
property ServerOS: String read FServerOS;
property ServerVersionUntouched: String read FServerVersionUntouched;
@ -500,6 +502,7 @@ type
function GetThreadId: Cardinal; override;
function GetCharacterSet: String; override;
procedure SetCharacterSet(CharsetName: String); override;
function GetLastErrorCode: Cardinal; override;
function GetLastError: String; override;
function GetServerVersionInt: Integer; override;
function GetAllDatabases: TStringList; override;
@ -528,6 +531,7 @@ type
function GetThreadId: Cardinal; override;
function GetCharacterSet: String; override;
procedure SetCharacterSet(CharsetName: String); override;
function GetLastErrorCode: Cardinal; override;
function GetLastError: String; override;
function GetServerVersionInt: Integer; override;
function GetAllDatabases: TStringList; override;
@ -1566,6 +1570,18 @@ begin
end;
function TMySQLConnection.GetLastErrorCode: Cardinal;
begin
Result := mysql_errno(FHandle);
end;
function TAdoDBConnection.GetLastErrorCode: Cardinal;
begin
Result := FAdoHandle.Errors[FAdoHandle.Errors.Count-1].NativeError;
end;
{**
Return the last error nicely formatted
}
@ -1584,7 +1600,7 @@ begin
Msg := Msg + CRLF + CRLF + Additional;
end;
rx.Free;
Result := Format(MsgSQLError, [mysql_errno(FHandle), Msg]);
Result := Format(MsgSQLError, [LastErrorCode, Msg]);
end;
@ -1602,7 +1618,7 @@ begin
if rx.Exec(Msg) then
Msg := rx.Match[1];
rx.Free;
Result := Format(MsgSQLError, [E.NativeError, Msg]);
Result := Format(MsgSQLError, [LastErrorCode, Msg]);
end;

View File

@ -4506,23 +4506,26 @@ var
t: Boolean;
pid: String;
Node: PVirtualNode;
Conn: TDBConnection;
begin
t := TimerRefresh.Enabled;
TimerRefresh.Enabled := false; // prevent av (ListProcesses.selected...)
Conn := ActiveConnection;
if MessageDialog('Kill '+IntToStr(ListProcesses.SelectedCount)+' Process(es)?', mtConfirmation, [mbok,mbcancel]) = mrok then
begin
Node := GetNextNode(ListProcesses, nil, True);
while Assigned(Node) do begin
pid := ListProcesses.Text[Node, ListProcesses.Header.MainColumn];
// Don't kill own process
if pid = IntToStr(ActiveConnection.ThreadId) then
if pid = IntToStr(Conn.ThreadId) then
LogSQL('Ignoring own process id #'+pid+' when trying to kill it.')
else try
ActiveConnection.Query('KILL '+pid);
Conn.Query('KILL '+pid);
except
on E:EDatabaseError do begin
if MessageDialog(E.Message, mtError, [mbOK, mbAbort]) = mrAbort then
break;
if Conn.LastErrorCode <> 1094 then
if MessageDialog(E.Message, mtError, [mbOK, mbAbort]) = mrAbort then
break;
end;
end;
Node := GetNextNode(ListProcesses, Node, True);