Re: CREATE SYNONYM suggestions - Mailing list pgsql-hackers

From Marc Lavergne
Subject Re: CREATE SYNONYM suggestions
Date
Msg-id 3D3F1BBD.5090506@richlava.com
Whole thread Raw
In response to CREATE SYNONYM suggestions  (Marc Lavergne <mlavergne-pub@richlava.com>)
Responses Re: CREATE SYNONYM suggestions
List pgsql-hackers
I thought that it might involve more than met the eye. I'm resisting the 
"view" approach since, like my bad kludge, it locks down the table 
definition and as a result doesn't provide a very effective synonym 
mechanism.

I'm looking into the commands/view.c as a basis for introducing the 
concept of synonyms. Based on what I see, it looks like implementing it 
should be too terrible. Sadly, it looks a lot like this would require 
introducing a new relation type.

I'll have to investigate and possibly submit the patch(es) later. The 
question is, since CREATE SYNONYM appears to be a SQL extension, is this 
something the group would want to incorporate?

Tom Lane wrote:
> 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: bug in COPY
Next
From: nconway@klamath.dyndns.org (Neil Conway)
Date:
Subject: Re: bug in COPY