db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r744169 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
Date Fri, 13 Feb 2009 16:38:01 GMT
Author: kmarsden
Date: Fri Feb 13 16:38:01 2009
New Revision: 744169

URL: http://svn.apache.org/viewvc?rev=744169&view=rev
Log:
DERBY-4057  Add disabled test case (xtestReclamationOnRollback() )  for the 
issue that space is not reclaimed on rollback.This does not fix the issue


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java?rev=744169&r1=744168&r2=744169&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
Fri Feb 13 16:38:01 2009
@@ -54,9 +54,10 @@
     }
 
     /**
-     * Two threads simultaneously updating a table. Thread 1 updates row 1 with
-     * a long value (>32K) Thread 2 updates row with a short clob ("hello");
-     * NUMALLOCATEDPAGES should be only 3 after each does 500 updates
+     * Two threads simultaneously updating a table. Threads each
+     * update a separate row with a long value (>32K). NUMALLOCATED
+     * pages should not grow past expected value after 500 updates
+     * by each thread.
      * 
      * @param lockTable true if we should get an exclusive lock on the table
      * before update
@@ -94,15 +95,28 @@
         for (int i = 0; i < NUM_THREADS; i++) {
             threads[i].join();
         }
+        checkNumAllocatedPages("CLOBTAB",expectedNumAllocated);
+    }
 
-        Statement s = createStatement();
+    /**
+     * Check that table has specified number of allocated pages.
+     * 
+     * @param table
+     * @param expectedAlloc
+     * @throws SQLException
+     */
+    private void checkNumAllocatedPages(String table, int expectedAlloc) throws SQLException
{        
         // Check the space table 
         // Should not have grown.
-        ResultSet rs = s.executeQuery("SELECT NUMALLOCATEDPAGES FROM "
-                + " new org.apache.derby.diag.SpaceTable('APP','CLOBTAB') t"
-                + " WHERE CONGLOMERATENAME = 'CLOBTAB'");
+
+        PreparedStatement ps = prepareStatement("SELECT NUMALLOCATEDPAGES FROM "
+                + " new org.apache.derby.diag.SpaceTable('APP',?) t"
+                + " WHERE CONGLOMERATENAME = ?");
+        ps.setString(1,table);
+        ps.setString(2, table);
+        ResultSet rs = ps.executeQuery();
         JDBC.assertFullResultSet(rs, new String[][] { { ""
-                + expectedNumAllocated } });
+                + expectedAlloc } });
     }
 
     private static void fiveHundredUpdates(Connection conn,
@@ -153,6 +167,25 @@
         testMultiThreadedUpdate(false /*don't lock table */, true /* update single row */
);
     }
     
+    /**
+     * Make sure we reclaim space on rollback. Cannot enable this test 
+     * until DERBY-4057 is fixed.
+     * 
+     * @throws SQLException
+     */
+    public void xtestReclamationOnRollback() throws SQLException {
+        setAutoCommit(false);
+        String insertString = Formatters.repeatChar("a", 33000);
+        PreparedStatement ps = prepareStatement("INSERT INTO CLOBTAB2 VALUES(?,?)");
+        for (int i = 0; i < 500; i++) {            
+            ps.setInt(1, i);
+            ps.setString(2, insertString);   
+            ps.executeUpdate();
+            rollback();
+        }
+        checkNumAllocatedPages("CLOBTAB2",1);
+    }
+    
     public static Test suite() {
 
         Properties sysProps = new Properties();
@@ -176,6 +209,7 @@
                     ps.setString(2, insertString);
                     ps.executeUpdate();
                 }
+                s.executeUpdate("CREATE TABLE CLOBTAB2 (I INT, C CLOB)");               

             }
 
         };



Mime
View raw message