Issue Details (XML | Word | Printable)

Key: DERBY-405
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Satheesh Bandaram
Reporter: Mamta A. Satoor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

SYNONYM should not be allowed in SESSION schema because that can confusion wih temporary tables

Created: 30/Jun/05 05:42 AM   Updated: 13/Apr/06 11:25 PM
Return to search
Component/s: SQL
Affects Version/s: 10.2.1.6
Fix Version/s: 10.1.1.0, 10.1.3.1, 10.2.1.6

Time Tracking:
Not Specified

Resolution Date: 13/Apr/06 11:24 PM


 Description  « Hide
A user should not be able to create a synonym in SESSION schema eg
create synonym session.st1 for app.t1;
select * from session.st1; -- refers to app.t1
declare global temporary table st1(c11 int, c12 int) on commit preserve rows not logged;
select * from session.st1; -- refers to app.t1, is that right?

I think the last select * from session.st1 should goto temporary table st1 since any references to objects in SESSION schema should first find a match against a temporary table if one by that name exists.

We already discourage users from defining objects other than temporary table in SESSION schema in the reference manual "Using SESSION as the schema name of a physical table will not cause an error, but is discouraged. The SESSION schema name should be reserved for the temporary table schema." But, IMHO, it will be nice to enforce this wherever possible in Derby code rather than leaving it upto the users to avoid confusion.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mamta A. Satoor added a comment - 30/Jun/05 03:18 PM
Forgot to mention earlier, but if we decide to fix this issue then it will have documentation impact and we would need to mention in docs that synonyms can't live in SESSION schema.

Satheesh Bandaram added a comment - 01/Jul/05 02:15 AM
The behavior here is same as with views. Suspect this is because of statement caching. We don't seem to recognise we have a temporary table that just overloaded an existing physical table.

It would have been good to avoid permanent tables/views/synonyms in SESSION schema. Not sure what we should do now about this, though.

ij> create view session.st1 as select * from t;
0 rows inserted/updated/deleted
ij> select * from session.st1;
I |J |K
-----------------------------------
1 |1 |NULL
2 |2 |NULL
3 |3 |NULL
4 |4 |NULL

4 rows selected
ij> select * from t;
I |J |K
-----------------------------------
1 |1 |NULL
2 |2 |NULL
3 |3 |NULL
4 |4 |NULL

4 rows selected
ij> declare global temporary table st1(c11 int, c12 int) on commit preserve rows
 not logged;
0 rows inserted/updated/deleted
ij> select * from session.st1;
I |J |K
-----------------------------------
1 |1 |NULL
2 |2 |NULL
3 |3 |NULL
4 |4 |NULL

4 rows selected
ij> select * from session.st1; <==== This statement has an extra space between FROM and session.st1
C11 |C12
-----------------------

0 rows selected

Daniel John Debrunner added a comment - 01/Jul/05 02:29 AM
Well, SYNONYM's haven't been released yet, thus we could disallow SYNONYMs in SESSION schema, before 10.1 goes GA.
Tables & views existed before the temportary SESSION schema was added, that's why they are allowed. Existing applications could have been using the SESSION schema.

Mamta A. Satoor added a comment - 01/Jul/05 02:40 AM
I agree with Dan's response but I think we have a bug here with statement caching. If I recall correctly, I think the goal was to not cache any statements referencing SESSION schema objects to cover an example scenario like Satheesh's script above. But looks like in the example Satheesh gave, select * from session.st1 is getting cached and that is why it does not detect that session.st1 needs to be mapped to temporary table when it is executed the 2nd time in the example.

Satheesh Bandaram added a comment - 01/Jul/05 03:06 AM
Dan's suggestion is good... We should disable synonyms in SESSION schema. I will submit a patch soon.

I will also file another bug to cover the statement caching issue.

Satheesh Bandaram added a comment - 01/Jul/05 08:45 AM
Fix has been merged into trunk. This may get ported to 10.1, if Andrew, the release czar, decides this is important for 10.1 release.

Satheesh Bandaram added a comment - 01/Jul/05 08:46 AM
Jeff, can you alter CREATE SYNONYM section to say creating synonyms in SESSION schema is not allowed?

Kathey Marsden added a comment - 13/Apr/06 11:24 PM
Fixed in 10.1 with revision 208776 - "In preparation for the 10.1 release, roll up fixes from trunk."

Kathey Marsden added a comment - 13/Apr/06 11:25 PM
reclosing after setting fixin