mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 18:12:05 +08:00
Nuke ExpectResultSet. Opted not to disable the mysql driver exceptions in zeos, instead used Anse's TZConnection.GetAffectedRowsFromLastPost().
(Messing with the internals here, please test...)
This commit is contained in:
@ -2808,27 +2808,19 @@ begin
|
|||||||
// ok, let's rock
|
// ok, let's rock
|
||||||
SQLstart := GetTickCount();
|
SQLstart := GetTickCount();
|
||||||
try
|
try
|
||||||
if ( ExpectResultSet( SQL[i] ) ) then
|
|
||||||
begin
|
|
||||||
ds := GetResults( SQL[i], false, false );
|
ds := GetResults( SQL[i], false, false );
|
||||||
gridQuery.DataSource.DataSet := ds;
|
gridQuery.DataSource.DataSet := ds;
|
||||||
if ( ds <> nil ) then
|
if ( ds <> nil ) then
|
||||||
begin
|
begin
|
||||||
fieldcount := ds.Fieldcount;
|
fieldcount := ds.Fieldcount;
|
||||||
recordcount := ds.Recordcount;
|
recordcount := ds.Recordcount;
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
fieldcount := 0;
|
|
||||||
recordcount := 0;
|
|
||||||
end;
|
|
||||||
rowsaffected := rowsaffected + TZQuery(ds).RowsAffected;
|
rowsaffected := rowsaffected + TZQuery(ds).RowsAffected;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
rowsaffected := rowsaffected + ExecUpdateQuery( SQL[i], false, false );
|
|
||||||
fieldcount := 0;
|
fieldcount := 0;
|
||||||
recordcount := 0;
|
recordcount := 0;
|
||||||
|
rowsaffected := FMysqlConn.Connection.GetAffectedRowsFromLastPost;
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
on E:Exception do
|
on E:Exception do
|
||||||
@ -5050,7 +5042,7 @@ begin
|
|||||||
try
|
try
|
||||||
// Start query execution
|
// Start query execution
|
||||||
MysqlQuery := RunThreadedQuery(sql);
|
MysqlQuery := RunThreadedQuery(sql);
|
||||||
Result := TZQuery(MysqlQuery.MysqlDataset).RowsAffected;
|
Result := FMysqlConn.Connection.GetAffectedRowsFromLastPost;
|
||||||
// Inspect query result code and log / notify user on failure
|
// Inspect query result code and log / notify user on failure
|
||||||
if MysqlQuery.Result in [MQR_CONNECT_FAIL,MQR_QUERY_FAIL] then
|
if MysqlQuery.Result in [MQR_CONNECT_FAIL,MQR_QUERY_FAIL] then
|
||||||
begin
|
begin
|
||||||
|
@ -74,7 +74,6 @@ type
|
|||||||
function maskSql(sql_version: integer; str: String) : String;
|
function maskSql(sql_version: integer; str: String) : String;
|
||||||
procedure ActivateWindow(Window : HWnd);
|
procedure ActivateWindow(Window : HWnd);
|
||||||
procedure ShellExec( cmd: String; path: String = '' );
|
procedure ShellExec( cmd: String; path: String = '' );
|
||||||
function ExpectResultSet(ASql: String): Boolean;
|
|
||||||
function getFirstWord( text: String ): String;
|
function getFirstWord( text: String ): String;
|
||||||
function ConvertWindowsCodepageToMysqlCharacterSet(codepage: Cardinal): string;
|
function ConvertWindowsCodepageToMysqlCharacterSet(codepage: Cardinal): string;
|
||||||
function GetFieldValue( Field: TField ): String;
|
function GetFieldValue( Field: TField ): String;
|
||||||
@ -1885,55 +1884,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{***
|
|
||||||
Checks if the SQL will bring up any resultset.
|
|
||||||
Important to know for deciding on whether to do a
|
|
||||||
ZQuery.Open or ZQuery.ExecSQL
|
|
||||||
|
|
||||||
@param string (part of) SQL-query
|
|
||||||
@return boolean
|
|
||||||
@see TMDIChild:ExecSQLClick
|
|
||||||
@see TMysqlQueryThread:Execute
|
|
||||||
}
|
|
||||||
function ExpectResultSet(ASql: String): Boolean;
|
|
||||||
const
|
|
||||||
RESULTSET_KEYWORDS : array[0..11] of string[10] =
|
|
||||||
(
|
|
||||||
'ANALYZE',
|
|
||||||
'CALL',
|
|
||||||
'CHECK',
|
|
||||||
'DESC',
|
|
||||||
'DESCRIBE',
|
|
||||||
'EXECUTE',
|
|
||||||
'EXPLAIN',
|
|
||||||
'HELP',
|
|
||||||
'OPTIMIZE',
|
|
||||||
'REPAIR',
|
|
||||||
'SELECT',
|
|
||||||
'SHOW'
|
|
||||||
);
|
|
||||||
NOTRESULTSET_SENTENCE : string[12] = 'INTO OUTFILE';
|
|
||||||
var
|
|
||||||
kw : String;
|
|
||||||
i : Integer;
|
|
||||||
begin
|
|
||||||
Result := False;
|
|
||||||
|
|
||||||
// Find keyword and check existance in const-array of resultset-keywords
|
|
||||||
kw := UpperCase( getFirstWord( ASql ) );
|
|
||||||
for i := Low(RESULTSET_KEYWORDS) to High(RESULTSET_KEYWORDS) do
|
|
||||||
begin
|
|
||||||
if kw = RESULTSET_KEYWORDS[i] then
|
|
||||||
begin
|
|
||||||
Result := True;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if Pos(NOTRESULTSET_SENTENCE, UpperCase(ASql)) > 0 then Result := False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{***
|
{***
|
||||||
Returns first word of a given text
|
Returns first word of a given text
|
||||||
@param string Given text
|
@param string Given text
|
||||||
|
@ -4,6 +4,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Messages, Forms, Db, Classes, ZConnection, ZDataSet, StdCtrls, SysUtils,
|
Windows, Messages, Forms, Db, Classes, ZConnection, ZDataSet, StdCtrls, SysUtils,
|
||||||
|
ZMessages,
|
||||||
HeidiComp;
|
HeidiComp;
|
||||||
|
|
||||||
{$IFDEF EXAMPLE_APP}
|
{$IFDEF EXAMPLE_APP}
|
||||||
@ -232,14 +233,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
try
|
try
|
||||||
if ExpectResultSet(FSql) then begin
|
|
||||||
r := RunDataQuery (FSql,TDataSet(q),ex,FCallback);
|
r := RunDataQuery (FSql,TDataSet(q),ex,FCallback);
|
||||||
if r then begin
|
if r then begin
|
||||||
if q.State=dsBrowse then begin
|
//if q.State=dsBrowse then begin
|
||||||
// WTF?
|
// WTF?
|
||||||
|
//end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end else r := RunUpdateQuery (FSql,TDataSet(q),ex,FCallBack);
|
|
||||||
TMysqlQuery(FOwner).SetMysqlDataset(q);
|
TMysqlQuery(FOwner).SetMysqlDataset(q);
|
||||||
|
|
||||||
if r then SetState (MQR_SUCCESS,'SUCCESS')
|
if r then SetState (MQR_SUCCESS,'SUCCESS')
|
||||||
@ -336,11 +335,12 @@ begin
|
|||||||
q.Active := True;
|
q.Active := True;
|
||||||
Result := True;
|
Result := True;
|
||||||
except
|
except
|
||||||
on E: Exception do
|
on E: Exception do begin
|
||||||
begin
|
if E.Message = SCanNotOpenResultSet then begin
|
||||||
AExceptionData := GetExceptionData(E);
|
Result := true;
|
||||||
|
ADataset := nil;
|
||||||
|
end else AExceptionData := GetExceptionData(E);
|
||||||
end;
|
end;
|
||||||
// EZSQLException
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user