mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
* Bugfix: Properly propagate exception when editing forbidden (access denied) data in a grid.
* Cosmetic: Fix haywire indentation in TMysqlQueryThread.Execute.
This commit is contained in:
@ -5268,6 +5268,8 @@ begin
|
||||
end;
|
||||
|
||||
procedure TMDIChild.RunAsyncPost(ds: TDeferDataSet);
|
||||
var
|
||||
res: TMysqlQuery;
|
||||
begin
|
||||
FQueryRunning := true;
|
||||
try
|
||||
@ -5280,8 +5282,12 @@ begin
|
||||
end;
|
||||
FProgressForm := TFrmQueryProgress.Create(Self);
|
||||
debug('RunThreadedQuery(): Launching asynchronous query.');
|
||||
ExecPostAsync(FConn,nil,FProgressForm.Handle,ds);
|
||||
res := ExecPostAsync(FConn,nil,FProgressForm.Handle,ds);
|
||||
WaitForQueryCompletion(FProgressForm);
|
||||
if res.Result in [MQR_CONNECT_FAIL,MQR_QUERY_FAIL] then
|
||||
begin
|
||||
raise Exception.Create(res.Comment);
|
||||
end;
|
||||
finally
|
||||
FQueryRunning := false;
|
||||
end;
|
||||
|
@ -77,7 +77,7 @@ type
|
||||
|
||||
function ExecMysqlStatementAsync(ASql : String; AConn : TOpenConnProf; ANotifyProc : TMysqlQueryNotificationEvent; AWndHandle : THandle; Callback: TAsyncPostRunner) : TMysqlQuery;
|
||||
function ExecMysqlStatementBlocking(ASql : String; AConn : TOpenConnProf; AWndHandle : THandle) : TMysqlQuery;
|
||||
procedure ExecPostAsync(AConn : TOpenConnProf; ANotifyProc : TMysqlQueryNotificationEvent; AWndHandle : THandle; ds: TDeferDataSet);
|
||||
function ExecPostAsync(AConn : TOpenConnProf; ANotifyProc : TMysqlQueryNotificationEvent; AWndHandle : THandle; ds: TDeferDataSet): TMysqlQuery;
|
||||
|
||||
|
||||
implementation
|
||||
@ -111,13 +111,11 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure ExecPostAsync(AConn : TOpenConnProf; ANotifyProc : TMysqlQueryNotificationEvent; AWndHandle : THandle; ds: TDeferDataSet);
|
||||
var
|
||||
q: TMysqlQuery;
|
||||
function ExecPostAsync(AConn : TOpenConnProf; ANotifyProc : TMysqlQueryNotificationEvent; AWndHandle : THandle; ds: TDeferDataSet): TMysqlQuery;
|
||||
begin
|
||||
q := TMysqlQuery.Create(nil,@AConn);
|
||||
q.OnNotify := ANotifyProc;
|
||||
q.Query('',MQM_ASYNC,AWndHandle,nil,ds);
|
||||
Result := TMysqlQuery.Create(nil,@AConn);
|
||||
Result.OnNotify := ANotifyProc;
|
||||
Result.Query('',MQM_ASYNC,AWndHandle,nil,ds);
|
||||
end;
|
||||
|
||||
{***
|
||||
|
@ -195,10 +195,8 @@ var
|
||||
qr : TThreadResult;
|
||||
begin
|
||||
debug(Format('qry: Setting result and posting status %d via WM_MYSQL_THREAD_NOTIFY message', [AEvent]));
|
||||
if self.FPostDataSet = nil then begin
|
||||
qr := AssembleResult();
|
||||
TMysqlQuery(FOwner).SetThreadResult(qr);
|
||||
end;
|
||||
qr := AssembleResult();
|
||||
TMysqlQuery(FOwner).SetThreadResult(qr);
|
||||
PostMessage(FNotifyWndHandle,WM_MYSQL_THREAD_NOTIFY,Integer(FOwner),AEvent);
|
||||
end;
|
||||
|
||||
@ -206,52 +204,47 @@ procedure TMysqlQueryThread.Execute;
|
||||
var
|
||||
q : TDeferDataSet;
|
||||
r : Boolean;
|
||||
e : TExceptionData;
|
||||
ex : TExceptionData;
|
||||
begin
|
||||
debug(Format('qry: Thread %d running...', [ThreadID]));
|
||||
NotifyStatus(MQE_INITED);
|
||||
|
||||
try
|
||||
if not FMysqlConn.Connected then
|
||||
FMysqlConn.Connect();
|
||||
if not FMysqlConn.Connected then FMysqlConn.Connect();
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
SetState (MQR_CONNECT_FAIL,Format('%s',[E.Message]));
|
||||
end;
|
||||
on E: Exception do begin
|
||||
SetState (MQR_CONNECT_FAIL,Format('%s',[E.Message]));
|
||||
end;
|
||||
end;
|
||||
|
||||
if FMysqlConn.Connected then
|
||||
begin
|
||||
NotifyStatus (MQE_STARTED);
|
||||
|
||||
q := nil;
|
||||
if FPostDataSet <> nil then FPostDataSet.DoAsync
|
||||
else begin
|
||||
if ExpectResultSet(FSql) then
|
||||
begin
|
||||
r := RunDataQuery (FSql,TDataSet(q),e,FCallback);
|
||||
|
||||
if r then
|
||||
begin
|
||||
if q.State=dsBrowse then
|
||||
begin
|
||||
// WTF?
|
||||
end;
|
||||
end;
|
||||
|
||||
end
|
||||
else
|
||||
r := RunUpdateQuery (FSql,TDataSet(q),e,FCallBack);
|
||||
TMysqlQuery(FOwner).SetMysqlDataset(q);
|
||||
|
||||
if r then
|
||||
SetState (MQR_SUCCESS,'SUCCESS')
|
||||
else
|
||||
SetState (MQR_QUERY_FAIL,e.Msg);
|
||||
if FMysqlConn.Connected then begin
|
||||
NotifyStatus (MQE_STARTED);
|
||||
|
||||
q := nil;
|
||||
if FPostDataSet <> nil then begin
|
||||
try
|
||||
FPostDataSet.DoAsync;
|
||||
SetState (MQR_SUCCESS,'SUCCESS')
|
||||
except
|
||||
on E: Exception do begin
|
||||
SetState (MQR_QUERY_FAIL,Format('%s', [E.Message]));
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
if ExpectResultSet(FSql) then begin
|
||||
r := RunDataQuery (FSql,TDataSet(q),ex,FCallback);
|
||||
if r then begin
|
||||
if q.State=dsBrowse then begin
|
||||
// WTF?
|
||||
end;
|
||||
end;
|
||||
end else r := RunUpdateQuery (FSql,TDataSet(q),ex,FCallBack);
|
||||
TMysqlQuery(FOwner).SetMysqlDataset(q);
|
||||
|
||||
if r then SetState (MQR_SUCCESS,'SUCCESS')
|
||||
else SetState (MQR_QUERY_FAIL,ex.Msg);
|
||||
end;
|
||||
end;
|
||||
|
||||
NotifyStatus (MQE_FINISHED);
|
||||
NotifyStatus (MQE_FREED);
|
||||
|
Reference in New Issue
Block a user