On 20 June 2011 11:00, Dave Page <dp...@pgadmin.org> wrote: > On Fri, Jun 17, 2011 at 6:39 PM, Thom Brown <t...@linux.com> wrote: >> On 17 June 2011 18:18, Thom Brown <t...@linux.com> wrote: >>> On 17 June 2011 18:16, Thom Brown <t...@linux.com> wrote: >>> >>>> Very well then. Dodgy patch attached. >>> >>> And again without ugly whitespace. >> >> Erk... just been trying to break it and found that this generates the >> alter statement every time once the value has been set, so fixed that >> too (attached). > > LOL. The patch looks great as far as it goes - not at all dodgy. It > currently only affects tables though - you need to do roughly the same > thing in dlgIndex.cpp and dlgIndexConstraint.cpp to cover the cases > you reported :-)
Okay, updated patch attached. This enables modification of fill factor on existing tables and primary keys. -- Thom Brown Twitter: @darkixion IRC (freenode): dark_ixion Registered Linux user: #516935 EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
diff --git a/pgadmin/dlg/dlgIndex.cpp b/pgadmin/dlg/dlgIndex.cpp index e023b5d..e86cc62 100644 --- a/pgadmin/dlg/dlgIndex.cpp +++ b/pgadmin/dlg/dlgIndex.cpp @@ -94,7 +94,7 @@ int dlgIndexBase::Go(bool modal) if (txtFillFactor) { txtFillFactor->SetValidator(numericValidator); - if (!index && connection->BackendMinimumVersion(8, 2)) + if (connection->BackendMinimumVersion(8, 2)) txtFillFactor->Enable(); else txtFillFactor->Disable(); @@ -164,7 +164,8 @@ void dlgIndexBase::CheckChange() if (index) { EnableOK(txtComment->GetValue() != index->GetComment() || - cbTablespace->GetOIDKey() != index->GetTablespaceOid()); + cbTablespace->GetOIDKey() != index->GetTablespaceOid() || + txtFillFactor->GetValue() != index->GetFillFactor()); } else { diff --git a/pgadmin/dlg/dlgIndexConstraint.cpp b/pgadmin/dlg/dlgIndexConstraint.cpp index 05d0bcc..03231f8 100644 --- a/pgadmin/dlg/dlgIndexConstraint.cpp +++ b/pgadmin/dlg/dlgIndexConstraint.cpp @@ -300,7 +300,7 @@ int dlgIndexConstraint::Go(bool modal) } txtFillFactor->SetValidator(numericValidator); - if (!index && connection->BackendMinimumVersion(8, 2)) + if (connection->BackendMinimumVersion(8, 2)) txtFillFactor->Enable(); else txtFillFactor->Disable(); @@ -568,6 +568,13 @@ wxString dlgIndexConstraint::GetSql() + wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue()) + wxT(";\n"); } + + if (txtFillFactor->GetValue().Trim().Length() > 0 txtFillFactor->GetValue() != index->GetFillFactor()) + { + sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name) + + wxT("\n SET (FILLFACTOR=") + + txtFillFactor->GetValue() + wxT(");\n"); + } } if (!name.IsEmpty()) diff --git a/pgadmin/dlg/dlgTable.cpp b/pgadmin/dlg/dlgTable.cpp index 72c2cae..3effcb7 100644 --- a/pgadmin/dlg/dlgTable.cpp +++ b/pgadmin/dlg/dlgTable.cpp @@ -105,6 +105,7 @@ BEGIN_EVENT_TABLE(dlgTable, dlgSecurityProperty) EVT_CHECKBOX(XRCID("chkUnlogged"), dlgProperty::OnChange) EVT_TEXT(XRCID("cbTablespace"), dlgProperty::OnChange) EVT_COMBOBOX(XRCID("cbTablespace"), dlgProperty::OnChange) + EVT_TEXT(XRCID("txtFillFactor"), dlgProperty::OnChange) EVT_COMBOBOX(XRCID("cbOfType"), dlgTable::OnChangeOfType) EVT_CHECKBOX(XRCID("chkHasOids"), dlgProperty::OnChange) EVT_TEXT(XRCID("cbTables"), dlgTable::OnChangeTable) @@ -745,13 +746,10 @@ int dlgTable::Go(bool modal) if (table) { txtFillFactor->SetValue(table->GetFillFactor()); - txtFillFactor->Disable(); - } - else - { - txtFillFactor->Enable(); - txtFillFactor->SetValidator(numericValidator); } + + txtFillFactor->SetValidator(numericValidator); + txtFillFactor->Enable(); } else { @@ -933,6 +931,13 @@ wxString dlgTable::GetSql() + wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue()) + wxT(";\n"); + if (txtFillFactor->GetValue().Trim().Length() > 0 && txtFillFactor->GetValue() != table->GetFillFactor()) + { + sql += wxT("ALTER TABLE ") + tabname + + wxT("\n SET (FILLFACTOR=") + + txtFillFactor->GetValue() + wxT(");\n"); + } + if (connection->BackendMinimumVersion(8, 1)) { if (!chkCustomVac->GetValue())
-- Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-support