On Wed, 2012-06-06 at 10:50 +0600, Timon wrote: > seems that this commit broke reindexing of selected index. steps to reproduce: > 1) create table > 2) create index > 3) select index in object inspector > 4) try to reindex it via maintenance menu item > 5) got error : ERROR: schema "table_name" does not exist > > and one more crash here > .. same steps as before > 4) try to CLUSTER index > 5) pgadmin simply crashed >
OK, I finally got some time to work on this. As Timon said, these bugs come from the patch "Lots of work on domains, and check constraints". In this patch, I changed some objects parent class from pgTableObject to pgSchemaObject. Due to this change, the GetTable() method returns NULL, which segfaults all statements that try to use the return value without checking. The two examples above from Timon are exactly this. I don't see many ways to get out of this issue. We could use GetSchema() instead of GetTable(). It works, it's an easy and small patch. But it'll certainly be a maintenance nightmare (at least without any comments) We could also revert my patch. It's simple, we loose the feature of adding as many check constraints as we want to a domain, we loose the feature of renaming and validating constraints, and we gain a few bugs. I don't see any other options. My own personal choice would be the first one (see attached patch). But it's a tough call. Comments? -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com
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 49f6ea3..ef15c22 100644 --- a/pgadmin/schema/pgIndex.cpp +++ b/pgadmin/schema/pgIndex.cpp @@ -698,7 +698,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); @@ -722,8 +722,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 6d86a2e..392a01d 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 (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers