diff --git a/include/schema/pgIndexConstraint.h b/include/schema/pgIndexConstraint.h index d0ac414..55bb784 100644 --- a/include/schema/pgIndexConstraint.h +++ b/include/schema/pgIndexConstraint.h @@ -22,6 +22,7 @@ public: void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0); bool DropObject(wxFrame *frame, ctlTree *browse, bool cascadedr); wxString GetDefinition(); + wxString GetDefinitionCluster(); wxString GetCreate(); wxString GetSql(ctlTree *browser); wxString GetHelpPage(bool forCreate) const diff --git a/schema/pgIndexConstraint.cpp b/schema/pgIndexConstraint.cpp index 3d598f0..9c52673 100644 --- a/schema/pgIndexConstraint.cpp +++ b/schema/pgIndexConstraint.cpp @@ -102,7 +102,6 @@ bool pgIndexConstraint::DropObject(wxFrame *frame, ctlTree *browser, bool cascad return GetDatabase()->ExecuteVoid(sql); } - wxString pgIndexConstraint::GetDefinition() { wxString sql = wxEmptyString; @@ -146,6 +145,15 @@ wxString pgIndexConstraint::GetCreate() return sql; }; +wxString pgIndexConstraint::GetDefinitionCluster() +{ + wxString sql; + if (GetIsClustered()) + sql += wxT("ALTER TABLE ") + GetQuotedSchemaPrefix(GetIdxSchema()) + qtIdent(GetIdxTable()) + + wxT(" CLUSTER ON ") + qtIdent(GetName()) + + wxT(";\n"); + return sql; +} wxString pgIndexConstraint::GetSql(ctlTree *browser) { @@ -164,6 +172,7 @@ wxString pgIndexConstraint::GetSql(ctlTree *browser) sql += wxT("COMMENT ON CONSTRAINT ") + GetQuotedIdentifier() + wxT(" ON ") + GetQuotedSchemaPrefix(GetIdxSchema()) + qtIdent(GetIdxTable()) + wxT(" IS ") + qtDbString(GetComment()) + wxT(";\n"); } + } return sql; } diff --git a/schema/pgTable.cpp b/schema/pgTable.cpp index 06d1877..3da9740 100644 --- a/schema/pgTable.cpp +++ b/schema/pgTable.cpp @@ -323,7 +323,7 @@ wxString pgTable::GetSql(ctlTree *browser) wxString cols_sql = wxEmptyString; wxString cols_type = wxEmptyString; wxString columnPrivileges; - + wxString defpkcluster; if (sql.IsNull()) { // make sure all kids are appended @@ -475,6 +475,7 @@ wxString pgTable::GetSql(ctlTree *browser) case PGM_UNIQUE: case PGM_EXCLUDE: cols_sql += ((pgIndexConstraint *)data)->GetDefinition(); + if (data->GetMetaType()== PGM_PRIMARYKEY) defpkcluster= ((pgIndexConstraint*)data)->GetDefinitionCluster(); break; case PGM_FOREIGNKEY: cols_sql += ((pgForeignKey *)data)->GetDefinition(); @@ -748,6 +749,7 @@ wxString pgTable::GetSql(ctlTree *browser) } AppendStuff(sql, browser, indexFactory); + if (!defpkcluster.IsEmpty()) sql += defpkcluster; AppendStuff(sql, browser, ruleFactory); AppendStuff(sql, browser, triggerFactory);