db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r354898 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/ engine/org/apache/derby/database/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/iapi/store/access/ engine/org/apache/derby/iapi/store/raw/ engine/org...
Date Wed, 07 Dec 2005 23:22:13 GMT
Author: mikem
Date: Wed Dec  7 15:22:01 2005
New Revision: 354898

URL: http://svn.apache.org/viewcvs?rev=354898&view=rev
Log:
committing onlinebackup_4.diff for DERBY-239.

committing on behalf of Suresh Thalamati.

This patch makes online backup call to wait/fail when unlogged operations like
create index are pending. It also fixes derby-523 bug my making the existing
log archive backup procedure to wait for the unlogged operation to complete. 

-- Two new procedures are added to allow the users to make backup wait/fail
when unlogged operations are pending. 
-- prevents users starting backup in an non-idle transactions to avoid backup
blocking forever if users starts backup in the same transaction as an
unlogged operation. 
-- backup is not really transactional , to avoid any locking issues in the
futures; backup procedures ends the transaction by implicitly doing commit
when it is successful or rollback on any errors. 

A new backup test is added to store suite to test the above scenarios. 


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/trunk/java/engine/org/apache/derby/database/Database.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/st_1.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/copyfiles.ant
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1.sql
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java Wed Dec  7 15:22:01 2005
@@ -46,7 +46,6 @@
 import org.apache.derby.iapi.util.IdUtil;
 import org.apache.derby.iapi.error.PublicAPI;
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
 
 
@@ -684,30 +683,234 @@
         Factory.getDatabaseOfConnection().checkpoint();
     }
 
-    public static void SYSCS_BACKUP_DATABASE(
-    String  backupDir)
+    /**
+     * Backup the database to a backup directory. By default this 
+     * procedure will wait for the backup blocking unlogged operations to
+     * complete before starting the backup.  
+     *
+     * Examples of unlogged operations include: create index and bulk insert.
+     * Note that once the backup begins these operations will not block, 
+     * instead they will automatically procede and be logged.
+     * 
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if it 
+     *                  does not exist.
+     * @exception StandardException thrown on error
+     */
+    public static void SYSCS_BACKUP_DATABASE(String  backupDir)
 		throws SQLException
     {
-        Factory.getDatabaseOfConnection().backup(backupDir);
+		backupDatabase(backupDir , true);
+    }
+
+    /**
+     * Backup the database to a backup directory.
+     *
+     * Backup the database to a backup directory. Use the "wait" parameter
+     * to determine if the operation should block waiting for the backup 
+     * blocking unlogged operations to complete before starting the backup.  
+     *
+     * Examples of unlogged operations include: create index and bulk insert.
+     * Note that once the backup begins these operations will not block, 
+     * instead they will automatically procede and be logged.
+     * 
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if it 
+     *                  does not exist.
+     * @param wait if <tt>non-zero</tt>, waits for  all the backup blocking 
+     *             operation in progress to finish.
+     * @exception StandardException thrown on error
+     */
+    public static void SYSCS_ONLINE_BACKUP_DATABASE(
+    String  backupDir, 
+    int     wait)
+        throws SQLException
+    {
+        backupDatabase(backupDir, (wait != 0));
+    }
+
+
+    /**
+     * Backup the database to a backup directory.
+     *
+     * Backup the database to a backup directory. Use the "wait" parameter
+     * to determine if the operation should block waiting for the backup 
+     * blocking unlogged operations to complete before starting the backup.  
+     *
+     * Examples of unlogged operations include: create index and bulk insert.
+     * Note that once the backup begins these operations will not block, 
+     * instead they will automatically procede and be logged.
+     * 
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if it 
+     *                  does not exist.
+     * @param wait if <tt>true</tt>, waits for  all the backup blocking 
+     *             operation in progress to finish.
+     * @exception StandardException thrown on error
+     */
+    private static void backupDatabase(
+    String  backupDir, 
+    boolean wait)
+        throws SQLException
+    {
+        checkBackupTransactionIsIdle();
+        Connection conn = getDefaultConn();
+        try {
+            Factory.getDatabaseOfConnection().backup(backupDir, wait);
+        }catch(SQLException se)
+        {
+            // issue a rollback on any errors
+            conn.rollback();
+            throw  se;
+        }
+        // finished successfully, commit it.
+        conn.commit();	
     }
 
