db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1493146 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
Date Fri, 14 Jun 2013 16:26:05 GMT
Author: rhillegas
Date: Fri Jun 14 16:26:05 2013
New Revision: 1493146

URL: http://svn.apache.org/r1493146
Log:
DERBY-6189: Merge 1469802 and 1469861 from trunk to 10.10 branch.

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

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

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=1493146&r1=1493145&r2=1493146&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Fri Jun 14 16:26:05 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.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java?rev=1493146&r1=1493145&r2=1493146&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeclareGlobalTempTableJavaJDBC30Test.java
Fri Jun 14 16:26:05 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