Re: Do we want SYNONYMS? - Mailing list pgsql-general

From Andy Colson
Subject Re: Do we want SYNONYMS?
Date
Msg-id 4CFE5075.6030400@squeakycode.net
Whole thread Raw
In response to Re: Do we want SYNONYMS?  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: Do we want SYNONYMS?  (Dmitriy Igrishin <dmitigr@gmail.com>)
List pgsql-general
On 12/7/2010 8:12 AM, Daniel Verite wrote:
>     Vick Khera wrote:
>
>> On Mon, Dec 6, 2010 at 2:31 PM, Joshua D. Drake<jd@commandprompt.com>
>> wrote:
>>> Command Prompt is currently considering writing a patch to provide
>>> synonyms to PostgreSQL. Is this something the community is interested
>>> in? Do we have use cases for it? MSSQL, DB2 and Oracle support them.
>>>
>>
>> I must be missing something, but really, what's the point of synonyms?
>>   What's the real-world use case for them?
>
> It's about decoupling the name from the actual object, much like what soft
> links are for file systems.
> It's convenient when you need to change the underlying object without
> touching the application code.
>
> Best regards,

So, you could rename a table without having to change the code?  But you
cant rename a column, or drop one, and thats a much more common thing
I'd bet.  And eventually you would change the code, right?  Isn't it
much better to keep everyone on the same page?  If you have 10 program
using 10 different names for the same table... how can that possibly be
useful?  Just sounds confusing and troublesome.

I can see a situation for live/hot upgrades.  Having old code and new
code run at the same time.  But eventually the old code would go away,
and I think the same thing could be handled with views.  (perhaps
updateable view's would be required... but still)

I dont see a situation where an alias gives me something updateable
views dont.  I'd vote we spend time on updateable views instead.

And the types:

table: maybe useful for live upgrade, but views, transactons and stored
procs do the same thing.

views: just create the new view.  Have both.  when the old code goes
away, drop the old view.  No need for an alias.

sequence:  why bother?  Other than renaming during live upgrade, why
would you need an alias?

index:  again, why bother... code really should not ever be dependent on
an indexes name, correct?  And transactions take care of live updates.

So for the two use cases I've seen (live update, directing data flow
(which is kinda like a live update)) we already have tools that do it:
transactional ddl, views, schemas, stored procs, etc.  Updateable views
might be the only thing missing.

Also:  I wonder if it might be a bad idea.  The people coming from
oracle will see that PG supports synonyms, and they'll be all happy, but
when they get into the guts of their translate they find PG's synonyms
are different (and not compatible), and they have to throw it out and
use schemas instead.

On the other hand, now that I think about it, if its really easy, it
might help a few people out, then why not.  On the other other hand, if
its not so easy, I think the time would be better spent on updatable views.

So here is my new vote:
IF its easy and wont slow anything down: +1
IF its hard: -1 (and spend the time on more important things)

-Andy

pgsql-general by date:

Previous
From: Steve Clark
Date:
Subject: dotted quad netmask conversion
Next
From: paulo matadr
Date:
Subject: restore In parallel postgres 9