db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1501625 - in /db/derby/code/branches/10.8: ./ java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
Date Wed, 10 Jul 2013 01:09:55 GMT
Author: kmarsden
Date: Wed Jul 10 01:09:54 2013
New Revision: 1501625

URL: http://svn.apache.org/r1501625
Log:
DERBY-6189 NPE involving temporary table and rollback
Merge  1469802 from trunk to 10.8 branch


Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1469802,1469861
  Merged /db/derby/code/branches/10.10:r1493146

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=1501625&r1=1501624&r2=1501625&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Wed Jul 10 01:09:54 2013
@@ -953,6 +953,7 @@ public class GenericLanguageConnectionCo
                     // conglomerate associated with it
 
                     TableDescriptor td = tempTableInfo.getTableDescriptor();
+                    invalidateCleanupDroppedTable( td );
 
                     //remove the conglomerate created for this temp table
                     tran.dropConglomerate(td.getHeapConglomerateId()); 
@@ -1006,10 +1007,7 @@ public class GenericLanguageConnectionCo
                 tempTableInfo.setModifiedInSavepointLevel(-1);
                 TableDescriptor td = tempTableInfo.getTableDescriptor();
 
-                getDataDictionary().getDependencyManager().invalidateFor(
-                        td, DependencyManager.DROP_TABLE, this);
-
-                cleanupTempTableOnCommitOrRollback(td, true);
+                invalidateCleanupDroppedTable( td );
             } 
             // there is no else here because there is no special processing 
             // required for temp tables declares in earlier work of 
@@ -1017,7 +1015,17 @@ public class GenericLanguageConnectionCo
         }
     
         if (allDeclaredGlobalTempTables.size() == 0)
+        {
             allDeclaredGlobalTempTables = null;
+        }
+    }
+
+    /** Invalidate a dropped temp table */
+    private void    invalidateCleanupDroppedTable( TableDescriptor td )
+        throws StandardException
+    {
+        getDataDictionary().getDependencyManager().invalidateFor( td, DependencyManager.DROP_TABLE,
this );
+        cleanupTempTableOnCommitOrRollback( td, true );
     }
 
     /**

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java?rev=1501625&r1=1501624&r2=1501625&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
Wed Jul 10 01:09:54 2013
@@ -927,5 +927,26 @@ public class DeclareGlobalTempTableJavaJ
         JDBC.assertSingleValueResultSet(s.executeQuery(
                 "select count(*) from SESSION.tx") , "3");
         s.executeUpdate("drop table SESSION.tx");
-    }	
+    }
+
+    /**
+     * Test that we don't get an NPE when re-using a PreparedStatement
+     * on a temp table declared and then rolled back. See DERBY-6189.
+     */
+    public  void    test_derby_6189() throws Exception
+    {
+        Connection  conn = getConnection();
+
+        conn.prepareStatement
+            ( "DECLARE GLOBAL TEMPORARY TABLE SESSION.t6189( c21 int, c22 int) not logged
on commit preserve rows" )
+            .execute();        
+        PreparedStatement pStmtInsert = conn.prepareStatement( "insert into SESSION.t6189
values (23, 1)" );
+
+        pStmtInsert.execute();
+
+        conn.rollback();
+
+        assertStatementError("42X05", pStmtInsert); 
+    }
+    
 }



Mime
View raw message