void dlgRole::CheckChange() { bool enable = true; bool timEn = datValidUntil->GetValue().IsValid(); timValidUntil->Enable(timEn); if (!timEn) timValidUntil->SetTime(wxDefaultDateTime); if (!readOnly) chkUpdateCat->Enable(chkSuperuser->GetValue() && !connection->BackendMinimumVersion(9, 5)); // Check the passwords match if (txtPasswd->GetValue() != txtRePasswd->GetValue()) { bool enable = true; CheckValid(enable, false, _("The passwords entered do not match!")); EnableOK(enable); return; } if (!role) { wxString name = GetName(); CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); } else { enable = !GetSql().IsEmpty(); if (seclabelPage && connection->BackendMinimumVersion(9, 2)) enable = enable || !(seclabelPage->GetSqlForSecLabels().IsEmpty()); } EnableOK(enable); }
void dlgDomain::CheckChange() { bool enable = true; if (domain) { enable = false; if (connection->BackendMinimumVersion(7, 4) || lstColumns->GetItemCount() > 0) { enable = !GetSql().IsEmpty(); } if (seclabelPage && connection->BackendMinimumVersion(9, 1)) enable = enable || !(seclabelPage->GetSqlForSecLabels().IsEmpty()); } else { wxString name = GetName(); long varlen = StrToLong(txtLength->GetValue()), varprec = StrToLong(txtPrecision->GetValue()); txtPrecision->Enable(isVarPrec && varlen > 0); CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); CheckValid(enable, cbDatatype->GetGuessedSelection() >= 0, _("Please select a datatype.")); CheckValid(enable, !isVarLen || txtLength->GetValue().IsEmpty() || (varlen >= minVarLen && varlen <= maxVarLen && NumToStr(varlen) == txtLength->GetValue()), _("Please specify valid length.")); CheckValid(enable, !txtPrecision->IsEnabled() || (varprec >= 0 && varprec <= varlen && NumToStr(varprec) == txtPrecision->GetValue()), _("Please specify valid numeric precision (0..") + NumToStr(varlen) + wxT(").")); } EnableOK(enable); }
void dlgRole::CheckChange() { bool timEn=datValidUntil->GetValue().IsValid(); timValidUntil->Enable(timEn); if (!timEn) timValidUntil->SetTime(wxDefaultDateTime); if (!readOnly) chkUpdateCat->Enable(chkSuperuser->GetValue()); // Check the passwords match if (txtPasswd->GetValue() != txtRePasswd->GetValue()) { bool enable=true; CheckValid(enable, false, _("The passwords entered do not match!")); EnableOK(enable); return; } if (!role) { wxString name=GetName(); bool enable=true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); EnableOK(enable); } else { EnableOK(!GetSql().IsEmpty()); } }
void dlgFunction::CheckChange() { wxString name = GetName(); bool isC = cbLanguage->GetValue().IsSameAs(wxT("C"), false); bool enable = true, didChange = true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); if (!isProcedure) CheckValid(enable, cbReturntype->GetValue().Trim() != wxEmptyString, _("Please select return type.")); if (!(isProcedure && connection->GetIsEdb())) CheckValid(enable, cbLanguage->GetGuessedSelection() >= 0, _("Please select language.")); if (isC) { wxString objfile = txtObjectFile->GetValue(); CheckValid(enable, !objfile.IsEmpty() && objfile != TXTOBJ_LIB, _("Please specify object library.")); } else { CheckValid(enable, !txtSqlBox->GetText().IsEmpty(), _("Please enter function source code.")); } if (function && enable) { if (seclabelPage && connection->BackendMinimumVersion(9, 1)) enable = enable || !(seclabelPage->GetSqlForSecLabels().IsEmpty()); EnableOK(enable && !GetSql().IsEmpty()); } else { EnableOK(enable && didChange); } }
void frmGrantWizard::OnPageSelect(wxNotebookEvent &event) { if (nbNotebook && sqlPane && event.GetSelection() == (int)nbNotebook->GetPageCount() - 2) { sqlPane->SetReadOnly(false); sqlPane->SetText(GetSql()); sqlPane->SetReadOnly(true); } }
void frmGrantWizard::OnChange(wxCommandEvent &event) { sqlPane->SetReadOnly(false); sqlPane->SetText(GetSql()); sqlPane->SetReadOnly(true); if (sqlPane->GetText().IsEmpty()) EnableOK(false); else EnableOK(true); }
void dlgView::CheckChange() { bool enable = true; wxString name = GetName(); CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); CheckValid(enable, txtSqlBox->GetText().Trim(true).Trim(false).Length() > 0 , _("Please enter function definition.")); if (!connection->BackendMinimumVersion(9, 3)) { DisableMaterializedView(); } if(enable) { if (view) enable = txtComment->GetValue() != view->GetComment() || txtSqlBox->GetText().Trim(true).Trim(false) != oldDefinition.Trim(true).Trim(false) || cbOwner->GetValue() != view->GetOwner() || cbSchema->GetValue() != view->GetSchema()->GetName() || name != view->GetName(); if (connection->BackendMinimumVersion(9, 3)) { enable = !GetSql().IsEmpty(); } if (seclabelPage && connection->BackendMinimumVersion(9, 1)) enable = enable || !(seclabelPage->GetSqlForSecLabels().IsEmpty()); if (connection->BackendMinimumVersion(9, 2)) { if (view) { if (chkSecurityBarrier->GetValue()) enable = enable || !(view->GetSecurityBarrier() == wxT("true")); else enable = enable || (view->GetSecurityBarrier() == wxT("true")); } else { enable = enable || (chkSecurityBarrier->GetValue()); } } if (connection->BackendMinimumVersion(9, 4) && view) { enable = enable || cbCheckOption->GetValue().Lower().Cmp(view->GetCheckOption()) != 0; } } EnableOK(enable); }
void dlgGroup::CheckChange() { if (group) { EnableOK(!GetSql().IsEmpty()); } else { wxString name = GetName(); bool enable = true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); EnableOK(enable); } }
void dlgResourceGroup::CheckChange() { if (resourceGroup) { EnableOK(!GetSql().IsEmpty()); } else { wxString name = GetName(); wxString cpuRate = txtCPURate->GetValue(); wxString dirtyRate = txtDirtyRate->GetValue(); bool enable = true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); CheckValid(enable, !cpuRate.IsEmpty(), _("Please specify CPU rate limit.")); CheckValid(enable, !dirtyRate.IsEmpty(), _("Please specify Dirty rate limit.")); EnableOK(enable); } }
void dlgSchedule::CheckChange() { timEnd->Enable(calEnd->GetValue().IsValid()); wxString name = GetName(); bool enable = true; if (statusBar) statusBar->SetStatusText(wxEmptyString); InitSelectAll(); CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); CheckValid(enable, calStart->GetValue().IsValid(), _("Please specify start date.")); if (enable) { EnableOK(!GetSql().IsEmpty()); } else EnableOK(false); }
void dlgForeignTable::CheckChange() { bool enable = true; if (foreigntable) { enable = txtComment->GetValue() != foreigntable->GetComment() || cbSchema->GetValue() != foreigntable->GetSchema()->GetName() || cbOwner->GetValue() != foreigntable->GetOwner() || GetSqlForTypes() != wxEmptyString || GetSql().Length() > 0; if (seclabelPage && connection->BackendMinimumVersion(9, 1)) enable = enable || !(seclabelPage->GetSqlForSecLabels().IsEmpty()); } else { wxString name = GetName(); CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); CheckValid(enable, cbForeignServer->GetCurrentSelection() >= 0, _("Please specify a foreign server.")); } EnableOK(enable); }
void ExecutionDialog::OnOK(wxCommandEvent &ev) { #ifdef __WXGTK__ if (!btnOK->IsEnabled()) return; #endif if (!thread) { wxString sql = GetSql(); if (sql.IsEmpty()) return; btnOK->Disable(); // Reset the variables bIsAborted = false; bIsExecutionStarted = false; bIsExecutionCompleted = false; thread = new pgQueryThread(conn, sql); if (thread->Create() != wxTHREAD_NO_ERROR) { Abort(); return; } wxLongLong startTime = wxGetLocalTimeMillis(); thread->Run(); // When execution is started then set the variable bIsExecutionStarted = true; wxNotebook *nb = CTRL_NOTEBOOK("nbNotebook"); if (nb) nb->SetSelection(nb->GetPageCount() - 1); while (thread && thread->IsRunning()) { wxMilliSleep(10); // here could be the animation if (txtMessages) { wxString msg = thread->GetMessagesAndClear(); if (!msg.IsEmpty()) txtMessages->AppendText(msg + wxT("\n")); } wxTheApp->Yield(true); } if (thread) { bool isOk = (thread->ReturnCode() == PGRES_COMMAND_OK || thread->ReturnCode() == PGRES_TUPLES_OK); if (txtMessages) { txtMessages->AppendText(thread->GetMessagesAndClear()); } if (thread->DataSet() != NULL) { wxLogInfo(wxString::Format(wxT("%d rows."), thread->DataSet()->NumRows())); } if (isOk) { if (txtMessages) txtMessages->AppendText(_("Total query runtime: ") + (wxGetLocalTimeMillis() - startTime).ToString() + wxT(" ms.")); btnOK->SetLabel(_("Done")); btnCancel->Disable(); } else { if (txtMessages) txtMessages->AppendText(conn->GetLastError()); Abort(); } } else if (txtMessages) txtMessages->AppendText(_("\nCancelled.\n")); btnOK->Enable(); bIsExecutionCompleted = true; } else { Abort(); delete conn; Destroy(); } }
void dlgRepCluster::OnOK(wxCommandEvent &ev) { #ifdef __WXGTK__ if (!btnOK->IsEnabled()) return; #endif EnableOK(false); bool done = true; done = connection->ExecuteVoid(wxT("BEGIN TRANSACTION;")); if (remoteConn) done = remoteConn->ExecuteVoid(wxT("BEGIN TRANSACTION;")); // initialize cluster on local node done = connection->ExecuteVoid(GetSql()); if (done && chkJoinCluster->GetValue()) { // we're joining an existing cluster wxString schemaPrefix = qtIdent(wxT("_") + cbClusterName->GetValue()) + wxT("."); wxString clusterVersion = remoteConn->ExecuteScalar( wxT("SELECT ") + schemaPrefix + wxT("slonyversion()")); wxString newVersion = connection->ExecuteScalar( wxT("SELECT ") + schemaPrefix + wxT("slonyversion()")); if (clusterVersion != newVersion) { wxMessageDialog msg(this, wxString::Format(_("The newly created cluster version (%s)\n doesn't match the existing cluster's version (%s)"), newVersion.c_str(), clusterVersion.c_str()), _("Error while joining replication cluster"), wxICON_ERROR); msg.ShowModal(); done = false; } if (done) done = CopyTable(remoteConn, connection, schemaPrefix + wxT("sl_node")); if (done) done = CopyTable(remoteConn, connection, schemaPrefix + wxT("sl_path")); if (done) done = CopyTable(remoteConn, connection, schemaPrefix + wxT("sl_listen")); if (done) done = CopyTable(remoteConn, connection, schemaPrefix + wxT("sl_set")); if (done) done = CopyTable(remoteConn, connection, schemaPrefix + wxT("sl_subscribe")); // make sure event seqno starts correctly after node reusage if (done) { pgSet *set = connection->ExecuteSet( wxT("SELECT ev_origin, MAX(ev_seqno) as seqno\n") wxT(" FROM ") + schemaPrefix + wxT("sl_event\n") wxT(" GROUP BY ev_origin")); if (set) { while (done && !set->Eof()) { if (set->GetVal(wxT("ev_origin")) == txtNodeID->GetValue()) { done = connection->ExecuteVoid( wxT("SELECT pg_catalog.setval(") + qtDbString(wxT("_") + cbClusterName->GetValue() + wxT(".sl_event_seq")) + wxT(", ") + set->GetVal(wxT("seqno")) + wxT("::int8 +1)")); } else { done = connection->ExecuteVoid( wxT("INSERT INTO ") + schemaPrefix + wxT("sl_confirm(con_origin, con_received, con_seqno, con_timestamp\n") wxT(" VALUES (") + set->GetVal(wxT("ev_origin")) + wxT(", ") + txtNodeID->GetValue() + wxT(", ") + set->GetVal(wxT("seqno")) + wxT(", current_timestamp")); } set->MoveNext(); } delete set; } } // make sure rowid seq starts correctly if (done) { wxString seqno = connection->ExecuteScalar( wxT("SELECT MAX(seql_last_value)\n") wxT(" FROM ") + schemaPrefix + wxT("sl_seqlog\n") wxT(" WHERE seql_seqid = 0 AND seql_origin = ") + txtNodeID->GetValue()); if (!seqno.IsEmpty()) { done = connection->ExecuteVoid( wxT("SELECT pg_catalog.setval(") + qtDbString(wxT("_") + cbClusterName->GetValue() + wxT(".sl_rowid_seq")) + wxT(", ") + seqno + wxT(")")); } } // create new node on the existing cluster if (done) { wxString sql = wxT("SELECT ") + schemaPrefix + wxT("storenode(") + txtNodeID->GetValue() + wxT(", ") + qtDbString(txtNodeName->GetValue()); if (StrToDouble(remoteVersion) >= 1.1 && StrToDouble(remoteVersion) < 2.0) sql += wxT(", false"); sql += wxT(");\n") wxT("SELECT ") + schemaPrefix + wxT("enablenode(") + txtNodeID->GetValue() + wxT(");\n"); done = remoteConn->ExecuteVoid(sql); } // add admin info to cluster if (done && cbAdminNode->GetCurrentSelection() > 0) { done = remoteConn->ExecuteVoid( wxT("SELECT ") + schemaPrefix + wxT("storepath(") + txtNodeID->GetValue() + wxT(", ") + NumToStr((long)cbAdminNode->wxItemContainer::GetClientData(cbAdminNode->GetCurrentSelection())) + wxT(", ") + qtDbString(wxT("host=") + database->GetServer()->GetName() + wxT(" port=") + NumToStr((long)database->GetServer()->GetPort()) + wxT(" dbname=") + database->GetName()) + wxT(", ") wxT("0);\n")); } } if (!done) { if (remoteConn) done = remoteConn->ExecuteVoid(wxT("ROLLBACK TRANSACTION;")); done = connection->ExecuteVoid(wxT("ROLLBACK TRANSACTION;")); EnableOK(true); return; } if (remoteConn) done = remoteConn->ExecuteVoid(wxT("COMMIT TRANSACTION;")); done = connection->ExecuteVoid(wxT("COMMIT TRANSACTION;")); ShowObject(); Destroy(); }