Skip to content

Commit

Permalink
Allow user to enable/disable stats at SQL editor screen
Browse files Browse the repository at this point in the history
  • Loading branch information
arvanus committed Oct 9, 2023
1 parent 48868e2 commit 41249aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gui/CommandIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum {
// SQL Query
Query_Execute,
Query_Show_plan,
Query_Show_Statistics,
Query_Execute_selection,
Query_Execute_from_cursor,
Query_Commit,
Expand Down
21 changes: 20 additions & 1 deletion src/gui/ExecuteSqlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ ExecuteSqlFrame::ExecuteSqlFrame(wxWindow* WXUNUSED(parent), int id,
transactionIsolationLevelM = static_cast<IBPP::TIL>(config().get("transactionIsolationLevel", 0));
transactionLockResolutionM = config().get("transactionLockResolution", true) ? IBPP::lrWait : IBPP::lrNoWait;
transactionAccessModeM = config().get("transactionAccessMode", false) ? IBPP::amRead : IBPP::amWrite;
showStatisticsM = config().get("SQLEditorShowStats", true);

timerBlobEditorM.SetOwner(this, TIMER_ID_UPDATE_BLOB);

Expand Down Expand Up @@ -730,6 +731,8 @@ void ExecuteSqlFrame::buildMainMenu(CommandManager& cm)
cm.getMainMenuItemText(_("&Execute"), Cmds::Query_Execute));
statementMenu->Append(Cmds::Query_Show_plan,
cm.getMainMenuItemText(_("Show execution &plan"), Cmds::Query_Show_plan));
statementMenu->AppendCheckItem(Cmds::Query_Show_Statistics,
cm.getMainMenuItemText(_("Display detailed query statistics"), Cmds::Query_Show_Statistics));
statementMenu->Append(Cmds::Query_Execute_selection,
cm.getMainMenuItemText(_("Execute &selection"), Cmds::Query_Execute_selection));
statementMenu->Append(Cmds::Query_Execute_from_cursor,
Expand Down Expand Up @@ -950,6 +953,8 @@ BEGIN_EVENT_TABLE(ExecuteSqlFrame, wxFrame)

EVT_MENU(Cmds::Query_Execute, ExecuteSqlFrame::OnMenuExecute)
EVT_MENU(Cmds::Query_Show_plan, ExecuteSqlFrame::OnMenuShowPlan)
EVT_MENU(Cmds::Query_Show_Statistics, ExecuteSqlFrame::OnMenuShowStatistics)
EVT_UPDATE_UI(Cmds::Query_Show_Statistics, ExecuteSqlFrame::OnMenuUpdateShowStatistics)
EVT_MENU(Cmds::Query_Execute_selection, ExecuteSqlFrame::OnMenuExecuteSelection)
EVT_MENU(Cmds::Query_Execute_from_cursor, ExecuteSqlFrame::OnMenuExecuteFromCursor)
EVT_UPDATE_UI(Cmds::Query_Execute, ExecuteSqlFrame::OnMenuUpdateWhenExecutePossible)
Expand Down Expand Up @@ -1619,6 +1624,16 @@ void ExecuteSqlFrame::OnMenuShowPlan(wxCommandEvent& WXUNUSED(event))
prepareAndExecute(true);
}

void ExecuteSqlFrame::OnMenuShowStatistics(wxCommandEvent& event)
{
showStatisticsM = event.IsChecked();
}

void ExecuteSqlFrame::OnMenuUpdateShowStatistics(wxUpdateUIEvent& event)
{
event.Check(showStatisticsM);
}

void ExecuteSqlFrame::OnMenuExecuteFromCursor(wxCommandEvent& WXUNUSED(event))
{
clearLogBeforeExecution();
Expand Down Expand Up @@ -2273,6 +2288,10 @@ void ExecuteSqlFrame::compareCounts(IBPP::DatabaseCounts& one,
str_log += wxString::Format(_("%d updates. "), r1.updates - r2.updates);
if (r1.deletes > r2.deletes)
str_log += wxString::Format(_("%d deletes. "), r1.deletes - r2.deletes);
if (r1.readIndex > r2.readIndex)
str_log += wxString::Format(_("%d reads index. "), r1.readIndex - r2.readIndex);
if (r1.readSequence > r2.readSequence)
str_log += wxString::Format(_("%d reads sequence. "), r1.readSequence - r2.readSequence);
if (!str_log.IsEmpty())
{
wxString relName;
Expand Down Expand Up @@ -2387,7 +2406,7 @@ bool ExecuteSqlFrame::execute(wxString sql, const wxString& terminator,
del1 = 0, ridx1 = 0, rseq1 = 0, mem1 = 0;
int fetch2, mark2, read2, write2, ins2, upd2, del2, ridx2, rseq2, mem2;
IBPP::DatabaseCounts counts1, counts2;
bool doShowStats = config().get("SQLEditorShowStats", true);
bool doShowStats = showStatisticsM;
if (!prepareOnly && doShowStats)
{
databaseM->getIBPPDatabase()->
Expand Down
3 changes: 3 additions & 0 deletions src/gui/ExecuteSqlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class ExecuteSqlFrame: public BaseFrame, public Observer
IBPP::TIL transactionIsolationLevelM;
IBPP::TLR transactionLockResolutionM;
IBPP::TAM transactionAccessModeM;
bool showStatisticsM;
void inTransaction(bool started); // changes controls (enable/disable)
bool commitTransaction();
bool rollbackTransaction();
Expand Down Expand Up @@ -210,6 +211,8 @@ class ExecuteSqlFrame: public BaseFrame, public Observer

void OnMenuExecute(wxCommandEvent& event);
void OnMenuShowPlan(wxCommandEvent& event);
void OnMenuShowStatistics(wxCommandEvent& event);
void OnMenuUpdateShowStatistics(wxUpdateUIEvent& event);
void OnMenuExecuteSelection(wxCommandEvent& event);
void OnMenuExecuteFromCursor(wxCommandEvent& event);
void OnMenuCommit(wxCommandEvent& event);
Expand Down

0 comments on commit 41249aa

Please sign in to comment.