+    /**
+     * Backup the database to a backup directory and enable the log archive
+     * mode that will keep the archived log files required for roll-forward
+     * from this version of the backup. By default this procedure will wait 
+     * for the backup blocking unlogged operations to complete before starting 
+     * the backup.  
+     *
+     * Examples of unlogged operations include: create index and bulk insert.
+     * Note that once the backup begins these operations will not block, 
+     * instead they will automatically procede and be logged.
+     *
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if not it 
+     *                  does not exist.   
+     * @param deleteOnlineArchivedLogFiles  If <tt>non-zero</tt> deletes online 
+     *                 archived log files that exist before this backup, delete 
+     *                 will occur  only after the backup is  complete.
+     * @exception StandardException thrown on error.
+     */
     public static void SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
     String  backupDir,
     int     deleteOnlineArchivedLogFiles)
 		throws SQLException
     {
-        Factory.getDatabaseOfConnection().backupAndEnableLogArchiveMode(
+        backupDatabaseAndEnableLogArchiveMode(
             backupDir, 
-            (deleteOnlineArchivedLogFiles != 0));
+            (deleteOnlineArchivedLogFiles != 0),
+            true);
+	}
+
+    /**
+     * Backup the database to a backup directory and enable the log archive
+	 * mode that will keep the archived log files required for roll-forward
+	 * from this version backup.
+     *
+     * Examples of unlogged operations include: create index and bulk insert.
+     * Note that once the backup begins these operations will not block, 
+     * instead they will automatically procede and be logged.
+     *
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if not it 
+     *                  does not exist.   
+     *
+     * @param deleteOnlineArchivedLogFiles  If <tt>non-zero</tt> deletes online 
+     *                  archived log files that exist before this backup, delete     *                  will occur  only after the backup is  complete.
+     *
+     * @param wait      if <tt>non-zero</tt>, waits for  all the backup blocking     *                  operations in progress to finish.
+     * @exception StandardException thrown on error.
+     */
+    public static void SYSCS_ONLINE_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
+    String  backupDir,
+    int     deleteOnlineArchivedLogFiles,
+	int     wait)
+		throws SQLException
+    {
+        backupDatabaseAndEnableLogArchiveMode(
+            backupDir,
+            (deleteOnlineArchivedLogFiles != 0),
+            (wait != 0));
+	}
+
+
+    /**
+     * Backup the database to a backup directory and enable the log archive
+	 * mode that will keep the archived log files required for roll-forward
+	 * from this version of the backup.
+     *
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if not it 
+     *                  does not exist.   
+     * @param deleteOnlineArchivedLogFiles  If <tt>true</tt> deletes online 
+     *                  archived log files that exist before this backup, delete     *                  will occur  only after the backup is  complete.
+	 * @param wait      if <tt>true</tt>, waits for  all the backup blocking 
+	 *                  operations in progress to finish.
+     * @exception StandardException thrown on error.
+     */
+    private static void backupDatabaseAndEnableLogArchiveMode(
+    String  backupDir,
+    boolean deleteOnlineArchivedLogFiles,
+	boolean wait)
+		throws SQLException
+    {
+		checkBackupTransactionIsIdle();
+		Connection conn = getDefaultConn();
+		try {
+            Factory.getDatabaseOfConnection().backupAndEnableLogArchiveMode(
+                backupDir, 
+                deleteOnlineArchivedLogFiles,
+                wait);
+		}catch(SQLException se)
+		{
+            // issue a rollback on any errors
+            conn.rollback();
+            throw  se;
+        }
+        // finished successfully, commit it.
+        conn.commit();
     }
 
+
+    /**
+	 * Disables the log archival process, i.e No old log files
+	 * will be kept around for a roll-forward recovery.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If <tt>non-zero</tt> deletes all the
+	 *        online archived log files that exist before this call immediately.
+     *
+	 * @exception StandardException Thrown on error
+	 */
+
     public static void SYSCS_DISABLE_LOG_ARCHIVE_MODE(
     int     deleteOnlineArchivedLogFiles)
 		throws SQLException
     {
-        Factory.getDatabaseOfConnection().disableLogArchiveMode(
-            (deleteOnlineArchivedLogFiles != 0));
+		checkBackupTransactionIsIdle();
+		Connection conn = getDefaultConn();
+		try { 
+			Factory.getDatabaseOfConnection().disableLogArchiveMode(
+                (deleteOnlineArchivedLogFiles != 0));
+		}catch(SQLException se)
+		{
+			// issue a rollback on any errors
+			conn.rollback();
+			throw  se;
+		}
+		// finished successfully, commit it.
+		conn.commit();
     }
+
+
+    /**
+     * Check if the transnaction is idle ? , Backup related operation are 
+     * allowed only in a new transaction.
+     */
+    private static void checkBackupTransactionIsIdle() throws SQLException 
+    {
+        if (!(ConnectionUtil.getCurrentLCC().getTransactionExecute().isIdle())) 
+        {
+            throw PublicAPI.wrapStandardException(
+                    StandardException.newException(
+                    SQLState.BACKUP_OPERATIONS_NOT_ALLOWED_IN_ACTIVE_XACT));								  
+		}
+	}
+
 
     public static void SYSCS_SET_RUNTIMESTATISTICS(
     int     enable)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/database/Database.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/database/Database.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/database/Database.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/database/Database.java Wed Dec  7 15:22:01 2005
@@ -72,19 +72,21 @@
 	public void dropAllJDBCMetaDataSPSes()
 		throws SQLException;
 
-	/**
-	 * Backup the database to a backup directory.  See on line documentation
-	 * for more detail about how to use this feature.
-	 *
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 *
-	 * @exception SQLException Thrown on error
-	 */
-	public void backup(String backupDir) throws SQLException;
+    /**
+     * Backup the database to a backup directory.  See online documentation
+     * for more detail about how to use this feature.
+     *
+     * @param backupDir the directory name where the database backup should
+     *         go.  This directory will be created if not it does not exist.
+     * @param wait if <tt>true</tt>, waits for  all the backup blocking 
+     *             operations in progress to finish.
+     * @exception SQLException Thrown on error
+     */
+    public void backup(String backupDir, boolean wait) 
+        throws SQLException;
 
 	/**
-	 * Backup the database to a backup directory.  See on line documentation
+	 * Backup the database to a backup directory.  See online documentation
 	 * for more detail about how to use this feature.
 	 *
 	 * @param backupDir the directory where the database backup should
@@ -96,38 +98,58 @@
 
 
 
-	/**
-	 * Backup the database to a backup directory and enable the log archive
-	 * mode that will keep the archived log files required for roll-forward
-	 * from this version backup.
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log files
-	 * that exist before this backup; otherwise they will not be deleted. 
-	 * Deletion will occur only after backup is complete.
-	 * @exception SQLException Thrown on error
-	 */
-
-	public void backupAndEnableLogArchiveMode(String backupDir,
-											  boolean
-											  deleteOnlineArchivedLogFiles) 
-		throws SQLException;
+    /**
+     * Backup the database to a backup directory and enable the log archive
+     * mode that will keep the archived log files required for roll-forward
+     * from this version backup.
+     *
+     * @param backupDir                     The directory name where the 
+     *                                      database backup should go.  This 
+     *                                      directory will be created if it 
+     *                                      does not exist.
+     *
+     * @param deleteOnlineArchivedLogFiles  If true deletes online archived log
+     *                                      files that exist before this backup;
+     *                                      otherwise they will not be deleted. 
+     *
+     *                                      Deletion will occur only after 
+     *                                      backup is complete.
+     *
+     * @param wait                          if <tt>true</tt>, waits for all 
+     *                                      the backup blocking operations in 
+     *                                      progress to finish.
+     *
+     * @exception SQLException Thrown on error
+     */
+    public void backupAndEnableLogArchiveMode(
+    String  backupDir,
+    boolean deleteOnlineArchivedLogFiles,
+    boolean wait) 
+        throws SQLException;
 
 
 	/**
 	 * Backup the database to a backup directory and enable the log archive
 	 * mode that will keep the archived log files required for roll-forward
 	 * from this version backup.
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log files
-	 * that exist before this backup; otherwise they will not be deleted. 
-	 * Deletion will occur only after backup is complete.
+     *
+	 * @param backupDir                     The directory name where the 
+     *                                      database backup should go.  This 
+     *                                      directory will be created if it does
+     *                                      not exist.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log
+     *                                      files that exist before this backup;
+     *                                      otherwise they will not be deleted. 
+     *
+	 *                                      Deletion will occur only after 
+     *                                      backup is complete.
+     *
 	 * @exception SQLException Thrown on error
 	 */
-	public void backupAndEnableLogArchiveMode(File backupDir, 
-											  boolean
-											  deleteOnlineArchivedLogFiles) 
+	public void backupAndEnableLogArchiveMode(
+    File    backupDir, 
+    boolean deleteOnlineArchivedLogFiles) 
 		throws SQLException;
 	
 
@@ -135,8 +157,12 @@
 	 * Disables the log archival process, i.e No old log files
 	 * will be kept around for a roll-forward recovery. Only restore that can 
 	 * be performed after disabling log archive mode is version recovery.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes all online archived log files
-	 * that exist before this call immediately; otherwise they will not be deleted.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes all online archived
+     *                                      log files that exist before this 
+     *                                      call immediately; otherwise they 
+     *                                      will not be deleted.
+     *
 	 * @exception SQLException Thrown on error
 	 */
 	public void disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles) 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java Wed Dec  7 15:22:01 2005
@@ -351,6 +351,9 @@
     String RAWSTORE_UNEXPECTED_EXCEPTION                        = "XSRS7.S";
     String RAWSTORE_CANNOT_CHANGE_LOGDEVICE                     = "XSRS8.S";
     String RAWSTORE_RECORD_VANISHED                             = "XSRS9.S";
