Re: public.pg_class isn't a catalog table

From: Dave Page <dpage(at)postgresql(dot)org>
To: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
Cc: "Decibel!" <decibel(at)decibel(dot)org>, pgadmin-hackers(at)postgresql(dot)org
Subject: Re: public.pg_class isn't a catalog table
Date: 2007-09-06 07:54:37
Message-ID: 46DFB23D.4070209@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers pgsql-bugs

Euler Taveira de Oliveira wrote:
> 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?

It's cosmetic, for when the reverse engineered SQL is generated. Most
people prefer not to see the schema prefixed when it's not needed. Of
course, that's no reason to mess around with hidden SQL to drop the object.

This falls over when the user creates objects with the same name as
those in pg_catalog of course. The normal response is 'Don't do that!'

> 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.

The patch is essentially reversing the logic to prevents the schema
being put there in the first place (which happens somewhere down the
stack under GetQuotedFullIdentifier). It would be a little cleaner just
to always construct the name manually.

For the record, here's some clarification on some of the schema member
functions:

->GetName() // Returns the name of the object

->GetIdentifier() // Returns the identifier - e.g. for a function, this
is the name and signature

->GetQuotedName() // Returns the name, quoted if necessary\

->GetQuotedIdentifier() // Returns the identifier, quoted if necessary

->GetQuotedFullIdentifier() // Returns the quoted identifier, with a
quoted schema prefix, *if* the prefix is required.

I'll commit the following new SQL to pgTable::DropObject:

wxString sql = wxT("DROP TABLE ") +
this->GetSchema()->GetQuotedIdentifier() + wxT(".") +
this->GetQuotedIdentifier();

Regards, Dave

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Dave Page 2007-09-06 08:15:04 Re: public.pg_class isn't a catalog table
Previous Message Devrim GÜNDÜZ 2007-09-06 07:33:05 Re: Beta 4 uploaded

Browse pgsql-bugs by date

  From Date Subject
Next Message Dave Page 2007-09-06 08:15:04 Re: public.pg_class isn't a catalog table
Previous Message Guillaume Lelarge 2007-09-06 06:23:46 Re: public.pg_class isn't a catalog table