From f4b19d1351f9879a4b7bb45aceb6e23f9ff995db Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 21 Aug 2011 05:45:09 +0000 Subject: [PATCH] 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. --- source/dbconnection.pas | 9 +++++++++ source/main.pas | 29 ++++------------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 1a44e813..3a288df5 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -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; // A list of db object lists, used for caching TDBObjectComparer = class(TComparer) @@ -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; diff --git a/source/main.pas b/source/main.pas index b2f413e5..9f0716c5 100644 --- a/source/main.pas +++ b/source/main.pas @@ -889,7 +889,6 @@ type procedure OperationRunning(Runs: Boolean); function RunQueryFiles(Filenames: TStrings; Encoding: TEncoding): Boolean; public - AllDatabasesDetails: TDBQuery; QueryTabs: TObjectList; 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;