db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1053724 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/types/ engine/org/apache/derby/impl/sql/ testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/
Date Wed, 29 Dec 2010 20:14:51 GMT
Author: kmarsden
Date: Wed Dec 29 20:14:51 2010
New Revision: 1053724

URL: http://svn.apache.org/viewvc?rev=1053724&view=rev
Log:
DERBY-4913 10.3 to 10.5 upgrade fails with ava.io.StreamCorruptedException: java.lang.ClassCastException:
org.apache.derby.catalog.types.OldRoutineType incompatible with org.apache.derby.iapi.types.DataTypeDescriptor


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java?rev=1053724&r1=1053723&r2=1053724&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java Wed
Dec 29 20:14:51 2010
@@ -322,7 +322,7 @@ public class RoutineAliasInfo extends Me
      * @param onDiskType The object read that represents the type.
      * @return A type descriptor.
      */
-    private static TypeDescriptor getStoredType(Object onDiskType)
+    public static TypeDescriptor getStoredType(Object onDiskType)
     {
         if (onDiskType instanceof OldRoutineType)
             return ((OldRoutineType) onDiskType).getCatalogType();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java?rev=1053724&r1=1053723&r2=1053724&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
Wed Dec 29 20:14:51 2010
@@ -21,6 +21,7 @@
 
 package org.apache.derby.impl.sql;
 
+import org.apache.derby.catalog.types.RoutineAliasInfo;
 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
@@ -220,7 +221,7 @@ public final class GenericColumnDescript
 		tableName = (String)fh.get("tableName");
 		schemaName = (String)fh.get("schemaName");
 		columnPos = fh.getInt("columnPos");
-		type = (DataTypeDescriptor)fh.get("type");
+		type = getStoredDataTypeDescriptor(fh.get("type"));
 		isAutoincrement = fh.getBoolean("isAutoincrement");
 		updatableByCursor = fh.getBoolean("updatableByCursor");
 	}
@@ -248,4 +249,27 @@ public final class GenericColumnDescript
 			return "";
 		}
 	}
+
+    /**
+     * When retrieving a DataTypeDescriptor, it might just be a regular
+     * DataTypeDescriptor or may be an OldRoutineType, as used for Routine
+     * parameters and return values prior to DERBY-2775. If it is not a regular
+     * DataTypeDescriptor, it must be an OldRoutineType, so convert it to a
+     * DataTypeDescriptor DERBY-4913
+     * 
+     * @param o
+     *            object as obtained by fh.get("type") in readExternal
+     * @return DataTypeDescriptor
+     */
+    private DataTypeDescriptor getStoredDataTypeDescriptor(Object o) {
+
+        if (o instanceof DataTypeDescriptor)
+            return (DataTypeDescriptor) o;
+        else
+            // Must be an OldRoutineType, so we will convert it to a
+            // DataTypeDescriptor for our purposes
+            return DataTypeDescriptor
+                    .getType(RoutineAliasInfo.getStoredType(o));
+    }
+
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java?rev=1053724&r1=1053723&r2=1053724&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
Wed Dec 29 20:14:51 2010
@@ -54,6 +54,10 @@ public class OldVersions
         {10, 7, 1, 1}, // 10.7.1.1 (December 14, 2010/ SVN 1040133)
     };
 
+    //Constant for special upgrade testing with both upgrade and create 
+    // set. We just test this with one version in the interest of time
+    // DERBY-4913
+    public static int VERSION_10_3_3_0_OFFSET = 7;
     /**
      * <p>
      * Get an array of versions supported by this platform.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java?rev=1053724&r1=1053723&r2=1053724&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
Wed Dec 29 20:14:51 2010
@@ -45,13 +45,17 @@ final class PhaseChanger extends BaseTes
     private ClassLoader loader;
     private ClassLoader previousLoader;
     private boolean trace = false;
+    private String upgradeAttributes="upgrade=true";
     
     public PhaseChanger(Test test, int phase,
-            ClassLoader loader, int[] version) {
+            ClassLoader loader, int[] version, boolean useCreateOnUpgrade) {
         super(test);
         this.phase = phase;
         this.loader = loader;
         this.version = version;
+        if (useCreateOnUpgrade) {
+            upgradeAttributes += ";create=true";
+        }
     }
     
     /**
@@ -99,7 +103,7 @@ final class PhaseChanger extends BaseTes
             
         case UpgradeChange.PH_HARD_UPGRADE:
             JDBCDataSource.setBeanProperty(ds, "connectionAttributes",
-                    "upgrade=true");
+                    upgradeAttributes);
             break;
         default:
             break;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=1053724&r1=1053723&r2=1053724&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Wed Dec 29 20:14:51 2010
@@ -77,7 +77,7 @@ class UpgradeRun extends UpgradeClassLoa
         new AdditionalDb("BUILTIN_10_6", false),
     };
     
-    public final static Test suite(final int[] version) {
+    public final static Test suite(final int[] version, boolean useCreateOnUpgrade) {
         
         ClassLoader oldLoader = makeClassLoader( version );
         
@@ -115,7 +115,7 @@ class UpgradeRun extends UpgradeClassLoa
                     + " Upgrade Phase: " + UpgradeChange.PHASES[phase] + " ",
                     phase, version);
             
-            Test phaseSet = new PhaseChanger(phaseTests, phase, loader, version);
+            Test phaseSet = new PhaseChanger(phaseTests, phase, loader, version, useCreateOnUpgrade);
             phaseSet = handleJavaSE6(phase, version, phaseSet);
             suite.addTest(phaseSet);
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java?rev=1053724&r1=1053723&r2=1053724&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
Wed Dec 29 20:14:51 2010
@@ -130,9 +130,15 @@ public class _Suite extends BaseTestCase
         old = OldVersions.getSupportedVersions();
         
         for (int i = 0; i < old.length; i++) {
-            suite.addTest(UpgradeRun.suite(old[i]));
+            // DERBY-4913. Test upgrade and create together for 10.3.3.0 since
+            // that combination seems to trigger a different code path.
+            if (i == OldVersions.VERSION_10_3_3_0_OFFSET)
+                suite.addTest(UpgradeRun.suite(old[i], true));
+            else
+                suite.addTest(UpgradeRun.suite(old[i], false));
         }
 
+        
         return suite;
     }
     



Mime
View raw message