Re: public.pg_class isn't a catalog table - Mailing list pgadmin-hackers

From Euler Taveira de Oliveira
Subject Re: public.pg_class isn't a catalog table
Date
Msg-id 46DF83AE.60203@timbira.com
Whole thread Raw
In response to public.pg_class isn't a catalog table  (Decibel! <decibel@decibel.org>)
Responses Re: public.pg_class isn't a catalog table
Re: public.pg_class isn't a catalog table
List pgadmin-hackers
Decibel! wrote:

> Version 1.6.3; if you have a table in public called pg_class and try to
> drop it, pgAdmin gives an error:
>
> ERROR: permission denied: "pg_class" is a system catalog
>
That's because pgAdmin is issuing "DROP TABLE pg_class" instead of "DROP
TABLE public.pg_class". By the way, is there any reason for not using
the namespace?
I don't know if it's the best way but this little proof of concept fix
might be applied to all objects that can be created inside a schema. I
could provide I patch if you want it.


--
  Euler Taveira de Oliveira
  http://www.timbira.com/
Index: pgadmin/schema/pgTable.cpp
===================================================================
--- pgadmin/schema/pgTable.cpp    (revis�o 6614)
+++ pgadmin/schema/pgTable.cpp    (c�pia de trabalho)
@@ -126,7 +126,13 @@

 bool pgTable::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
 {
-    wxString sql = wxT("DROP TABLE ") + GetQuotedFullIdentifier();
+    wxString sql;
+
+    if (this->GetSchema()->GetName() == this->GetDatabase()->GetDefaultSchema())
+        sql = wxT("DROP TABLE ") + this->GetSchema()->GetName() + wxT(".") + GetQuotedFullIdentifier();
+    else
+        sql = wxT("DROP TABLE ") + GetQuotedFullIdentifier();
+
     if (cascaded)
         sql += wxT(" CASCADE");
     return GetDatabase()->ExecuteVoid(sql);

pgadmin-hackers by date:

Previous
From: Decibel!
Date:
Subject: Re: Maintenance on indexes
Next
From: Guillaume Lelarge
Date:
Subject: Re: public.pg_class isn't a catalog table