diff --git a/pgadmin/dlg/dlgProperty.cpp b/pgadmin/dlg/dlgProperty.cpp index 5518026..74d36d5 100644 --- a/pgadmin/dlg/dlgProperty.cpp +++ b/pgadmin/dlg/dlgProperty.cpp @@ -144,8 +144,10 @@ dlgProperty::dlgProperty(pgaFactory *f, frmMain *frame, const wxString &resName) wxString db = wxT("Database"); wxString ts = wxT("Tablespace"); + wxString rg = wxT("Resource Group"); enableSQL2 = db.Cmp(factory->GetTypeName()) == 0 - || ts.Cmp(factory->GetTypeName()) == 0; + || ts.Cmp(factory->GetTypeName()) == 0 + || rg.Cmp(factory->GetTypeName()) == 0; wxNotebookPage *page = nbNotebook->GetPage(0); wxASSERT(page != NULL); diff --git a/pgadmin/dlg/dlgResourceGroup.cpp b/pgadmin/dlg/dlgResourceGroup.cpp index 2204e75..b5d8a6c 100644 --- a/pgadmin/dlg/dlgResourceGroup.cpp +++ b/pgadmin/dlg/dlgResourceGroup.cpp @@ -40,6 +40,9 @@ dlgResourceGroup::dlgResourceGroup(pgaFactory *f, frmMain *frame, edbResourceGro : dlgProperty(f, frame, wxT("dlgResourceGroup")) { resourceGroup = node; + m_cpuRate = wxEmptyString; + m_dirtyRate = wxEmptyString; + m_isNameChange = false; } pgObject *dlgResourceGroup::GetObject() @@ -71,6 +74,9 @@ int dlgResourceGroup::Go(bool modal) txtDirtyRate->SetValue(wxT("0")); } + m_cpuRate = txtCPURate->GetValue(); + m_dirtyRate = txtDirtyRate->GetValue(); + return dlgProperty::Go(modal); } @@ -110,28 +116,51 @@ pgObject *dlgResourceGroup::CreateObject(pgCollection *collection) wxString dlgResourceGroup::GetSql() { - wxString sql; + wxString sql = wxEmptyString; wxString name = GetName(); wxString cpuRate = txtCPURate->GetValue(); wxString dirtyRate = txtDirtyRate->GetValue(); if (resourceGroup) { - // Edit Mode AppendNameChange(sql, wxT("RESOURCE GROUP ") + resourceGroup->GetQuotedFullIdentifier()); - sql += wxT("ALTER RESOURCE GROUP ") + qtIdent(name) + wxT(" SET cpu_rate_limit = ") + - cpuRate + wxT(", dirty_rate_limit = ") + dirtyRate + wxT(";\n"); + // Update the flag if resource group name is changed so that next + // ALTER command will be displayed in the second SQL text box. + m_isNameChange = !sql.IsEmpty(); + + // Check the "cpu rate/dirty rate" limit is changed or not + if (!m_isNameChange && (m_cpuRate.compare(cpuRate) != 0 || m_dirtyRate.compare(dirtyRate) != 0)) + { + sql += wxT("ALTER RESOURCE GROUP ") + qtIdent(name) + wxT(" SET cpu_rate_limit = ") + + cpuRate + wxT(", dirty_rate_limit = ") + dirtyRate + wxT(";\n"); + } } else { - // Create Mode - wxString name = GetName(); - sql = wxT("CREATE RESOURCE GROUP ") + qtIdent(name) + wxT(";\n"); - sql += wxT("ALTER RESOURCE GROUP ") + qtIdent(name) + wxT(" SET cpu_rate_limit = ") + - cpuRate + wxT(", dirty_rate_limit = ") + dirtyRate + wxT(";\n"); } + + return sql; +} + +wxString dlgResourceGroup::GetSql2() +{ + wxString sql = wxEmptyString; + wxString name = GetName(); + wxString cpuRate = txtCPURate->GetValue(); + wxString dirtyRate = txtDirtyRate->GetValue(); + + if (!resourceGroup || m_isNameChange) + { + // Check the "cpu rate/dirty rate" limit is changed or not + if (m_cpuRate.compare(cpuRate) != 0 || m_dirtyRate.compare(dirtyRate) != 0) + { + sql = wxT("ALTER RESOURCE GROUP ") + qtIdent(name) + wxT(" SET cpu_rate_limit = ") + + cpuRate + wxT(", dirty_rate_limit = ") + dirtyRate + wxT(";\n"); + } + } + return sql; } diff --git a/pgadmin/include/dlg/dlgResourceGroup.h b/pgadmin/include/dlg/dlgResourceGroup.h index 08017ba..f013b58 100644 --- a/pgadmin/include/dlg/dlgResourceGroup.h +++ b/pgadmin/include/dlg/dlgResourceGroup.h @@ -21,23 +21,23 @@ class dlgResourceGroup : public dlgProperty public: dlgResourceGroup(pgaFactory *factory, frmMain *frame, edbResourceGroup *node = 0); wxString GetSql(); + wxString GetSql2(); pgObject *CreateObject(pgCollection *collection); pgObject *GetObject(); void CheckChange(); int Go(bool modal); - bool WannaSplitQueries() - { - return true; - } - private: void OnChange(wxCommandEvent &event); void OnOK(wxCommandEvent &ev); private: edbResourceGroup *resourceGroup; + wxString m_cpuRate; + wxString m_dirtyRate; + bool m_isNameChange; + DECLARE_EVENT_TABLE() };