On 2 July 2011 23:57, Thom Brown <[email protected]> wrote:
> On 2 July 2011 13:11, Guillaume Lelarge <[email protected]> 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.
Oh, just discovered you can cluster on a primary key or a unique
constraint, so modified it to support those too. (revised patch
attached)
--
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..6e7e695 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,28 @@ 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 || object->GetMetaType() == PGM_UNIQUE
+ || object->GetMetaType() == PGM_PRIMARYKEY)
+ {
+ 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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support