+    String BACKUP_BLOCKING_OPERATIONS_IN_PROGRESS               = "XSRSA.S";
+    String BACKUP_OPERATIONS_NOT_ALLOWED_IN_ACTIVE_XACT         = "XSRSB.S";
+    
 
 	/*
 	** RawStore - Log.Generic statement exceptions

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactory.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactory.java Wed Dec  7 15:22:01 2005
@@ -230,15 +230,18 @@
 	public void unfreeze() throws StandardException;
 
 	/**
-	  * Backup the database to backupDir.  
-	  * <P>Please see cloudscape on line documentation on backup and restore.
-	  *
-	  * @param backupDir the name of the directory where the backup should be
-	  *		stored.
-	  *
-	  * @exception StandardException Thrown on error
-	  */
-	public void backup(String backupDir) throws StandardException;
+     * Backup the database to backupDir.  
+     * <P>Please see cloudscape on line documentation on backup and restore.
+     *
+     * @param backupDir the name of the directory where the backup should be
+     *		             stored.
+     * @param wait      if <tt>true</tt>, waits for  all the backup blocking 
+     *                  operations in progress to finish.
+     *
+     * @exception StandardException Thrown on error
+     */
+    public void backup(String backupDir, boolean wait) 
+        throws StandardException;
 
 	/**
 	  * Backup the database to backupDir.  
@@ -251,41 +254,64 @@
 	public void backup(File backupDir) throws StandardException;
 	
 	/**
-	 * Backup the database to a backup directory and enable the log archive
-	 * mode that will keep the archived log files required for roll-forward
-	 * from this version backup.
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log files
-	 * that exist before this backup, delete will occur only after backup is complete.
+     * Backup the database to a backup directory and enable the log archive
+     * mode that will keep the archived log files required for roll-forward
+     * from this version backup.
+     *
+     * @param backupDir                     the directory name where the 
+     *                                      database backup should go.  This 
+     *                                      directory will be created if not it
+     *                                      does not exist.
+     *
+     * @param deleteOnlineArchivedLogFiles  If true deletes online archived log
+     *                                      files that exist before this backup,
+     *                                      delete will occur only after backup
+     *                                      is complete.
+     *
+     * @param wait                          if <tt>true</tt>, waits for all the
+     *                                      backup blocking operations in 
+     *                                      progress to finish.
+     *
 	 * @exception StandardException Thrown on error
 	 */
-	public void backupAndEnableLogArchiveMode(String backupDir, 
-											  boolean	
-											  deleteOnlineArchivedLogFiles) 	
-		throws StandardException ;
+    public void backupAndEnableLogArchiveMode(
+    String  backupDir, 
+    boolean deleteOnlineArchivedLogFiles,
+    boolean wait) 	
+		throws StandardException;
 	
 	/**
 	 * Backup the database to a backup directory and enable the log archive
 	 * mode that will keep the archived log files required for roll-forward
 	 * from this version backup.
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log files
-	 * that exist before this backup, delete will occur only after backup is complete.
+     *
+	 * @param backupDir                     the directory name where the 
+     *                                      database backup should go.  This 
+     *                                      directory will be created if not it
+     *                                      does not exist.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log
+     *                                      files that exist before this backup,
+     *                                      delete will occur only after backup
+     *                                      is complete.
+     *
 	 * @exception StandardException Thrown on error
 	 */
-	public void backupAndEnableLogArchiveMode(File backupDir, 
-											  boolean
-											  deleteOnlineArchivedLogFiles) 
+	public void backupAndEnableLogArchiveMode(
+    File    backupDir, 
+    boolean deleteOnlineArchivedLogFiles) 
 		throws StandardException;
 
 	/**
 	 * disables the log archival process, i.e No old log files
 	 * will be kept around for a roll-forward recovery.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes all online archived log files
-	 * that exist before this call immediately; Only restore that can be performed
-	 * after disabling log archive mode is version recovery.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes all online archived
+     *                                      log files that exist before this 
+     *                                      call immediately; Only restore that
+     *                                      can be performed after disabling log
+     *                                      archive mode is version recovery.
+     *
 	 * @exception StandardException Thrown on error
 	 */
 	public void disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java Wed Dec  7 15:22:01 2005
@@ -647,11 +647,15 @@
 	  * <P>Please see cloudscape on line documentation on backup and restore.
 	  *
 	  * @param backupDir the name of the directory where the backup should be
-	  *		stored.
-	  *
-	  * @exception StandardException Thrown on error
+      *                  stored.
+      * @param wait      if <tt>true</tt>, waits for  all the backup blocking 
+      *                  operations in progress to finish.
+      * 
+      * @exception StandardException Thrown on error
 	  */
-	public void backup(String backupDir) throws StandardException;
+    public void backup(
+    String backupDir, 
+    boolean wait) throws StandardException;
 
 	/**
 	  * Backup the database to backupDir.  
@@ -669,38 +673,60 @@
 	 * Backup the database to a backup directory and enable the log archive
 	 * mode that will keep the archived log files required for roll-forward
 	 * from this version backup.
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log files
-	 * that exist before this backup, delete will occur only after backup is complete.
-	 * @exception StandardException Thrown on error
+     *
+	 * @param backupDir                     the directory name where the 
+     *                                      database backup should go.  This 
+     *                                      directory will be created if not it
+     *                                      does not exist.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log
+     *                                      files that exist before this backup,
+     *                                      delete will occur only after backup
+     *                                      is complete.
+     *
+     * @param wait if <tt>true</tt>, waits for  all the backup blocking 
+	 *             operations in progress to finish.
+     *
+     * @exception StandardException Thrown on error
 	 */
