From b7cec30bd319f0bbf456f9ebbe3e7befad461d15 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 20 Apr 2011 19:03:13 +0000 Subject: [PATCH] Exceptions are caught in TMySQLConnection.GetAllDatabases, no need to catch them again in TMainForm.DBtreeInitChildren. Also, log an error message if both SHOW DATABASES and the alternative did not work. --- source/dbconnection.pas | 7 +++++-- source/main.pas | 6 +----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 5e40cfff..0f364229 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -1700,8 +1700,11 @@ begin except on E:EDatabaseError do try FAllDatabases := GetCol('SELECT '+QuoteIdent('SCHEMA_NAME')+' FROM '+QuoteIdent(DBNAME_INFORMATION_SCHEMA)+'.'+QuoteIdent('SCHEMATA')+' ORDER BY '+QuoteIdent('SCHEMA_NAME')); - except on E:EDatabaseError do - FAllDatabases := TStringList.Create; + except + on E:EDatabaseError do begin + FAllDatabases := TStringList.Create; + Log(lcError, 'Database names not available due to missing privileges for user '+CurrentUserHostCombination+'.'); + end; end; end; Result := FAllDatabases; diff --git a/source/main.pas b/source/main.pas index 0f9703cd..6a8d3262 100644 --- a/source/main.pas +++ b/source/main.pas @@ -6710,12 +6710,8 @@ begin lntNone: begin Screen.Cursor := crHourglass; ShowStatusMsg('Reading Databases...'); - if Sender.Tag = VTREE_NOTLOADED_PURGECACHE then try + if Sender.Tag = VTREE_NOTLOADED_PURGECACHE then DBObj.Connection.RefreshAllDatabases; - except - on E:EDatabaseError do - MessageDlg(E.Message+CRLF+CRLF+'You have no privilege to execute SHOW DATABASES. Please specify one or more databases in your session settings, if you want to see any.', mtError, [mbOK], 0); - end; ShowStatusMsg; Sender.Tag := VTREE_LOADED; InvalidateVT(ListDatabases, VTREE_NOTLOADED, True);