On Fri, 2012-08-17 at 11:39 +0600, Timon wrote:
> and, one more little bug
> altering index fillfactor produces wrong sql code
> steps to reproduce:
>
> 1. create table
> 2. add index
> 3. chage fillfactor on created index
> 4. got error like "scheme name <table name> doesn't exists"
> example of sql: ALTER INDEX gallery.idx_gallery_regionid_itemiddesc
> SET (FILLFACTOR=80);
> gallery is the table name
>
Thanks, I modified my patch to take care of this too. New (rebased)
patch attached.
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
diff --git a/pgadmin/dlg/dlgIndex.cpp b/pgadmin/dlg/dlgIndex.cpp
index 0077c38..c12b006 100644
--- a/pgadmin/dlg/dlgIndex.cpp
+++ b/pgadmin/dlg/dlgIndex.cpp
@@ -601,7 +601,7 @@ wxString dlgIndex::GetSql()
else
{
if (connection->BackendMinimumVersion(8, 2) && txtFillFactor->GetValue().Length() > 0)
- sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".")
+ sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetSchema()->GetName()) + wxT(".")
+ qtIdent(index->GetName()) + wxT("\n SET (FILLFACTOR=")
+ txtFillFactor->GetValue() + wxT(");\n");
@@ -609,12 +609,12 @@ wxString dlgIndex::GetSql()
{
if (index->GetName() != txtName->GetValue() &&
!txtName->GetValue().IsEmpty())
- sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".")
+ sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetSchema()->GetName()) + wxT(".")
+ qtIdent(index->GetName()) + wxT("\n RENAME TO ")
+ qtIdent(txtName->GetValue()) + wxT(";\n");
if (cbTablespace->GetOIDKey() != index->GetTablespaceOid())
- sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".") + qtIdent(name)
+ sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetSchema()->GetName()) + wxT(".") + qtIdent(name)
+ wxT("\n SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+ wxT(";\n");
}
diff --git a/pgadmin/dlg/dlgIndexConstraint.cpp b/pgadmin/dlg/dlgIndexConstraint.cpp
index 462c48c..ce04710 100644
--- a/pgadmin/dlg/dlgIndexConstraint.cpp
+++ b/pgadmin/dlg/dlgIndexConstraint.cpp
@@ -569,14 +569,14 @@ wxString dlgIndexConstraint::GetSql()
}
if (connection->BackendMinimumVersion(8, 0) && cbTablespace->GetOIDKey() != index->GetTablespaceOid())
{
- sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
+ sql += wxT("ALTER INDEX ") + index->GetSchema()->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
+ wxT("\n SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+ wxT(";\n");
}
if (txtFillFactor->GetValue().Trim().Length() > 0 && txtFillFactor->GetValue() != index->GetFillFactor())
{
- sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
+ sql += wxT("ALTER INDEX ") + index->GetSchema()->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
+ wxT("\n SET (FILLFACTOR=")
+ txtFillFactor->GetValue() + wxT(");\n");
}
diff --git a/pgadmin/frm/frmMaintenance.cpp b/pgadmin/frm/frmMaintenance.cpp
index 6d347cf..c39ac11 100644
--- a/pgadmin/frm/frmMaintenance.cpp
+++ b/pgadmin/frm/frmMaintenance.cpp
@@ -192,7 +192,7 @@ wxString frmMaintenance::GetSql()
if (object->GetMetaType() == PGM_INDEX || object->GetMetaType() == PGM_UNIQUE
|| object->GetMetaType() == PGM_PRIMARYKEY)
{
- sql += object->GetTable()->GetQuotedFullIdentifier();
+ sql += object->GetSchema()->GetQuotedFullIdentifier();
if (conn->BackendMinimumVersion(8, 4))
{
sql += wxT(" USING ") + object->GetQuotedIdentifier();
diff --git a/pgadmin/schema/pgIndex.cpp b/pgadmin/schema/pgIndex.cpp
index a1c9bf5..206bc51 100644
--- a/pgadmin/schema/pgIndex.cpp
+++ b/pgadmin/schema/pgIndex.cpp
@@ -699,7 +699,7 @@ pgIndexBaseCollection::pgIndexBaseCollection(pgaFactory *factory, pgSchema *sch)
void pgIndexBaseCollection::ShowStatistics(frmMain *form, ctlListView *statistics)
{
- wxLogInfo(wxT("Displaying statistics for indexes on ") + GetTable()->GetName());
+ wxLogInfo(wxT("Displaying statistics for indexes on ") + GetSchema()->GetName());
bool hasSize = GetConnection()->HasFeature(FEATURE_SIZE);
@@ -723,8 +723,8 @@ void pgIndexBaseCollection::ShowStatistics(frmMain *form, ctlListView *statistic
wxT(" JOIN pg_class cls ON cls.oid=indexrelid\n")
wxT(" LEFT JOIN pg_depend dep ON (dep.classid = cls.tableoid AND dep.objid = cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM pg_class WHERE relname='pg_constraint'))\n")
wxT(" LEFT OUTER JOIN pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)\n")
- wxT(" WHERE schemaname = ") + qtDbString(GetTable()->GetSchema()->GetName())
- + wxT(" AND stat.relname = ") + qtDbString(GetTable()->GetName())
+ wxT(" WHERE schemaname = ") + qtDbString(GetSchema()->GetSchema()->GetName())
+ + wxT(" AND stat.relname = ") + qtDbString(GetSchema()->GetName())
+ wxT(" AND con.contype IS NULL")
+ wxT("\n ORDER BY indexrelname");
diff --git a/pgadmin/schema/pgObject.cpp b/pgadmin/schema/pgObject.cpp
index 5288bf8..e222f50 100644
--- a/pgadmin/schema/pgObject.cpp
+++ b/pgadmin/schema/pgObject.cpp
@@ -1443,7 +1443,10 @@ wxString pgSchemaObject::GetFullIdentifier() const
wxString pgSchemaObject::GetQuotedFullIdentifier() const
{
- return schema->GetQuotedPrefix() + GetQuotedIdentifier();
+ if (schema->GetTypeName() == wxT("Table"))
+ return schema->GetSchema()->GetQuotedPrefix() + GetQuotedIdentifier();
+ else
+ return schema->GetQuotedPrefix() + GetQuotedIdentifier();
}
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers