mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Remove TMainForm.AllDatabasesDetails, and implement a collation property in TDBObjectList, queried from information_schema.schemata. Removes a moreorless useless queries for objects in information_schema, which probably causes crashes when badly timed, like described in issue #2537.
This commit is contained in:
@ -206,11 +206,13 @@ type
|
||||
FDataSize: Int64;
|
||||
FLargestObjectSize: Int64;
|
||||
FLastUpdate: TDateTime;
|
||||
FCollation: String;
|
||||
public
|
||||
property Database: String read FDatabase;
|
||||
property DataSize: Int64 read FDataSize;
|
||||
property LargestObjectSize: Int64 read FLargestObjectSize;
|
||||
property LastUpdate: TDateTime read FLastUpdate;
|
||||
property Collation: String read FCollation;
|
||||
end;
|
||||
TDatabaseList = TObjectList<TDBObjectList>; // A list of db object lists, used for caching
|
||||
TDBObjectComparer = class(TComparer<TDBObject>)
|
||||
@ -2409,6 +2411,13 @@ begin
|
||||
Result.FLastUpdate := 0;
|
||||
Result.FDataSize := 0;
|
||||
Result.FDatabase := db;
|
||||
try
|
||||
Result.FCollation := GetVar('SELECT '+QuoteIdent('DEFAULT_COLLATION_NAME')+
|
||||
' FROM '+QuoteIdent('information_schema')+'.'+QuoteIdent('SCHEMATA')+
|
||||
' WHERE '+QuoteIdent('SCHEMA_NAME')+'='+EscapeString(db));
|
||||
except
|
||||
Result.FCollation := '';
|
||||
end;
|
||||
Results := nil;
|
||||
rx := TRegExpr.Create;
|
||||
rx.ModifierI := True;
|
||||
|
@ -889,7 +889,6 @@ type
|
||||
procedure OperationRunning(Runs: Boolean);
|
||||
function RunQueryFiles(Filenames: TStrings; Encoding: TEncoding): Boolean;
|
||||
public
|
||||
AllDatabasesDetails: TDBQuery;
|
||||
QueryTabs: TObjectList<TQueryTab>;
|
||||
ActiveObjectEditor: TDBObjectEditor;
|
||||
FileEncodings: TStringList;
|
||||
@ -7846,13 +7845,6 @@ begin
|
||||
Screen.Cursor := crHourglass;
|
||||
vt.Clear;
|
||||
if Conn <> nil then begin
|
||||
try
|
||||
if Conn.InformationSchemaObjects.IndexOf('SCHEMATA') > -1 then
|
||||
AllDatabasesDetails := Conn.GetResults('SELECT * FROM '+Conn.QuoteIdent('information_schema')+'.'+Conn.QuoteIdent('SCHEMATA'));
|
||||
except
|
||||
on E:EDatabaseError do
|
||||
LogSQL(E.Message, lcError);
|
||||
end;
|
||||
if vt.Tag = VTREE_NOTLOADED_PURGECACHE then begin
|
||||
for i:=0 to Conn.AllDatabases.Count-1 do begin
|
||||
if Conn.DbObjectsCached(Conn.AllDatabases[i]) then
|
||||
@ -7946,32 +7938,19 @@ begin
|
||||
DBname := Conn.AllDatabases[Idx^];
|
||||
if Conn.DbObjectsCached(DBname) then
|
||||
Objects := Conn.GetDBObjects(DBname);
|
||||
CellText := '';
|
||||
case Column of
|
||||
0: CellText := DBname;
|
||||
1: if Assigned(Objects) then CellText := FormatByteNumber(Objects.DataSize)
|
||||
else CellText := '';
|
||||
1: if Assigned(Objects) then CellText := FormatByteNumber(Objects.DataSize);
|
||||
2: CellText := GetItemCount(lntNone);
|
||||
3: if Assigned(Objects) and (Objects.LastUpdate > 0) then CellText := DateTimeToStr(Objects.LastUpdate)
|
||||
else CellText := '';
|
||||
3: if Assigned(Objects) and (Objects.LastUpdate > 0) then CellText := DateTimeToStr(Objects.LastUpdate);
|
||||
4: CellText := GetItemCount(lntTable);
|
||||
5: CellText := GetItemCount(lntView);
|
||||
6: CellText := GetItemCount(lntFunction);
|
||||
7: CellText := GetItemCount(lntProcedure);
|
||||
8: CellText := GetItemCount(lntTrigger);
|
||||
9: CellText := GetItemCount(lntEvent);
|
||||
10: begin
|
||||
CellText := '';
|
||||
if Assigned(AllDatabasesDetails) then begin
|
||||
AllDatabasesDetails.First;
|
||||
while not AllDatabasesDetails.Eof do begin
|
||||
if AllDatabasesDetails.Col('SCHEMA_NAME', True) = DBname then begin
|
||||
CellText := AllDatabasesDetails.Col('DEFAULT_COLLATION_NAME', True);
|
||||
break;
|
||||
end;
|
||||
AllDatabasesDetails.Next;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
10: if Assigned(Objects) then CellText := Objects.Collation;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
Reference in New Issue
Block a user