Re: CREATE SYNONYM suggestions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marc Lavergne <mlavergne-pub(at)richlava(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE SYNONYM suggestions
Date: 2002-07-24 15:43:30
Message-ID: 11771.1027525410@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2002-07-24 16:51:10 Proposal: anonymous composite types for Table Functions (aka SRFs)
Previous Message Tom Lane 2002-07-24 15:05:49 Re: partial index on system indexes?