db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1469802 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
Date Fri, 19 Apr 2013 12:11:47 GMT
Author: rhillegas
Date: Fri Apr 19 12:11:47 2013
New Revision: 1469802

URL: http://svn.apache.org/r1469802
Log:
DERBY-6189: Fix NPE involving rollback of temporary table.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=1469802&r1=1469801&r2=1469802&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Fri Apr 19 12:11:47 2013
@@ -951,6 +951,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()); 
@@ -1004,10 +1005,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 
@@ -1015,7 +1013,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/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java?rev=1469802&r1=1469801&r2=1469802&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
Fri Apr 19 12:11:47 2013
@@ -927,5 +927,33 @@ 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();
+
+        try {
+            pStmtInsert.execute();
+            fail( "Should fail!" );
+        }
+        catch ( SQLException se)
+        {
+            assertEquals( "42X05", se.getSQLState() );
+        }
+    }
+    
 }



Mime
View raw message