You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2011/12/09 18:46:50 UTC
svn commit: r1212541 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
testing/org/apache/derbyTesting/functionTests/tests/lang/HalfCreatedDatabaseTest.java
Author: kmarsden
Date: Fri Dec 9 17:46:50 2011
New Revision: 1212541
URL: http://svn.apache.org/viewvc?rev=1212541&view=rev
Log:
DERBY-5526 on upgrade from 10.5 to 10.8.2 , getting ERROR XBM0A: The database directory 'C:\cygwin\home\debugfat\clientdb' exists.
However, it does not contain the expected 'service.properties' file.
Change to only throw this message if there is a seg0 directory so this looks
like a partially created database
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/HalfCreatedDatabaseTest.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=1212541&r1=1212540&r2=1212541&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java Fri Dec 9 17:46:50 2011
@@ -804,8 +804,13 @@ final class StorageFactoryService implem
if ( !service_properties.exists() )
{
+ // DERBY-5526 Try to roughly determine if this was a partially created database by
+ // seeing if the seg0 directory exists.
+ StorageFile seg0 = storageFactory.newStorageFile("seg0");
+ if (seg0.exists()) {
throw StandardException.newException
( SQLState.SERVICE_PROPERTIES_MISSING, serviceName, PersistentService.PROPERTIES_NAME );
+ }
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/HalfCreatedDatabaseTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/HalfCreatedDatabaseTest.java?rev=1212541&r1=1212540&r2=1212541&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/HalfCreatedDatabaseTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/HalfCreatedDatabaseTest.java Fri Dec 9 17:46:50 2011
@@ -23,11 +23,14 @@ package org.apache.derbyTesting.function
import java.io.File;
import java.sql.SQLException;
+import javax.sql.DataSource;
+
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.derbyTesting.junit.BaseTestCase;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBCDataSource;
import org.apache.derbyTesting.junit.SecurityManagerSetup;
import org.apache.derbyTesting.junit.TestConfiguration;
import org.apache.derbyTesting.junit.JDBC;
@@ -149,6 +152,31 @@ public class HalfCreatedDatabaseTest ext
renamedProperties.renameTo( serviceProperties );
}
+ /**
+ * Verify that a user data dir (in this case empty) throws the old message
+ *
+ */
+ public void test_5526() throws SQLException {
+ String mydatadirStr = BaseTestCase.getSystemProperty("derby.system.home") +
+ File.separator + "mydatadir";
+ File mydatadir = new File(mydatadirStr);
+ assertTrue(mydatadir.mkdir());
+ DataSource ds = JDBCDataSource.getDataSource(mydatadirStr);
+ JDBCDataSource.setBeanProperty(ds, "createDatabase", "create");
+ try {
+ ds.getConnection();
+ fail("Should not be able to create database on existing directory " + mydatadirStr);
+ } catch (SQLException se) {
+ // should be nested exception XJ041 -> XBM0J (Directory exists)
+ assertSQLState("XJ041",se);
+ se = se.getNextException();
+ assertSQLState("XBM0J",se);
+ } finally {
+ BaseTestCase.removeDirectory(mydatadir);
+ }
+
+ }
+
}