Re: [pgadmin-hackers] pgAdmin III commit: Lots of work on domains, and check constraints

2012-07-21 Thread Guillaume Lelarge
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


[pgadmin-hackers] pgAdmin III commit: Add *.dirstamp pattern to .gitignore

2012-07-21 Thread Guillaume Lelarge
Add *.dirstamp pattern to .gitignore

Branch
--
REL-1_16_0_PATCHES

Details
---
http://git.postgresql.org/gitweb?p=pgadmin3.git;a=commitdiff;h=71c10ebef25a03f5e838141c5e52654a18de774d

Modified Files
--
.gitignore |1 +
1 files changed, 1 insertions(+), 0 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] pgAdmin III commit: Add *.dirstamp pattern to .gitignore

2012-07-21 Thread Guillaume Lelarge
Add *.dirstamp pattern to .gitignore

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin3.git;a=commitdiff;h=4550888b393625b17006f022e406acdcc5a9

Modified Files
--
.gitignore |1 +
1 files changed, 1 insertions(+), 0 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] pgAdmin III commit: Fix the database stats query

2012-07-21 Thread Guillaume Lelarge
Fix the database stats query

Branch
--
REL-1_16_0_PATCHES

Details
---
http://git.postgresql.org/gitweb?p=pgadmin3.git;a=commitdiff;h=9adeb4fbef3fae2c2270a68d82a9179c95fc38fe

Modified Files
--
pgadmin/schema/pgDatabase.cpp |4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] pgAdmin III commit: Fix the database stats query

2012-07-21 Thread Guillaume Lelarge
Fix the database stats query

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin3.git;a=commitdiff;h=5d43fc771ad7e27a1e8b87f23dd0e013496269f1

Modified Files
--
pgadmin/schema/pgDatabase.cpp |4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers