You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@debrunners.com> on 2005/06/02 01:02:56 UTC

Re: [PATCH] Synonym support in Derby.

Satheesh Bandaram wrote:

> Hi
> 
> I am attaching a patch that adds SYNONYM support to Derby.  Synonym
> provides an alternate name for a table or a view that is present in the
> same schema or another schema. A synonym can also be created for another
> synonym, causing nesting of synonyms. A synonym can be used in SELECT,
> INSERT, UPDATE, DELETE or LOCK TABLE statements instead of the original
> qualified table or view name. Note that a synonym can be created for a
> table or a view that doesn't yet exists. But the target table/view must
> be present before the synonym can be used.

[snip]

> Let me know if you have any comments or suggestions. My vote is *+1*, to
> accept this patch.

Any explanation of how SYNONYMs are implemented? You had indicated a
couple of days ago you were undecided on how to represent them in system
catalogs.

Is the namespace for SYNONYM the same as for tables, or separate? If
separate and A.B is both a table name and a synoymn name, which is selected?

Dan.


Re: [PATCH] Synonym support in Derby.

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Satheesh Bandaram wrote:


>    2. While I am providing implementation that allows creating synonyms
>       for tables and views, it is possible to extend this mechanism to
>       other database objects as well, like procedures or functions. Some
>       of the database vendors already support this.

How does that work? If I create

CREATE SYNONYM B FOR A


Does this synonym work for tables, views procedures, functions etc?

CALL B -> really is CALL A;
SELECT B() * FROM B -> really is SELECT A() * FROM A

Ie. with the same single synonym?


Thus if in in the future Derby extended SYNONYM support to procedures
and functions, then creating a synonym B would have to ensure all of
the following:
   - no tables called B
   - no views called B
   - no procedures called B
   - no functions called B

Thus the synonym namespace is really a union of the namespaces it can
map to?

Dan.



Re: [PATCH] Synonym support in Derby.

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Satheesh Bandaram wrote:

> Could this possibly lead to dead-locks? If someone is trying to create a
> table and another trying to create a synonym could possibly block each
> other. I have a feeling you have a better way to do this, so what is it?

No i don't have a better way to do this, I'm trying to understand how
you implemented SYNONYNs, your e-mail has the functionality descibed but
not the implementation. To quote an extract from:

http://incubator.apache.org/derby/derby_comm.html#Contribute+Code+or+Documentation

[quote]

 Post the patch to the derby-dev mail list or attach it to the Jira
issue. Include the following information with your post:
[snip]
 - A description of the changes, e.g. how a feature is implemented or
why the change fixes a bug. Hopefully this will be in comments in the
code but sometimes an overview in the e-mail is useful, or have the
e-mail point to an overview in the code comments.
[snip]

[end-quote]

I imagine this functionality could possibly be implemented using
SYSTABLES and TableDescriptor or SYSALIASES and AliasDescritpor.
I'm sure there would be different problems in each approach, it would be
interesting to see your approach explained.

Dan.




Re: [PATCH] Synonym support in Derby.

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Satheesh Bandaram wrote:

> I almost submitted a patch using option 1, like I said I would. I have
> added a SynonymAliasInfo to hold target of a synonym, which is
> schemaName.tableName. I think this schemaName needs to be stored as a
> name, instead of an ID so that the synonym stays valid even after
> droping and recreating the target schema.

That seems like correct behaviour.

> Yes, the namespace for SYNONYM is the same for tables and views. You
> can't create a synonym if a table of that name already exists.

An explanation of how this is enforced would be good, another approach
would be to introduce a new table type in SYSTABLES, and then the
uniqueness would be handled by the existing code. Maybe you are doing
that already. I guess I should wait for the patch. :-)

Dan.


Re: [PATCH] Synonym support in Derby.

Posted by Satheesh Bandaram <sa...@Sourcery.Org>.
I almost submitted a patch using option 1, like I said I would. I have
added a SynonymAliasInfo to hold target of a synonym, which is
schemaName.tableName. I think this schemaName needs to be stored as a
name, instead of an ID so that the synonym stays valid even after
droping and recreating the target schema.

Yes, the namespace for SYNONYM is the same for tables and views. You
can't create a synonym if a table of that name already exists.

Satheesh

Daniel John Debrunner wrote:

>
>Any explanation of how SYNONYMs are implemented? You had indicated a
>couple of days ago you were undecided on how to represent them in system
>catalogs.
>
>Is the namespace for SYNONYM the same as for tables, or separate? If
>separate and A.B is both a table name and a synoymn name, which is selected?
>
>Dan.
>
>
>
>  
>