Show moer information about the indexes.
This commit is contained in:
parent
8c20bd6a02
commit
61645d44ac
5 changed files with 110 additions and 25 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include "PgAttributeContainer.h"
|
||||
#include "PgClass.h"
|
||||
#include "PgClassContainer.h"
|
||||
#include "PgIndex.h"
|
||||
#include "PgNamespace.h"
|
||||
#include "PgNamespaceContainer.h"
|
||||
#include "PgDatabaseCatalog.h"
|
||||
|
|
@ -19,7 +20,7 @@ bool identNeedsQuotes(QString ident)
|
|||
if (ident[0].isDigit())
|
||||
return true;
|
||||
for (auto c : ident)
|
||||
if (c < 'a' && c > 'z' && c != '_')
|
||||
if ((c < 'a' || c > 'z') && c != '_')
|
||||
return true;
|
||||
|
||||
auto kw = getPgsqlKeyword(ident);
|
||||
|
|
@ -170,6 +171,57 @@ QString getConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstr
|
|||
return result;
|
||||
}
|
||||
|
||||
QString getIndexDefinition(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 = "CREATE ";
|
||||
if (index.isunique)
|
||||
result += "UNIQUE ";
|
||||
result += "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;
|
||||
|
||||
#if 0
|
||||
+ wxT("\n USING ") + GetIndexType()
|
||||
+ wxT("\n (");
|
||||
if (GetProcName().IsNull())
|
||||
str += GetQuotedColumns();
|
||||
else
|
||||
{
|
||||
str += GetQuotedSchemaPrefix(GetProcNamespace()) + qtIdent(GetProcName()) + wxT("(") + GetQuotedColumns() + wxT(")");
|
||||
if (!this->GetOperatorClasses().IsNull())
|
||||
str += wxT(" ") + GetOperatorClasses();
|
||||
}
|
||||
|
||||
str += wxT(")");
|
||||
|
||||
if (GetConnection()->BackendMinimumVersion(8, 2) && GetFillFactor().Length() > 0)
|
||||
str += wxT("\n WITH (FILLFACTOR=") + GetFillFactor() + wxT(")");
|
||||
|
||||
if (GetConnection()->BackendMinimumVersion(8, 0) && tablespace != GetDatabase()->GetDefaultTablespace())
|
||||
str += wxT("\nTABLESPACE ") + qtIdent(tablespace);
|
||||
|
||||
AppendIfFilled(str, wxT("\n WHERE "), GetConstraint());
|
||||
|
||||
str += wxT(";\n");
|
||||
|
||||
if (GetConnection()->BackendMinimumVersion(7, 5))
|
||||
if (GetIsClustered())
|
||||
str += wxT("ALTER TABLE ") + GetQuotedSchemaPrefix(GetIdxSchema()) + qtIdent(GetIdxTable())
|
||||
+ wxT(" CLUSTER ON ") + qtIdent(GetName())
|
||||
+ wxT(";\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
wxString sql;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue