mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Fix access violations on old servers, fixes issue #1417:
a) On a 4.0 server, mysql_real_query("SHOW TABLES FROM nonexistant_db") returns 0/OK . A 5.x server returns 1. On 4.0 servers mysql_num_rows() then causes an access violation. So, we now gracefully avoid calling it when mysql_store_result() returned nil. b) Various hardcoded queries like SHOW ENGINES need to be quiet in any error case.
This commit is contained in:
@ -3773,8 +3773,8 @@ begin
|
||||
Cap.Add( FormatNumber(Results.Col(DBO_AUTOINC)) )
|
||||
else Cap.Add('');
|
||||
Cap.Add(Results.Col(DBO_AUTOINC));
|
||||
Cap.Add(Results.Col(DBO_COLLATION));
|
||||
Cap.Add(Results.Col(DBO_CHECKSUM));
|
||||
Cap.Add(Results.Col(DBO_COLLATION, True));
|
||||
Cap.Add(Results.Col(DBO_CHECKSUM, True));
|
||||
Cap.Add(Results.Col(DBO_CROPTIONS));
|
||||
if Results.ColExists(DBO_TYPE) then
|
||||
Cap.Add(Results.Col(DBO_TYPE))
|
||||
@ -5840,7 +5840,11 @@ begin
|
||||
// Cache datasets
|
||||
if dsShowEngines = nil then begin
|
||||
FreeAndNil(dsShowEngines);
|
||||
dsShowEngines := Connection.GetResults('SHOW ENGINES');
|
||||
try
|
||||
dsShowEngines := Connection.GetResults('SHOW ENGINES');
|
||||
except
|
||||
// Ignore errors on old servers
|
||||
end;
|
||||
end;
|
||||
if dsHaveEngines = nil then begin
|
||||
FreeAndNil(dsHaveEngines);
|
||||
@ -8272,8 +8276,11 @@ end;
|
||||
function TMainform.GetCollations(Items: TWideStrings = nil): TMySQLQuery;
|
||||
begin
|
||||
// Return cached collation list, used in several places, e.g. table editor
|
||||
if dsCollations = nil then
|
||||
if dsCollations = nil then try
|
||||
dsCollations := Connection.GetResults('SHOW COLLATION');
|
||||
except
|
||||
// Ignore errors on old servers
|
||||
end;
|
||||
if Assigned(dsCollations) then begin
|
||||
dsCollations.First;
|
||||
if Assigned(Items) then begin
|
||||
|
@ -307,7 +307,8 @@ begin
|
||||
FRowsAffected := 0;
|
||||
if DoStoreResult then begin
|
||||
Result := mysql_store_result(FHandle);
|
||||
FRowsFound := mysql_num_rows(Result);
|
||||
if Result <> nil then
|
||||
FRowsFound := mysql_num_rows(Result);
|
||||
Log(lcDebug, IntToStr(RowsFound)+' rows found.');
|
||||
end;
|
||||
end else begin
|
||||
@ -545,7 +546,7 @@ begin
|
||||
try
|
||||
Results := GetResults(SQL);
|
||||
Result := TWideStringList.Create;
|
||||
while not Results.Eof do begin
|
||||
if Results.RecordCount > 0 then while not Results.Eof do begin
|
||||
Result.Add(Results.Col(Column));
|
||||
Results.Next;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user