Hi,

If we use pgadmin III to browse a PPAS database that was installed in
Postgresql mode, the "sys" and "dbo" system schemas appear incorrectly under
the normal user "Schemas" hierarchy. The issue is occurring because the
current sql in pgSchemaBaseFactory::CreateObjects() which tries to avoid
showing non-system schemas is incorrect.

Since these schemas are added at initdb time, IMO just checking for these
schemas by name should be enough. This patch does just the same.

Regards,
Nikhils
diff --git a/pgadmin/schema/pgSchema.cpp b/pgadmin/schema/pgSchema.cpp
index 1c2df2d..2b87abc 100644
--- a/pgadmin/schema/pgSchema.cpp
+++ b/pgadmin/schema/pgSchema.cpp
@@ -438,8 +438,13 @@ pgObject *pgSchemaBaseFactory::CreateObjects(pgCollection *collection, ctlTree *
 	restr += wxT("(nspname = 'pgagent' AND EXISTS (SELECT 1 FROM pg_class WHERE relname = 'pga_job' AND relnamespace = nsp.oid LIMIT 1)) OR\n");
 	restr += wxT("(nspname = 'information_schema' AND EXISTS (SELECT 1 FROM pg_class WHERE relname = 'tables' AND relnamespace = nsp.oid LIMIT 1)) OR\n");
 	restr += wxT("(nspname LIKE '_%' AND EXISTS (SELECT 1 FROM pg_proc WHERE proname='slonyversion' AND pronamespace = nsp.oid LIMIT 1)) OR\n");
-	restr += wxT("(nspname = 'dbo' AND EXISTS (SELECT 1 FROM pg_class WHERE relname = 'systables' AND relnamespace = nsp.oid LIMIT 1)) OR\n");
-	restr += wxT("(nspname = 'sys' AND EXISTS (SELECT 1 FROM pg_class WHERE relname = 'all_tables' AND relnamespace = nsp.oid LIMIT 1)))\n");
+
+	// We add the below schemas at initdb time itself. So users cannot create
+	// schemas of the same name later. However if DB is started in PostgreSQL
+	// mode, we do not install all other edb-sys.sql objects. So just checking
+	// for presence of schemas with such names should be enough..
+	if (collection->GetConnection()->EdbMinimumVersion(8, 1))
+		restr += wxT("(nspname = 'dbo' OR nspname = 'sys'))\n");
 
 	if (collection->GetConnection()->EdbMinimumVersion(8, 2))
 	{
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to