-	public void backupAndEnableLogArchiveMode(String backupDir, 
-											  boolean
-											  deleteOnlineArchivedLogFiles) 
+    public void backupAndEnableLogArchiveMode(
+    String  backupDir, 
+    boolean deleteOnlineArchivedLogFiles,
+    boolean wait) 
 		throws StandardException;
 		
 	/**
 	 * Backup the database to a backup directory and enable the log archive
 	 * mode that will keep the archived log files required for roll-forward
 	 * from this version backup.
-	 * @param backupDir the directory name where the database backup should
-	 *   go.  This directory will be created if not it does not exist.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log files
-	 * that exist before this backup, delete will occur only after backup is complete.
+	 * @param backupDir                     the directory name where the 
+     *                                      database backup should go.  This 
+     *                                      directory will be created if not it 
+     *                                      does not exist.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes online archived log
+     *                                      files that exist before this backup,
+     *                                      delete will occur only after backup
+     *                                      is complete.
+     *
 	 * @exception StandardException Thrown on error
 	 */
-	public void backupAndEnableLogArchiveMode(File backupDir, 
-											  boolean
-											  deleteOnlineArchivedLogFiles) 
+	public void backupAndEnableLogArchiveMode(
+    File    backupDir, 
+    boolean deleteOnlineArchivedLogFiles) 
 		throws StandardException;
 	
 	/**
 	 * disables the log archival process, i.e No old log files
 	 * will be kept around for a roll-forward recovery.
-	 * @param deleteOnlineArchivedLogFiles  If true deletes all online archived log files
-	 * that exist before this call immediately; Only restore that can be performed
-	 * after disabling log archive mode is version recovery.
+     *
+	 * @param deleteOnlineArchivedLogFiles  If true deletes all online archived
+     *                                      log files that exist before this 
+     *                                      call immediately; Only restore that
+     *                                      can be performed after disabling 
+     *                                      log archive mode is version 
+     *                                      recovery.
+     *
 	 * @exception StandardException Thrown on error
 	 */
 	public void disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java Wed Dec  7 15:22:01 2005
@@ -328,16 +328,16 @@
 	}
 
 
-	public void backup(String backupDir) throws SQLException
-	{
+    public void backup(String backupDir, boolean wait) 
+        throws SQLException
+    {
 		try {
-			af.backup(backupDir);
+			af.backup(backupDir, wait);
 		} catch (StandardException se) {
 			throw PublicAPI.wrapStandardException(se);
 		}
 	}
 
-
 	public void backup(File backupDir) throws SQLException
 	{
 		try {
@@ -349,13 +349,16 @@
 
 
 
-	public void backupAndEnableLogArchiveMode(String backupDir, 
-											  boolean
-											  deleteOnlineArchivedLogFiles)
-		throws SQLException
+    public void backupAndEnableLogArchiveMode(
+    String  backupDir, 
+    boolean deleteOnlineArchivedLogFiles,
+    boolean wait)
+        throws SQLException
 	{
 		try {
-			af.backupAndEnableLogArchiveMode(backupDir, deleteOnlineArchivedLogFiles);
+			af.backupAndEnableLogArchiveMode(backupDir, 
+                                             deleteOnlineArchivedLogFiles,
+                                             wait); 
 		} catch (StandardException se) {
 			throw PublicAPI.wrapStandardException(se);
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java Wed Dec  7 15:22:01 2005
@@ -337,6 +337,16 @@
                 tc, 
                 bootingDictionary.getSystemUtilSchemaDescriptor().getUUID());
         }
+
+        if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_1)
+        {
+            // On ugrade from versions before 10.2, create system procedures
+            // added in 10.2.
+            bootingDictionary.create_10_2_system_procedures(
+                tc, 
+                bootingDictionary.getSystemUtilSchemaDescriptor().getUUID());
+        }
+        
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Wed Dec  7 15:22:01 2005
@@ -8880,6 +8880,8 @@
 
         // add 10.1 specific system procedures
         create_10_1_system_procedures(tc, sysUtilUUID);
+        // add 10.2 specific system procedures
+        create_10_2_system_procedures(tc, sysUtilUUID);
     }
 
     /**
@@ -9411,6 +9413,88 @@
                 (TypeDescriptor) null,
                 tc);
         }
+    }
+
+    
+    /**
+     * Create system procedures added in version 10.2.
+     * <p>
+     * Create 10.2 system procedures, called by either code creating new
+     * database, or code doing hard upgrade from previous version.
+     * <p>
+     *
+     * @param sysUtilUUID   uuid of the SYSUTIL schema.
+     *
+     * @exception  StandardException  Standard exception policy.
+     **/
+    void create_10_2_system_procedures(
+    TransactionController   tc,
+    UUID                    sysUtilUUID)
+		throws StandardException
+    {
+
+        // void SYSCS_UTIL.SYSCS_ONLINE_BACKUP_DATABASE(
+        //     IN BACKUPDIR        VARCHAR(Limits.DB2_VARCHAR_MAXWIDTH),
+        //     IN WAIT             SMALLINT
+        //     )
+        
+        {
+            // procedure argument names
+            String[] arg_names = {"BACKUPDIR", "WAIT"};
+
+            // procedure argument types
+            TypeDescriptor[] arg_types = {
+                DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                    Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH),
+                DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                    Types.SMALLINT)
+            };
+
+            createSystemProcedureOrFunction(
+                "SYSCS_ONLINE_BACKUP_DATABASE",
+                sysUtilUUID,
+                arg_names,
+                arg_types,
+                0,
+                0,
+                RoutineAliasInfo.MODIFIES_SQL_DATA,
+                (TypeDescriptor) null,
+                tc);
+        }
+
+        // void 
+        // SYSCS_UTIL.SYSCS_ONLINE_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
+        //   IN BACKUPDIR                 VARCHAR(Limits.DB2_VARCHAR_MAXWIDTH),
+        //   IN DELETE_ARCHIVED_LOG_FILES SMALLINT,
+        //   IN WAIT                      SMALLINT
+        //   )
+        {
+            // procedure argument names
+            String[] arg_names = 
+                {"BACKUPDIR", "DELETE_ARCHIVED_LOG_FILES", "WAIT"};
+
+            // procedure argument types
+            TypeDescriptor[] arg_types = {
+                DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                    Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH),
+                DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                    Types.SMALLINT),
+                DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                    Types.SMALLINT)
+            };
+
+            createSystemProcedureOrFunction(
+                "SYSCS_ONLINE_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE",
+                sysUtilUUID,
+                arg_names,
+                arg_types,
+                0,
+                0,
+                RoutineAliasInfo.MODIFIES_SQL_DATA,
+                (TypeDescriptor) null,
+                tc);
+        }
+
     }
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java Wed Dec  7 15:22:01 2005
@@ -926,9 +926,12 @@
 		rawstore.unfreeze();
 	}
 
