Re: public.pg_class isn't a catalog table

Поиск
Список
Период
Сортировка
От Dave Page
Тема Re: public.pg_class isn't a catalog table
Дата
Msg-id 46DFB23D.4070209@postgresql.org
обсуждение исходный текст
Ответ на Re: public.pg_class isn't a catalog table  (Euler Taveira de Oliveira <euler@timbira.com>)
Ответы Re: public.pg_class isn't a catalog table  (Dave Page <dpage@postgresql.org>)
Список pgadmin-hackers
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


В списке pgadmin-hackers по дате отправления:

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: Beta 4 uploaded
Следующее
От: Dave Page
Дата:
Сообщение: Re: public.pg_class isn't a catalog table