Re: CREATE SYNONYM suggestions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CREATE SYNONYM suggestions
Дата
Msg-id 11771.1027525410@sss.pgh.pa.us
обсуждение исходный текст
Ответ на CREATE SYNONYM suggestions  (Marc Lavergne <mlavergne-pub@richlava.com>)
Список pgsql-hackers
Marc Lavergne <mlavergne-pub@richlava.com> writes:
> I have a need for relation synonyms in PostgreSQL. I don't see it in 
> 7.2.1 but the catalog seems to be able to support it more or less.

> Here's what I intend to do:

> 1) Create a duplicate record in pg_class for the base table information 
> but with the relname set to the synonym name.

> 2) Duplicate the attribute information in pg_attribute for the base 
> table but with the attrelid set to the synonym oid.

> Is there anything fundamentally wrong with this approach?

YES.   You just broke relation locking (a lock by OID will only lock
one access path to the table).  Any sort of ALTER seems quite
problematical as well; how will it know to update both sets of catalog
entries?

A view seems like a better idea, especially since you can do it without
any backend changes.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: partial index on system indexes?
Следующее
От: Joe Conway
Дата:
Сообщение: Proposal: anonymous composite types for Table Functions (aka SRFs)