db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r472613 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
Date Wed, 08 Nov 2006 19:49:14 GMT
Author: djd
Date: Wed Nov  8 11:49:13 2006
New Revision: 472613

URL: http://svn.apache.org/viewvc?view=rev&rev=472613
Log:
DERBY-2048 Add an additional cleanup step(compression) to cleanDatabase() method.
After objects removal is performed via removeObjects(), object compression is performed in
the
new compressObjects() method on the SYS.SYSDEPENDS to compact the system table.
(Currently it only compress this system table.)

Contributed by Yip Ng yipng168@gmail.com

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java?view=diff&rev=472613&r1=472612&r2=472613
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
Wed Nov  8 11:49:13 2006
@@ -109,7 +109,7 @@
      public static void cleanDatabase(Connection conn) throws SQLException {
          clearProperties(conn);
          removeObjects(conn);
-
+         compressObjects(conn);
      }
      
      /**
@@ -186,4 +186,35 @@
         throw sqle;
     }
 
+     /**
+      * Set of objects that will be compressed as part of cleaning a database.
+      */
+     private static final String[] COMPRESS_DB_OBJECTS =
+     {
+         "SYS.SYSDEPENDS",
+     };
+     
+     /**
+      * Compress the objects in the database.
+      * 
+      * @param conn the db connection
+      * @throws SQLException database error
+      */
+     private static void compressObjects(Connection conn) throws SQLException {
+    	 
+    	 CallableStatement cs = conn.prepareCall
+    	     ("CALL SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE(?, ?, 1, 1, 1)");
+    	 
+    	 for (int i = 0; i < COMPRESS_DB_OBJECTS.length; i++)
+    	 {
+    		 int delim = COMPRESS_DB_OBJECTS[i].indexOf(".");
+             cs.setString(1, COMPRESS_DB_OBJECTS[i].substring(0, delim) );
+             cs.setString(2, COMPRESS_DB_OBJECTS[i].substring(delim+1) );
+             cs.execute();
+    	 }
+    	 
+    	 cs.close();
+    	 conn.commit();
+     }
+    	   
 }



Mime
View raw message