Displaying the "Cluster" property of the primary key.

Исправлено отображение признака кластеризации у первичного ключа.
This commit is contained in:
lsv 2025-02-05 09:59:32 +05:00 committed by lsv
parent 96e23cc7b4
commit b7b911c93b
3 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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);