-	public void backup(String backupDir) throws StandardException
+    public void backup(
+    String  backupDir, 
+    boolean wait) 
+        throws StandardException
 	{
-		rawstore.backup(backupDir);
+		rawstore.backup(backupDir, wait);
 	}
 
 	public void backup(File backupDir) throws StandardException
@@ -937,18 +940,24 @@
 	}
 
 
-	public void backupAndEnableLogArchiveMode(String backupDir, 
-											  boolean deleteOnlineArchivedLogFiles)
+    public void backupAndEnableLogArchiveMode(
+    String  backupDir, 
+    boolean deleteOnlineArchivedLogFiles,
+    boolean wait)
 		throws StandardException 
 	{
-		rawstore.backupAndEnableLogArchiveMode(backupDir, deleteOnlineArchivedLogFiles);
+		rawstore.backupAndEnableLogArchiveMode(backupDir, 
+                                               deleteOnlineArchivedLogFiles, 
+                                               wait);
 	}
 
-	public void backupAndEnableLogArchiveMode(File backupDir, 
-											  boolean deleteOnlineArchivedLogFiles) 
+	public void backupAndEnableLogArchiveMode(
+    File    backupDir, 
+    boolean deleteOnlineArchivedLogFiles) 
 		throws StandardException
 	{
-		rawstore.backupAndEnableLogArchiveMode(backupDir, deleteOnlineArchivedLogFiles);
+		rawstore.backupAndEnableLogArchiveMode(
+            backupDir, deleteOnlineArchivedLogFiles);
 	}	
 
 	public void disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java Wed Dec  7 15:22:01 2005
@@ -460,8 +460,19 @@
 		dataFactory.unfreezePersistentStore();
 	}
 
