On 2 July 2011 13:11, Guillaume Lelarge <guilla...@lelarge.info> wrote: > On Sat, 2011-07-02 at 10:23 +0100, Thom Brown wrote: >> Hi >> >> How does one run CLUSTER on a table using the PgAdmin GUI? (assuming I >> have an index I selected "clustered" on) >> > > AFAICT, you can't. You can add the cluster bit on an index, but that's > all you can do. Seems we missed something that would be interesting to > add in 1.16.
Okay, here's a patch for it. (see attached) Not entirely confident on the elegance of the code, but had a stab at it. -- 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/frm/frmMaintenance.cpp b/pgadmin/frm/frmMaintenance.cpp index d044b12..07fb104 100644 --- a/pgadmin/frm/frmMaintenance.cpp +++ b/pgadmin/frm/frmMaintenance.cpp @@ -90,6 +90,9 @@ wxString frmMaintenance::GetHelpPage() const case 2: page = wxT("pg/sql-reindex"); break; + case 3: + page = wxT("pg/sql-cluster"); + break; } return page; } @@ -104,11 +107,17 @@ void frmMaintenance::OnAction(wxCommandEvent &ev) chkAnalyze->Enable(isVacuum); bool isReindex = (rbxAction->GetSelection() == 2); - if (isReindex) + bool isCluster = (rbxAction->GetSelection() == 3); + if (isReindex || (isCluster && !conn->BackendMinimumVersion(8, 4))) { chkVerbose->SetValue(false); + chkVerbose->Enable(false); + } + else + { + chkVerbose->SetValue(true); + chkVerbose->Enable(true); } - chkVerbose->Enable(!isReindex); } @@ -168,6 +177,27 @@ wxString frmMaintenance::GetSql() } break; } + case 3: + { + sql = wxT("CLUSTER "); + + if (chkVerbose->GetValue()) + sql += wxT("VERBOSE "); + if (object->GetMetaType() == PGM_TABLE) + sql += object->GetQuotedFullIdentifier(); + if (object->GetMetaType() == PGM_INDEX) + { + sql += object->GetTable()->GetQuotedFullIdentifier(); + if (conn->BackendMinimumVersion(8, 4)) + { + sql += wxT(" USING ") + object->GetQuotedIdentifier(); + } + else + { + sql += wxT(" ON ") + object->GetQuotedIdentifier(); + } + } + } } return sql; diff --git a/pgadmin/ui/frmMaintenance.xrc b/pgadmin/ui/frmMaintenance.xrc index 436c0d4..ab8fc49 100644 --- a/pgadmin/ui/frmMaintenance.xrc +++ b/pgadmin/ui/frmMaintenance.xrc @@ -28,6 +28,7 @@ <item>VACUUM</item> <item>ANALYZE</item> <item>REINDEX</item> + <item>CLUSTER</item> </content> <selection>0</selection> <style>wxRA_SPECIFY_ROWS</style>
-- Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-support