The files affected by this change are
M java\engine\org\apache\derby\impl\sql\GenericStatement.java
M java\engine\org\apache\derby\impl\sql\compile\FromList.java
M java\engine\org\apache\derby\impl\sql\GenericPreparedStatement.java
M java\testing\org\apache\derbyTesting\functionTests\tests\lang\declareGlobalTempTableJava.java
M java\testing\org\apache\derbyTesting\functionTests\master\declareGlobalTempTableJava.out
The changes for this fix are very localized, affecting only 3 files in Derby engine. 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.
