db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1517533 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/catalog/DD_Version.java testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
Date Mon, 26 Aug 2013 12:57:05 GMT
Author: kahatlen
Date: Mon Aug 26 12:57:04 2013
New Revision: 1517533

URL: http://svn.apache.org/r1517533
Log:
DERBY-6314: Upgrade from 10.10 fails with ClassCastException

Make sure stored plans for metadata queries are cleared the same
way as trigger plans during upgrade, so that upgrade doesn't fail
if the format of the old metadata plans cannot be read by the new
version.

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/BasicSetup.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?rev=1517533&r1=1517532&r2=1517533&view=diff
==============================================================================
--- 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 Mon
Aug 26 12:57:04 2013
@@ -530,6 +530,13 @@ public	class DD_Version implements	Forma
 		boolean isReadOnly = bootingDictionary.af.isReadOnly();
 
 		if (!isReadOnly) {
+            // Make sure all stored plans are cleared, both for triggers and
+            // for metadata queries. The plans will be recompiled automatically
+            // on the first execution after upgrade. We clear the plans because
+            // the stored format may have changed between the versions, so it
+            // might not be possible to read or execute them in this version.
+            bootingDictionary.clearSPSPlans();
+
 			// Once a database is version 10.5 we will start updating metadata SPSes
 			// on any version change,up or down.  This will ensure that metadata queries 
 			// match the version we are using.  We don't want to do this for lower 
@@ -537,10 +544,6 @@ public	class DD_Version implements	Forma
 			// SPSes won't be restored.
 			if (fromVersion.majorVersionNumber >= DataDictionary.DD_VERSION_DERBY_10_5)
 				bootingDictionary.updateMetadataSPSes(tc);
-			//Following make sure that the stored plans (including the ones for
-			//triggers) will get cleared during upgrade and hence we will not
-			//hold on to stale plans.
-			bootingDictionary.clearSPSPlans();
 
 			DD_Version lastRun;
 			

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java?rev=1517533&r1=1517532&r2=1517533&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
Mon Aug 26 12:57:04 2013
@@ -1948,4 +1948,15 @@ public class BasicSetup extends UpgradeC
         s.executeUpdate("DELETE FROM D5289TABLE3");
         commit();  
     }
+
+    /**
+     * Regression test case for DERBY-6314, which caused upgrade to fail if a
+     * metadata query had been executed with the old version of the database.
+     */
+    public void testDERBY6314() throws SQLException {
+        // Simply execute a metadata query. The query itself did not use to
+        // fail, but it caused PhaseChanger to fail when moving to the
+        // PH_SOFT_UPGRADE phase or the PH_HARD_UPGRADE phase.
+        JDBC.assertDrainResults(getConnection().getMetaData().getSchemas());
+    }
 }



Mime
View raw message