-	public void backup(String backupDir) throws StandardException
-	{
+    /**
+     * Backup the database to a backup directory.
+     * 
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if it 
+     *                  does not exist.
+     * @param wait if <tt>true</tt>, waits for  all the backup blocking 
+     *             operations in progress to finish.
+     * @exception StandardException thrown on error
+     */
+    public void backup(String backupDir, boolean wait) 
+        throws StandardException 
+    {
 		if (backupDir == null || backupDir.equals(""))
         {
 			throw StandardException.newException(
@@ -487,13 +498,21 @@
                 AccessFactoryGlobals.USER_TRANS_NAME);
 
 		try {
-			canStartOnlineBackup(t, true);
-			backup(t, new File(backupDir));
-		}finally {
-			// let the xactfatory know that backup is done, so that
-			// it can allow backup blocking operations. 
-			xactFactory.backupFinished();
-		}
+            // check if there any backup blocking operations are in progress
+            // and stop new ones from starting until the backup is completed.
+            if (!xactFactory.stopBackupBlockingOperations(wait))
+            {
+                throw StandardException.newException(
+                      SQLState.BACKUP_BLOCKING_OPERATIONS_IN_PROGRESS);  
+            }
+
+            // perform backup
+            backup(t, new File(backupDir));
+        }finally {
+            // let the xactfatory know that backup is done, so that
+            // it can allow backup blocking operations. 
+            xactFactory.backupFinished();
+        }
 	}
 
 
@@ -505,15 +524,18 @@
 	/*
 	 * Backup the database.
 	 * Online backup copies all the database files (log, seg0  ...Etc) to the
-	 * specified backup location  without blocking any user operation for the 
-	 * whole duration of the backup. Stable copy is made using  using page level
-	 * latches 	and in some cases with the help monitors.  Transaction 
-	 * log is also backed up, this will help in bringing the databse to the
-	 * consistent state on restore.
+	 * specified backup location without blocking any user operation for the 
+	 * duration of the backup. Stable copy is made of each page using using 
+     * page level latches and in some cases with the help of monitors.  
+     * Transaction log is also backed up, this is used to bring the database to 
+     * the consistent state on restore.
 	 * 
 	 * TODO : make sure no parallel backup/disabling log archive mode occurs.
 	 */
-	public synchronized void backup(Transaction t, File backupDir) throws StandardException
+	public synchronized void backup(
+    Transaction t, 
+    File        backupDir) 
+        throws StandardException
 	{
         if (!privExists(backupDir))
 		{
@@ -523,7 +545,6 @@
                     SQLState.RAWSTORE_CANNOT_CREATE_BACKUP_DIRECTORY,
                     (File) backupDir);
             }
-
 		}
 		else
 		{
@@ -765,20 +786,58 @@
 
 	}
 
-
-	public void backupAndEnableLogArchiveMode(String backupDir,boolean
-											  deleteOnlineArchivedLogFiles) 
+    /**
+     * Backup the database to a backup directory and enable the log archive
+	 * mode that will keep the archived log files required for roll-forward
+	 * from this version backup.
+     *
+     * @param backupDir the name of the directory where the backup should be
+     *                  stored. This directory will be created if it 
+     *                  does not exist.   
+     *
+     * @param deleteOnlineArchivedLogFiles  
+     *                  If true deletes online archived 
+     *                  log files that exist before this backup, delete 
+     *                  will occur  only after the backup is  complete.
+     *
+     * @param wait      if <tt>true</tt>, waits for  all the backup blocking 
+     *                  operations in progress to finish.
+     *
+     * @exception StandardException thrown on error.
+     */
+    public void backupAndEnableLogArchiveMode(
+    String backupDir,
+    boolean deleteOnlineArchivedLogFiles,
+    boolean wait) 
 		throws StandardException
 	{
-		logFactory.enableLogArchiveMode();
-		backup(backupDir);
-		//After successful backup delete the archived log files
-		//that are not necessary to do a roll-forward recovery
-		//from this backup if requested.
-		if(deleteOnlineArchivedLogFiles)
-		{
-			logFactory.deleteOnlineArchivedLogFiles();
-		}
+        boolean enabledLogArchive = false;
+        boolean error = true;
+        try {
+            // Enable the log archive mode, if it is not already enabled.
+            if(!logFactory.logArchived()) {
+                logFactory.enableLogArchiveMode();
+                enabledLogArchive = true ;
+            }
+
+            backup(backupDir, wait);
+            
+            // After successful backup delete the archived log files
+            // that are not necessary to do a roll-forward recovery
+            // from this backup if requested.
+            if (deleteOnlineArchivedLogFiles)
+            {
+                logFactory.deleteOnlineArchivedLogFiles();
+            }
+            error = false;
+        } finally {
+            // On any errors , disable the log archive, if it 
+            // is enabled on this call. 
+            if(error) {
+                if (enabledLogArchive)
+                logFactory.disableLogArchiveMode();
+            }
+        }
 	}
 
 
@@ -808,36 +867,6 @@
 		}
 	}
 
-
-	/**
-	 * Checks if the online backup can be started.
-     *
-	 * A Consistent backup can not  be made if there are any backup 
-	 * blocking operations (like unlogged operations) are in progress. 
-	 * Backup is allowed only in brand new transaction to avoid issues
-	 * like users starting a backup in the same transaction that has 
-	 * pending unlogged operations. 
-	 * 
-	 * @param wait if <tt>true</tt>, waits for  all the backup blocking 
-	 *             operation in progress to finish.
-	 * @return     <tt>true</tt> if an online backup can be made.
-	 *			   <tt>false</tt> otherwise.
-	 * @exception StandardException if the transaction that is used  
-	 *                              to start the backup is not idle.
-	 */
-	private boolean canStartOnlineBackup(Transaction t, boolean wait) 
-		throws StandardException {
-		
-		// check if the transaction is in the idle state
-		if(!t.isIdle()) {
-			// online backup can only be started in an IDLE transaction.
-			// TODO : add the exception here. 
-		}
-		
-		// check if there any backup blocking operations are in progress
-		// and stop new ones from starting until the backup is completed.
-		return xactFactory.stopBackupBlockingOperations(wait); 
-	}
 	
 	//copies the files from the backup that does not need
 	//any special handling like jars.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java Wed Dec  7 15:22:01 2005
