Re: CREATE SYNONYM suggestions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: CREATE SYNONYM suggestions
Date
Msg-id 11771.1027525410@sss.pgh.pa.us
Whole thread Raw
In response to CREATE SYNONYM suggestions  (Marc Lavergne <mlavergne-pub@richlava.com>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: partial index on system indexes?
Next
From: Joe Conway
Date:
Subject: Proposal: anonymous composite types for Table Functions (aka SRFs)