db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1055681 - in /db/derby/code/branches/10.7: ./ java/engine/org/apache/derby/catalog/types/ java/engine/org/apache/derby/impl/sql/ java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/
Date Wed, 05 Jan 2011 23:05:15 GMT
Author: kmarsden
Date: Wed Jan  5 23:05:14 2011
New Revision: 1055681

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

merge revisions #1053724 and #1055169 from trunk


Modified:
    db/derby/code/branches/10.7/   (props changed)
    db/derby/code/branches/10.7/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
    db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java

Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan  5 23:05:14 2011
@@ -1 +1 @@
-/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026
+/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169

Modified: db/derby/code/branches/10.7/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java?rev=1055681&r1=1055680&r2=1055681&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
(original)
+++ db/derby/code/branches/10.7/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
Wed Jan  5 23:05:14 2011
@@ -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/branches/10.7/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java?rev=1055681&r1=1055680&r2=1055681&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
(original)
+++ db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
Wed Jan  5 23:05:14 2011
@@ -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/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java?rev=1055681&r1=1055680&r2=1055681&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
(original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
Wed Jan  5 23:05:14 2011
@@ -53,6 +53,10 @@ public class OldVersions
         {10, 6, 2, 1}, // 10.6.2.1 (Oct 6, 2010/ SVN 999685
     };
 
+    //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=  new int[] {10,3,3,0};
     /**
      * <p>
      * Get an array of versions supported by this platform.

Modified: db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java?rev=1055681&r1=1055680&r2=1055681&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
(original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
Wed Jan  5 23:05:14 2011
@@ -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";
+        }
     }
     
     /**
@@ -75,6 +79,9 @@ final class PhaseChanger extends BaseTes
                     + "." +  ((int[]) UpgradeChange.oldVersion.get())[3];
             BaseTestCase.traceit("Test upgrade from: " + versStr + ", phase: " 
                     + UpgradeChange.PHASES[phase]);
+            if (UpgradeChange.PHASES[phase].equals("UPGRADE")) {
+                BaseTestCase.traceit("Upgrade attributes = " + upgradeAttributes);
+            }
         }
         
         if (loader != null) {
@@ -99,7 +106,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/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=1055681&r1=1055680&r2=1055681&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Wed Jan  5 23:05:14 2011
@@ -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/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java?rev=1055681&r1=1055680&r2=1055681&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
(original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
Wed Jan  5 23:05:14 2011
@@ -20,6 +20,8 @@ limitations under the License.
 */
 package org.apache.derbyTesting.functionTests.tests.upgradeTests;
 
+import java.util.Arrays;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -130,9 +132,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 (Arrays.equals(old[i],OldVersions.VERSION_10_3_3_0))
+                suite.addTest(UpgradeRun.suite(old[i], true));
+            else
+                suite.addTest(UpgradeRun.suite(old[i], false));
         }
 
+        
         return suite;
     }
     



Mime
View raw message