db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1055682 - in /db/derby/code/branches/10.6: ./ 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:07:42 GMT
Author: kmarsden
Date: Wed Jan  5 23:07:41 2011
New Revision: 1055682

URL: http://svn.apache.org/viewvc?rev=1055682&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.6/   (props changed)
    db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
    db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan  5 23:07:41 2011
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,962716,963206,963705,964115,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033864,1038514,1040658
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,962716,963206,963705,964115,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033864,1038514,1040658,1053724,1055169
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java?rev=1055682&r1=1055681&r2=1055682&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
Wed Jan  5 23:07:41 2011
@@ -288,7 +288,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.6/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java?rev=1055682&r1=1055681&r2=1055682&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
Wed Jan  5 23:07:41 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.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java?rev=1055682&r1=1055681&r2=1055682&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/OldVersions.java
Wed Jan  5 23:07:41 2011
@@ -51,6 +51,10 @@ public class OldVersions
         {10, 5, 3, 0}, // 10.5.3.0 (August 21, 2009 / SVN 802917)
     };
 
+    //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.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java?rev=1055682&r1=1055681&r2=1055682&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
Wed Jan  5 23:07:41 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.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=1055682&r1=1055681&r2=1055682&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Wed Jan  5 23:07:41 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.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java?rev=1055682&r1=1055681&r2=1055682&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
Wed Jan  5 23:07:41 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