Java Doc for TempTableInfo.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » conn » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.sql.conn 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.derby.impl.sql.conn.TempTableInfo

TempTableInfo
class TempTableInfo (Code)
The temp tables will have following data structure TableDescriptor Declared in savepoint level Dropped in savepoint level Modified in savepoint level The actual logic LanguageConnectionContext will keep the "current savepoint level". At any point in time, this is the total number of savepoints defined for a transaction. At the start of any new transaction, the "current savepoint level" will be set to 0. Everytime a new user defined savepoint is set, store returns the total number of savepoints for the connection at that point. For eg, in a new transaction, "current savepoint level' will be 0. When the first savepoint is set, store will return 1 and "current savepoint level" will be set to 1. For next savepoint, store will return 2 and so on and so forth. When language calls rollback or release of a savepoint, store will again return the total number of savepoints for the connection after rollback or release and we will set "current savepoint level" to that number. For eg, start tran ("current savepoint level"=0) set savepoint 1 ("current savepoint level"=1) set savepoint 2 ("current savepoint level"=2) set savepoint 3 ("current savepoint level"=3) set savepoint 4 ("current savepoint level"=4) release savepoint 3 ("current savepoint level"=2) rollback savepoint 1 ("current savepoint level"=0) If the temporary table was declared with ON ROLLBACK DELETE ROWS and contents of that temporary table were modified in a transaction or within a savepoint unit, then we keep track of that by saving the savepoint level in dataModifiedInSavepointLevel. This information will be used at rollback of savepoint or transaction. Also, when a savepoint is released, we check if the table was modified in any of the savepoints that are getting released. If yes, then we put the current savepoint level as dataModifiedInSavepointLevel. eg start tran ("current savepoint level"=0) declare temp table 0 ON ROLLBACK DELETE ROWS("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) commit (temp table 0 ("declared in savepoint level"=-1, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1)) start tran ("current savepoint level = 0) temp table 0 ("declared in savepoint level"=-1, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) set savepoint 1("current savepoint level = 1") temp table 0 ("declared in savepoint level"=-1, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) set savepoint 2("current savepoint level = 2") delete 1 row from temp table 0 temp table 0 ("declared in savepoint level"=-1, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=2) release savepoint 2 ("current savepoint level"=1) and reset the modified in savepoint level as follows temp table 0 ("declared in savepoint level"=-1, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=1) rollback ("current savepoint level"=0) All the rows from the temp table 0 will be removed At the time of commit, we set dataModifiedInSavepointLevel to -1. At the time of rollback (transaction / savepoint), first we check if the table was modified in the unit of work getting rolled back. If yes, then we delete all the data from the temp table and we set dataModifiedInSavepointLevel to -1. When language calls release of a savepoint, store will again return the total number of savepoints in the system after release. We will go through all the temp tables and reset their declared or dropped or modified in savepoint level to the value returned by the release savepoint if those tables had their declared or dropped or modified in savepoint levels higher than what was returned by the release savepoint. eg start tran ("current savepoint level"=0) declare temp table 0 ("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) set savepoint 1("current savepoint level = 1") declare temp table 1 ("declared in savepoint level"=1, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) set savepoint 2("current savepoint level = 2") declare temp table 2 ("declared in savepoint level"=2, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) release savepoint 1 ("current savepoint level"=0) and reset the savepoint levels as follows temp table 1 ("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) temp table 2 ("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) set savepoint 3("current savepoint level = 1") rollback savepoint 3 ("current savepoint level"=0) and temp table info will look as follows temp table 0 ("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) temp table 1 ("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) temp table 2 ("declared in savepoint level"=0, "dropped in savepoint level"=-1, "dataModifiedInSavepointLevel"=-1) When you declare a temp table, it will have "declared in savepoint level" as the current savepoint level of the LanguageConnectionContext (which will be 0 in a transaction with no user-defined savepoints). The "dropped in savepoint level" for new temp tables will be set to -1. The "dataModifiedInSavepointLevel" for new temp tables will be set to -1 as well. When a temp table is dropped, we will first check if the table was declared in a savepoint level equal to the current savepoint level. If yes, then we will remove it from the temp tables list for the LanguageConnectionContext . eg start tran ("current savepoint level = 0") set savepoint 1("current savepoint level = 1") declare temp table 1 ("declared in savepoint level"=1, "dropped in savepoint level"=-1) drop temp table 1 (declared in savepoint level same as current savepoint level and hence will remove it from list of temp tables) If no, then we will set the dropped in savepoint level as the current savepoint level of the LanguageConnectionContext (which will be 0 in a transaction without savepoints and it also means that the table was declared in a previous transaction). At the time of commit, go through all the temp tables with "dropped in savepoint level" != -1 (meaning dropped in this transaction) and remove them from the temp tables list for the LanguageConnectionContext. All the rest of the temp tables with "dropped in savepoint level" = -1, we will set their "declared in savepoint level" to -1 and , "dataModifiedInSavepointLevel" to -1. eg start tran ("current savepoint level = 0) declare temp table t1("declared in savepoint level" = 0, "dropped in savepoint level"=-1) commit (temp table 1 ("declared in savepoint level"=-1, "dropped in savepoint level"=-1)) start tran ("current savepoint level = 0) drop temp table t1 ("declared in savepoint level" = -1, "dropped in savepoint level"=0) commit (temp table t1 will be removed from list of temp tables) At the time of rollback if rolling back transaction, first set the "current savepoint level" to 0 if rolling back to a savepoint, first set the "current savepoint level" to savepoint level returned by Store for the rollback to savepoint command Now go through all the temp tables. If "declared in savepoint level" of temp table is greater than or equal to "current savepoint level" (ie table was declared in this unit of work) And if table was not dropped in this unit of work ie "dropped in savepoint level" = -1 Then we should remove the table from the list of temp tables and drop the conglomerate created for it eg start tran ("current savepoint level = 0) declare temp table t2("declared in savepoint level" = 0, "dropped in savepoint level"=-1) rollback tran (temp table t2 will be removed from list of tables and conglomerate associated with it will be dropped) And if table was dropped in this unit of work ie "dropped in savepoint level" >= "current savepoint level" Then we should remove the table from the list of temp tables eg start tran ("current savepoint level = 0) set savepoint 1("current savepoint level = 1") declare temp table t2("declared in savepoint level" = 1, "dropped in savepoint level"=-1) set savepoint 2("current savepoint level = 2") drop temp table t1 ("declared in savepoint level" = 1, "dropped in savepoint level"=2) rollback savepoint 1 ("current savepoint level = 0) temp table t1 will be removed from the list of temp tables Else if the "dropped in savepoint level" of temp table is greate than or equal to "current savepoint level" it mean that table was dropped in this unit of work (and was declared in an earlier savepoint unit / transaction) and we will restore it as part of rollback ie replace the existing entry for this table in valid temp tables list with restored temp table. At the end of restoring, "declared in savepoint level" will remain unchanged and "dropped in savepoint level" will be -1. eg start tran ("current savepoint level = 0) declare temp table t1 with definition 1("declared in savepoint level" = 0, "dropped in savepoint level"=-1, definition 1(stored in table descriptor)) commit (temp table t1 "declared in savepoint level" = -1, "dropped in savepoint level"=-1) start tran ("current savepoint level = 0) set savepoint 1("current savepoint level = 1") drop temp table t1 ("declared in savepoint level" = -1, "dropped in savepoint level"=1, definition 1(stored in table descriptor)) declare temp table t1 with definition 2(say different than definition 1) ("declared in savepoint level" = -1, "dropped in savepoint level"=1, definition 1(stored in table descriptor)) , ("declared in savepoint level" = 1, "dropped in savepoint level"=-1, definition 2(stored in table descriptor)) set savepoint 2("current savepoint level = 2") drop temp table t1("declared in savepoint level" = -1, "dropped in savepoint level"=1, definition 1(stored in table descriptor)) , ("declared in savepoint level" = 1, "dropped in savepoint level"=2, definition 2(stored in table descriptor)) rollback tran (Remove : temp table t1("declared in savepoint level" = 1, "dropped in savepoint level"=2, definition 2(stored in table descriptor) (Restore : temp table t1"declared in savepoint level" = -1, "dropped in savepoint level"=-1, definition 1(stored in table descriptor)) Else if the "dataModifiedInSavepointLevel" of temp table is greate than or equal to "current savepoint level" it means that table was declared in an earlier savepoint unit / transaction and was modified in the current UOW. And hence we will delete all the data from it.



Constructor Summary
 TempTableInfo(TableDescriptor td, int declaredInSavepointLevel)
    

Method Summary
 intgetDeclaredInSavepointLevel()
    
 intgetDroppedInSavepointLevel()
    
 intgetModifiedInSavepointLevel()
    
 TableDescriptorgetTableDescriptor()
    
 booleanmatches(String tableName)
    
 voidsetDeclaredInSavepointLevel(int declaredInSavepointLevel)
    
public  voidsetDroppedInSavepointLevel(int droppededInSavepointLevel)
    
 voidsetModifiedInSavepointLevel(int dataModifiedInSavepointLevel)
    
 voidsetTableDescriptor(TableDescriptor td)
     Set the table descriptor.


Constructor Detail
TempTableInfo
TempTableInfo(TableDescriptor td, int declaredInSavepointLevel)(Code)




Method Detail
getDeclaredInSavepointLevel
int getDeclaredInSavepointLevel()(Code)
Return the savepoint level when the table was declared



getDroppedInSavepointLevel
int getDroppedInSavepointLevel()(Code)
Return the savepoint level when the table was dropped



getModifiedInSavepointLevel
int getModifiedInSavepointLevel()(Code)
Return the savepoint level when the table was last modified



getTableDescriptor
TableDescriptor getTableDescriptor()(Code)
Return the table descriptor



matches
boolean matches(String tableName)(Code)
Matches by name and only temp tables that have not been dropped (that's when droppededInSavepointLevel will be -1)



setDeclaredInSavepointLevel
void setDeclaredInSavepointLevel(int declaredInSavepointLevel)(Code)
Set the savepoint level when the table was declared



setDroppedInSavepointLevel
public void setDroppedInSavepointLevel(int droppededInSavepointLevel)(Code)
Return the savepoint level when the table was dropped



setModifiedInSavepointLevel
void setModifiedInSavepointLevel(int dataModifiedInSavepointLevel)(Code)
Set the savepoint level when the table was last modified



setTableDescriptor
void setTableDescriptor(TableDescriptor td)(Code)
Set the table descriptor. Will be called while temporary is being restored



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.