Skip to content
Permalink
Browse files

Leave explain links disabled when SQL in focused process is empty, an…

…d only prepend a "USE dbname" if used database is not empty. Closes #738
  • Loading branch information...
ansgarbecker committed Aug 16, 2019
1 parent 8f1fb1c commit 1130ee41a3b9c00192ab77692862039305134a47
Showing with 25 additions and 14 deletions.
  1. +3 −3 out/locale/en/LC_MESSAGES/default.po
  2. +22 −11 source/main.pas
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2019-07-28 12:11+0200\n"
"PO-Revision-Date: 2019-08-16 07:10+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
@@ -4828,8 +4828,8 @@ msgid "Writing to session log file disabled now"
msgstr "Writing to session log file disabled now"

#: main.pas:6577
msgid "Please select a process in the above list."
msgstr "Please select a process in the above list."
msgid "Please select a process with a running query"
msgstr "Please select a process with a running query"

#: main.pas:6990
msgid "Reading Databases..."
@@ -7818,21 +7818,28 @@ procedure TMainForm.PaintColorBar(Value, Max: Extended; TargetCanvas: TCanvas; C
procedure TMainForm.ListProcessesFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
var
enableSQLView : Boolean;
NodeFocused, EnableControls: Boolean;
SQL: String;
begin
enableSQLView := Assigned(Node);
SynMemoProcessView.Enabled := enableSQLView;
pnlProcessView.Enabled := enableSQLView;
if enableSQLView then begin
NodeFocused := Assigned(Node);
SQL := '';
if NodeFocused then begin
SQL := ListProcesses.Text[Node, 7];
end;
EnableControls := not SQL.IsEmpty;
if EnableControls then begin
SynMemoProcessView.Highlighter := SynSQLSynUsed;
SynMemoProcessView.Text := ListProcesses.Text[Node, 7];
SynMemoProcessView.Color := GetThemeColor(clWindow);
SynMemoProcessView.Color := clWindow;
end else begin
SynMemoProcessView.Highlighter := nil;
SynMemoProcessView.Text := _('Please select a process in the above list.');
SynMemoProcessView.Color := GetThemeColor(clBtnFace);
SynMemoProcessView.Text := _('Please select a process with a running query');
SynMemoProcessView.Color := clBtnFace;
end;
lblExplainProcess.Enabled := enableSQLView and ActiveConnection.Parameters.IsMySQL;

SynMemoProcessView.Enabled := EnableControls;
pnlProcessView.Enabled := EnableControls;
lblExplainProcess.Enabled := EnableControls and ActiveConnection.Parameters.IsMySQL;
menuExplainProcess.Enabled := lblExplainProcess.Enabled;
lblExplainProcessAnalyzer.Enabled := lblExplainProcess.Enabled;
menuExplainAnalyzer.Enabled := lblExplainProcess.Enabled;
@@ -11856,12 +11863,16 @@ procedure TMainForm.lblExplainProcessAnalyzerClick(Sender: TObject);
procedure TMainForm.lblExplainProcessClick(Sender: TObject);
var
Tab: TQueryTab;
UsedDatabase: String;
begin
// Click on "Explain" link label, in process viewer
actNewQueryTabExecute(Sender);
Tab := QueryTabs[QueryTabs.Count-1];
Tab.Memo.Text := 'USE '+ActiveConnection.QuoteIdent(listProcesses.Text[listProcesses.FocusedNode, 3])+';'+CRLF+
'EXPLAIN'+CRLF+SynMemoProcessView.Text;
UsedDatabase := listProcesses.Text[listProcesses.FocusedNode, 3];
if not UsedDatabase.IsEmpty then begin
Tab.Memo.Lines.Add('USE ' + ActiveConnection.QuoteIdent(UsedDatabase) + ';');
end;
Tab.Memo.Lines.Add('EXPLAIN' + sLineBreak + SynMemoProcessView.Text + ';');
Tab.TabSheet.Show;
actExecuteQueryExecute(Sender);
end;

0 comments on commit 1130ee4

Please sign in to comment.
You can’t perform that action at this time.