Issue Details (XML | Word | Printable)

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

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

Queryplan for a query using SESSION schema view is incorrectly put in statement cache. This could cause incorrect plan getting executed later if a temp. table is created with that name.

Created: 01/Jul/05 08:44 AM   Updated: 20/Mar/07 09:54 PM
Return to search
Component/s: SQL
Affects Version/s: 10.1.1.0, 10.2.1.6
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works Derby424SessionSchemaCaching.txt 2005-10-19 02:12 PM Mamta A. Satoor 12 kB
Environment: generic

Resolution Date: 23/Oct/05 03:26 AM


 Description  « Hide
See DERBY-405 for some discussion related this issue. I suspect this is because of statement caching. Derby doesn'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


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #326959 Thu Oct 20 17:52:35 UTC 2005 bandaram DERBY-424: Basically, the problem is that, during the compile phase of views,
the reference to the view gets replaced by the view definition, which causes
us to loose the information that the view might have belonged in SESSION schema.
In order to fix this, during the bind phase in FromList, before the view gets
replaced by its definition, I find out if the view is from SESSION schema, If
yes, then I save this information in FromList and this gets used by FromList
when it is asked if it has any items referencing SESSION schema objects. This
information is again lost during the optimization and generate phase and hence
I moved the check for SESSION schema reference to right after the bind phase in
GenericStatement. If there is a reference to SESSION schema object,
GenericStatement will remove the statement from the cache.

Submitted by Mamta Satoor (msatoor@gmail.com)
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/declareGlobalTempTableJava.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java

Repository Revision Date User Message
ASF #326969 Thu Oct 20 18:38:48 UTC 2005 bandaram DERBY-424: Ported from TRUNK.

Basically, the problem is that, during the compile phase of views,
the reference to the view gets replaced by the view definition, which causes
us to loose the information that the view might have belonged in SESSION schema.
In order to fix this, during the bind phase in FromList, before the view gets
replaced by its definition, I find out if the view is from SESSION schema, If
yes, then I save this information in FromList and this gets used by FromList
when it is asked if it has any items referencing SESSION schema objects. This
information is again lost during the optimization and generate phase and hence
I moved the check for SESSION schema reference to right after the bind phase in
GenericStatement. If there is a reference to SESSION schema object,
GenericStatement will remove the statement from the cache.

Submitted by Mamta Satoor (msatoor@gmail.com)
Files Changed
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out
MODIFY /db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/FromList.java
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/declareGlobalTempTableJava.java
MODIFY /db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
MODIFY /db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/GenericStatement.java