Index DROP and CREATE statements are now shown.
For now the create is still single line. Either complex query is required to get details for custom generator or we need to format after the fact. Close #12
This commit is contained in:
parent
78a6666839
commit
f1020ac56e
3 changed files with 28 additions and 12 deletions
|
|
@ -146,7 +146,7 @@ void TablesPage::indexesTable_selectionChanged(const QItemSelection &/*selected*
|
||||||
QString creates;
|
QString creates;
|
||||||
for (auto rij : rijen) {
|
for (auto rij : rijen) {
|
||||||
const PgIndex index = m_indexModel->getIndex(rij);
|
const PgIndex index = m_indexModel->getIndex(rij);
|
||||||
//drops += getDropIndexDefinition(*m_catalog, index) % "\n";
|
drops += getDropIndexDefinition(*m_catalog, index) % "\n";
|
||||||
creates += getIndexDefinition(*m_catalog, index) % "\n";
|
creates += getIndexDefinition(*m_catalog, index) % "\n";
|
||||||
}
|
}
|
||||||
ui->indexSqlEdit->setPlainText(drops % "\n" % creates);
|
ui->indexSqlEdit->setPlainText(drops % "\n" % creates);
|
||||||
|
|
|
||||||
|
|
@ -177,18 +177,18 @@ QString getIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &inde
|
||||||
PgClass index_class = catalog.classes()->getByKey(index.indexrelid);
|
PgClass index_class = catalog.classes()->getByKey(index.indexrelid);
|
||||||
|
|
||||||
|
|
||||||
|
return index.definition + ";";
|
||||||
|
|
||||||
|
// QString result;
|
||||||
QString result;
|
// result = "CREATE ";
|
||||||
result = "CREATE ";
|
// if (index.isunique)
|
||||||
if (index.isunique)
|
// result += "UNIQUE ";
|
||||||
result += "UNIQUE ";
|
// result += "INDEX "
|
||||||
result += "INDEX "
|
//// % quoteIdent(getIndexDisplayString(catalog, index.indexrelid))
|
||||||
// % quoteIdent(getIndexDisplayString(catalog, index.indexrelid))
|
// % quoteIdent(index_class.name)
|
||||||
% quoteIdent(index_class.name)
|
// % "\n ON " % genFQTableName(catalog, table_class);
|
||||||
% "\n ON " % genFQTableName(catalog, table_class);
|
//// % "\n USING " % index_class.am lookup in pg_am table
|
||||||
// % "\n USING " % index_class.am lookup in pg_am table
|
// return result;
|
||||||
return result;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
+ wxT("\n USING ") + GetIndexType()
|
+ wxT("\n USING ") + GetIndexType()
|
||||||
|
|
@ -222,6 +222,21 @@ QString getIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &inde
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString getDropIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index)
|
||||||
|
{
|
||||||
|
PgClass table_class = catalog.classes()->getByKey(index.relid);
|
||||||
|
PgClass index_class = catalog.classes()->getByKey(index.indexrelid);
|
||||||
|
|
||||||
|
QString result;
|
||||||
|
result = "DROP INDEX "
|
||||||
|
% quoteIdent(getIndexDisplayString(catalog, index.indexrelid))
|
||||||
|
% ";";
|
||||||
|
// % quoteIdent(index_class.name)
|
||||||
|
// % "\n ON " % genFQTableName(catalog, table_class);
|
||||||
|
//// % "\n USING " % index_class.am lookup in pg_am table
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
wxString sql;
|
wxString sql;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ QString genFQTableName(const PgDatabaseCatalog &catalog, const PgClass &cls);
|
||||||
QString getDropConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
|
QString getDropConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
|
||||||
QString getConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
|
QString getConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
|
||||||
QString getIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index);
|
QString getIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index);
|
||||||
|
QString getDropIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index);
|
||||||
QString getForeignKeyConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
|
QString getForeignKeyConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
|
||||||
|
|
||||||
#endif // SQLFORMATTINGUTILS_H
|
#endif // SQLFORMATTINGUTILS_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue