Bugfix: switch back to normal cursor after failed database operation.

Issue #180 doesn't seem to reproduce anymore, not here anyway.
This commit is contained in:
rosenfield.albert
2008-08-08 00:08:45 +00:00
parent 071e68c598
commit ae87769f9c

View File

@ -1511,18 +1511,21 @@ begin
OldCursor := Screen.Cursor; OldCursor := Screen.Cursor;
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
MainForm.ShowStatus('Fetching tables from "' + db + '" ...'); MainForm.ShowStatus('Fetching tables from "' + db + '" ...');
if (mysql_version >= 32300) and (not prefPreferShowTables) then begin try
ds := GetResults('SHOW TABLE STATUS FROM ' + mask(db), false, false); if (mysql_version >= 32300) and (not prefPreferShowTables) then begin
end else begin ds := GetResults('SHOW TABLE STATUS FROM ' + mask(db), false, false);
// contains table names, nothing else. end else begin
ds := GetResults('SHOW /*!50002 FULL */ TABLES FROM ' + mask(db), false, false); // contains table names, nothing else.
// could clean up data (rename first column to 'Name') and ds := GetResults('SHOW /*!50002 FULL */ TABLES FROM ' + mask(db), false, false);
// and add row counters to data set as a new field by using // could clean up data (rename first column to 'Name') and
// SELECT COUNT(*), but that would potentially be rather slow. // and add row counters to data set as a new field by using
// SELECT COUNT(*), but that would potentially be rather slow.
end;
CachedTableLists.AddObject(db, ds);
finally
MainForm.ShowStatus(STATUS_MSG_READY);
Screen.Cursor := OldCursor;
end; end;
CachedTableLists.AddObject(db, ds);
MainForm.ShowStatus(STATUS_MSG_READY);
Screen.Cursor := OldCursor;
end; end;
Result := TDataSet(CachedTableLists.Objects[CachedTableLists.IndexOf(db)]); Result := TDataSet(CachedTableLists.Objects[CachedTableLists.IndexOf(db)]);
Result.First; Result.First;
@ -1729,10 +1732,10 @@ begin
SetVTSelection(ListTables, SelectedCaptions); SetVTSelection(ListTables, SelectedCaptions);
Mainform.showstatus(db + ': ' + IntToStr(ListTables.RootNodeCount) +' table(s)', 0); Mainform.showstatus(db + ': ' + IntToStr(ListTables.RootNodeCount) +' table(s)', 0);
tabDatabase.Caption := sstr('Database: ' + db, 30); tabDatabase.Caption := sstr('Database: ' + db, 30);
// Ensure tree db node displays its chidren initialized
DBtree.ReinitChildren(FindDBNode(db), False);
MainForm.ShowStatus(STATUS_MSG_READY); MainForm.ShowStatus(STATUS_MSG_READY);
Screen.Cursor := crDefault; Screen.Cursor := crDefault;
// Ensure tree db node displays its chidren initialized
DBtree.ReinitChildren(FindDBNode(db), False);
end; end;
end; end;
@ -5076,40 +5079,50 @@ begin
0: begin 0: begin
Screen.Cursor := crSQLWait; Screen.Cursor := crSQLWait;
mainform.Showstatus( 'Reading Databases...' ); mainform.Showstatus( 'Reading Databases...' );
Databases := TStringList.Create; try
if DatabasesWanted.Count = 0 then begin Databases := TStringList.Create;
ds := GetResults( 'SHOW DATABASES' ); if DatabasesWanted.Count = 0 then begin
specialDbs := TStringList.Create; ds := GetResults( 'SHOW DATABASES' );
for i:=1 to ds.RecordCount do begin specialDbs := TStringList.Create;
dbName := ds.FieldByName('Database').AsString; for i:=1 to ds.RecordCount do begin
if dbName = DBNAME_INFORMATION_SCHEMA then specialDbs.Insert( 0, dbName ) dbName := ds.FieldByName('Database').AsString;
else Databases.Add( dbName ); if dbName = DBNAME_INFORMATION_SCHEMA then specialDbs.Insert( 0, dbName )
ds.Next; else Databases.Add( dbName );
end; ds.Next;
ds.Close; end;
FreeAndNil(ds); ds.Close;
Databases.Sort; FreeAndNil(ds);
// Prioritised position of system-databases Databases.Sort;
for i := specialDbs.Count - 1 downto 0 do // Prioritised position of system-databases
Databases.Insert( 0, specialDbs[i] ); for i := specialDbs.Count - 1 downto 0 do
end else Databases.Insert( 0, specialDbs[i] );
Databases.AddStrings(DatabasesWanted); end else
Mainform.showstatus( IntToStr( Databases.Count ) + ' Databases', 0 ); Databases.AddStrings(DatabasesWanted);
ChildCount := Databases.Count; Mainform.showstatus( IntToStr( Databases.Count ) + ' Databases', 0 );
// Avoids excessive InitializeKeywordLists() calls. ChildCount := Databases.Count;
SynSQLSyn1.TableNames.BeginUpdate; // Avoids excessive InitializeKeywordLists() calls.
SynSQLSyn1.TableNames.Clear; SynSQLSyn1.TableNames.BeginUpdate;
// Let synedit know all database names so that they can be highlighted SynSQLSyn1.TableNames.Clear;
// TODO: Is this right? Adding "<db name>.<table name>" seems to make more sense.. // Let synedit know all database names so that they can be highlighted
SynSQLSyn1.TableNames.AddStrings( Databases ); // TODO: Is this right? Adding "<db name>.<table name>" seems to make more sense..
SynSQLSyn1.TableNames.EndUpdate; SynSQLSyn1.TableNames.AddStrings( Databases );
MainForm.ShowStatus( STATUS_MSG_READY ); SynSQLSyn1.TableNames.EndUpdate;
Screen.Cursor := crDefault; finally
MainForm.ShowStatus( STATUS_MSG_READY );
Screen.Cursor := crDefault;
end;
end; end;
// DB node expanding // DB node expanding
1: begin 1: begin
ds := FetchDbTableList(Databases[Node.Index]); Screen.Cursor := crSQLWait;
ChildCount := ds.RecordCount; mainform.Showstatus( 'Reading Tables...' );
try
ds := FetchDbTableList(Databases[Node.Index]);
ChildCount := ds.RecordCount;
finally
MainForm.ShowStatus( STATUS_MSG_READY );
Screen.Cursor := crDefault;
end;
end; end;
else Exit; else Exit;
end; end;