From: | Marc Lavergne <mlavergne-pub(at)richlava(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: CREATE SYNONYM suggestions |
Date: | 2002-07-24 21:27:25 |
Message-ID: | 3D3F1BBD.5090506@richlava.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)richlava(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2002-07-24 22:32:00 | Re: bug in COPY |
Previous Message | Tom Lane | 2002-07-24 20:23:56 | Re: bug in COPY |