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 su...@apache.org on 2007/03/24 19:12:06 UTC
svn commit: r522077 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/catalog/DD_Version.java
testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_3.java
Author: suresht
Date: Sat Mar 24 11:12:06 2007
New Revision: 522077
URL: http://svn.apache.org/viewvc?view=rev&rev=522077
Log:
DERBY-378 (partial)
This patch adds code required to enable new system procedures added to
support import/export of lob data on hard upgrade from versions before
10.3. Added a new test case to the 10.3 upgrade test cases.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_3.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java?view=diff&rev=522077&r1=522076&r2=522077
==============================================================================
--- 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 Sat Mar 24 11:12:06 2007
@@ -393,7 +393,15 @@
// Grant PUBLIC access to some system routines
bootingDictionary.grantPublicAccessToSystemRoutines(tc, aid);
}
-
+
+ if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_2)
+ {
+ // On ugrade from versions before 10.3, create system procedures
+ // added in 10.3.
+ bootingDictionary.create_10_3_system_procedures(
+ tc,
+ bootingDictionary.getSystemUtilSchemaDescriptor().getUUID());
+ }
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_3.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_3.java?view=diff&rev=522077&r1=522076&r2=522077
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_3.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_3.java Sat Mar 24 11:12:06 2007
@@ -29,6 +29,9 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.SupportFilesSetup;
+import org.apache.derbyTesting.junit.JDBC;
+
/**
* Upgrade test cases for changes made in 10.3.
@@ -44,8 +47,7 @@
TestSuite suite = new TestSuite("Upgrade changes for 10.3");
suite.addTestSuite(Changes10_3.class);
-
- return suite;
+ return new SupportFilesSetup((Test) suite);
}
public Changes10_3(String name) {
@@ -177,4 +179,73 @@
commit();
}
+
+
+
+ /**
+ * Simple test to ensure new import/export procedures added in 10.3
+ * are working on hard upgrade to 10.3 from previous derby versions.
+ */
+ public void testImportExportLobsProcedures()
+ throws SQLException
+ {
+
+ switch(getPhase()) {
+ case PH_CREATE: {
+ Statement s = createStatement();
+ s.execute("create table iet1(id int , content clob , pic blob)");
+ s.executeUpdate("insert into iet1 values " +
+ "(1, 'SQL Tips', cast(X'4231a2' as blob))");
+ s.close();
+ commit();
+ break;
+ }
+ case PH_SOFT_UPGRADE: {
+ // new import export procedure should not be found
+ // on soft-upgrade.
+ Statement s = createStatement();
+ assertStatementError("42Y03", s,
+ "call SYSCS_UTIL.SYSCS_EXPORT_TABLE_LOBS_IN_EXTFILE" +
+ "(null , 'IET1' , 'iet1.del' , null, " +
+ "null, null, 'iet1_lobs.dat')");
+ s.close();
+ break;
+ }
+ case PH_POST_SOFT_UPGRADE:
+ break;
+ case PH_HARD_UPGRADE: {
+ // main file used to perform import/export.
+ String fileName =
+ (SupportFilesSetup.getReadWrite("iet1.del")).getPath();
+ // external file name used to store lobs.
+ String lobsFileName =
+ (SupportFilesSetup.getReadWrite("iet1_lobs.dat")).getPath();
+
+ Statement s = createStatement();
+ s.execute(
+ "call SYSCS_UTIL.SYSCS_EXPORT_TABLE_LOBS_IN_EXTFILE" +
+ "(null , 'IET1' , '" + fileName +
+ "' , null, null, null, '" + lobsFileName + "')");
+ s.execute("call SYSCS_UTIL.SYSCS_IMPORT_TABLE_LOBS_IN_EXTFILE(" +
+ "null, 'IET1' , '" + fileName +
+ "', null, null, null, 0)");
+ s.execute("call SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_IN_EXTFILE(" +
+ "'select * from IET1', '" + fileName +
+ "' , null, null, null, '" + lobsFileName + "')");
+ s.execute("call SYSCS_UTIL.SYSCS_IMPORT_DATA_LOBS_IN_EXTFILE(" +
+ "null, 'IET1','ID, CONTENT, PIC', '1,2,3'," +
+ "'" + fileName +"', null, null, null, 1)") ;
+
+ // verify table has correct data after performing import/export.
+ ResultSet rs = s.executeQuery("select * from iet1");
+ JDBC.assertFullResultSet(rs, new String[][]
+ {{"1", "SQL Tips", "4231a2"},
+ {"1", "SQL Tips", "4231a2"}});
+ s.close();
+ break;
+ }
+
+ }
+ }
+
}