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 <[EMAIL PROTECTED]> 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 > ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly