db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1139449 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
Date Fri, 24 Jun 2011 21:44:16 GMT
Author: kmarsden
Date: Fri Jun 24 21:44:16 2011
New Revision: 1139449

URL: http://svn.apache.org/viewvc?rev=1139449&view=rev
Log:
DERBY-5289 Unable to boot 10.5.1.1 database - fails during soft/hard upgrade process for a
new version number while trying to drop jdbc metadata

Checking testcase for DERBY-5289. In trunk theDERBY-3870 fix contributed by Knut Anders Hatlen
fixed the issue so no code change is needed. Just the portion of DERBY-3870 that is relevant
to DERBY-5289 will be backported to the other branches.



Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java

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=1139449&r1=1139448&r2=1139449&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
Fri Jun 24 21:44:16 2011
@@ -1378,5 +1378,79 @@ public class BasicSetup extends UpgradeC
                     s.executeQuery("select * from d3870_t2"), "1");
         }
     }
+    
+    /**
+     * DERBY-5289 Upgrade could fail during upgrade with triggers due to 
+     * failure reading serializable or SQLData object
+     * @throws SQLException
+     */
+    public void testDERBY5289TriggerUpgradeFormat() throws SQLException {
+        // if the old version suffers from DERBY-4835 we 
+        // cannot run this test because the database won't boot
+        // on soft upgrade and none of the fixtures will run.
+        if (oldSuffersFromDerby4835())
+            return;
+        Statement s = createStatement();
+        switch (getPhase())
+        {
+            case PH_CREATE:
+                s.executeUpdate("CREATE TABLE D5289TABLE1 (COL1 VARCHAR(5))");
+                s.executeUpdate("CREATE TABLE D5289TABLE2 (COL2 VARCHAR(5))");
+                s.executeUpdate("CREATE TABLE D5289TABLE3 (COL3 VARCHAR(5))");
+                s.executeUpdate("CREATE TRIGGER D5289T1_UPDATED AFTER UPDATE " +
+                        "ON D5289TABLE1 REFERENCING OLD AS OLD NEW AS NEW FOR " +
+                        "EACH ROW MODE DB2SQL UPDATE D5289TABLE2 SET COL2 = NEW.COL1 WHERE
" +
+                        "COL2 = OLD.COL1");
+                s.executeUpdate("CREATE TRIGGER D5289T2_UPDATED AFTER UPDATE " + 
+                        "ON D5289TABLE2 REFERENCING NEW AS NEW FOR EACH " +
+                        "ROW MODE DB2SQL INSERT INTO D5289TABLE3(COL3) VALUES('ccc')");
+                s.executeUpdate("insert into D5289TABLE1(COL1) values ('aaa') ");
+                s.executeUpdate("insert into D5289TABLE2(COL2) values ('aaa') ");
+                s.executeUpdate("UPDATE D5289TABLE1 SET COL1 = 'bbb'");
+                assertDERBY5289ResultsAndDelete();
+                break;
+            case PH_SOFT_UPGRADE:   
+                s.executeUpdate("insert into D5289TABLE1(COL1) values ('aaa')");
+                s.executeUpdate("insert into D5289TABLE2(COL2) values ('aaa')");
+                s.executeUpdate("UPDATE D5289TABLE1 SET COL1 = 'bbb'");
+                assertDERBY5289ResultsAndDelete();                
+                break;
+            case PH_POST_SOFT_UPGRADE:
+                // If old version suffers from DERBY-5289, we can't run this part of the

+                // DERBY-5289 won't go in until 10.8.2.0
+                if (! oldLessThan(10,8,2,0)) {
+                    s.executeUpdate("insert into D5289TABLE1(COL1) values ('aaa')");
+                    s.executeUpdate("insert into D5289TABLE2(COL2) values ('aaa') ");
+                    s.executeUpdate("UPDATE D5289TABLE1 SET COL1 = 'bbb'");
+                    assertDERBY5289ResultsAndDelete();
+                }
+                break;
+            case PH_HARD_UPGRADE:
+                s.executeUpdate("insert into D5289TABLE1(COL1) values ('aaa')");
+                s.executeUpdate("insert into D5289TABLE2(COL2) values ('aaa') ");
+                s.executeUpdate("UPDATE D5289TABLE1 SET COL1 = 'bbb'");
+                assertDERBY5289ResultsAndDelete();
+                break;
+        }
+    }
 
+    /**
+     * Private helper method for fixture testDERBY5289TriggerUpgradeFormat
+     * to check and cleanup date in each phase.
+     * 
+     * @throws SQLException
+     */
+    private void assertDERBY5289ResultsAndDelete() throws SQLException {
+        Statement s = createStatement();
+        JDBC.assertFullResultSet(s.executeQuery("SELECT * FROM D5289TABLE1"), 
+                new String[][] {{"bbb"}});        
+        JDBC.assertFullResultSet(s.executeQuery("SELECT * FROM D5289TABLE2"),
+                new String[][] {{"bbb"}});
+        JDBC.assertFullResultSet(s.executeQuery("SELECT * FROM D5289TABLE3"), 
+                new String[][] {{"ccc"}});
+        s.executeUpdate("DELETE FROM D5289TABLE1");
+        s.executeUpdate("DELETE FROM D5289TABLE2");
+        s.executeUpdate("DELETE FROM D5289TABLE3");
+        commit();  
+    }
 }



Mime
View raw message