@@ -1065,12 +1065,16 @@
 				if (backupBlockingOperations == 0)
 					inBackup = true;
 			}
+            
 		}
 
-		if (SanityManager.DEBUG)
-			SanityManager.ASSERT(backupBlockingOperations == 0 && 
-								 inBackup == true,
-								 "store is not in correct state for backup");
+        if (SanityManager.DEBUG) {
+            if (inBackup) {
+                SanityManager.ASSERT(backupBlockingOperations == 0 ,
+                                 "store is not in correct state for backup");
+            }
+        }
+
 		return inBackup;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Wed Dec  7 15:22:01 2005
@@ -183,7 +183,8 @@
 XSRS7.S=Backup caught unexpected exception.
 XSRS8.S=Log Device can only be set during database creation time, it cannot be changed on the fly.
 XSRS9.S=Record {0} no longer exists
-
+XSRSA.S=Cannot backup the database when backup blocking unlogged operations are pending. Please commit the transactions with backup blocking operations or use the backup procedure with option to wait for them to complete. 
+XSRSB.S=Backup operation can not be performed in an active transaction. Please use a new transaction to execute backup procedures.
 
 # java/com/ibm/db2j/impl/Database/Storage/RawStore/Log/Generic
 # statement errors.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/st_1.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/st_1.out?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/st_1.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/st_1.out Wed Dec  7 15:22:01 2005
@@ -18,6 +18,7 @@
 0 rows inserted/updated/deleted
 ij> call SYSCS_SET_DATABASE_PROPERTY('foo', 'bar');
 0 rows inserted/updated/deleted
+ij> commit;
 ij> call SYSCS_BACKUP_DATABASE('extinout/mybackup');
 0 rows inserted/updated/deleted
 ij> call SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE('extinout/mybackup2', 0);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall Wed Dec  7 15:22:01 2005
@@ -30,3 +30,4 @@
 store/TestDurabilityProperty.java
 store/OnlineCompressTest.java
 store/OnlineBackupTest1.java
+store/onlineBackupTest2.sql

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/copyfiles.ant?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/copyfiles.ant (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/copyfiles.ant Wed Dec  7 15:22:01 2005
@@ -142,3 +142,5 @@
 MaxLogNumberRecovery_app.properties
 MaxLogNumberRecovery_derby.properties
 OnlineBackupTest1_app.properties
+onlineBackupTest2.sql
+onlineBackupTest2_app.properties

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1.sql?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1.sql Wed Dec  7 15:22:01 2005
@@ -15,6 +15,7 @@
 call SYSCS_UNFREEZE_DATABASE();
 call SYSCS_CHECKPOINT_DATABASE();
 call SYSCS_SET_DATABASE_PROPERTY('foo', 'bar');
+commit;
 call SYSCS_BACKUP_DATABASE('extinout/mybackup');
 call SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE('extinout/mybackup2', 0);
 call SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE('extinout/mybackup2', 1);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java?rev=354898&r1=354897&r2=354898&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java Wed Dec  7 15:22:01 2005
@@ -66,6 +66,81 @@
 							    " To: " + dst.getAbsolutePath());
 		}
 	}
+
+
+    /**
+     * Check if a file exists ?
+     *
+     * @param name the file's name.
+     * @return     <tt>"true"</tt> if the given file exists 
+     *             <tt>"false"</tt> otherwise.
+     * @exception Exception if any exception occurs 
+     */
+    public static String fileExists(String fileName) throws Exception
+    {
+        File fl = new File(fileName);
+        if(fl.exists()) {
+            return "true";
+        }else {
+            return "false";
+        }
+    }
+
+
+    /**
+     *	Remove a directory and all of its contents.
+     *   
+     *  @param name the file's name.
+     * @return     <tt>true</tt> if the omplete directory was removed
+     *             <tt>false</tt> otherwise.f false is returned then some of 
+     *              the files in the directory may have been removed.
+     */
+
+	private static boolean removeDirectory(File directory) {
+
+		if (directory == null)
+			return false;
+		if (!directory.exists())
+			return true;
+		if (!directory.isDirectory())
+			return false;
+
+		String[] list = directory.list();
+
+		if (list != null) {
+			for (int i = 0; i < list.length; i++) {
+				File entry = new File(directory, list[i]);
+
+				if (entry.isDirectory())
+				{
+					if (!removeDirectory(entry))
+						return false;
+				}
+				else
+				{
+					if (!entry.delete())
+						return false;
+				}
+			}
+		}
+
+		return directory.delete();
+	}
+
+    /**
+     *	Remove a directory and all of its contents.
+     *   
+     *  @param name the file's name.
+     * @return     <tt>"true"</tt> if the omplete directory was removed
+     *             <tt>"false"</tt> otherwise.f false is returned then some of 
+     *              the files in the directory may have been removed.
+     */
+
+	public static String removeDirectory(String directory)
+	{
+	    return (removeDirectory(new File(directory)) ? "true" : "false");
+	}
+    
 }
 
 



Mime
View raw message