db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1130632 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
Date Thu, 02 Jun 2011 16:23:33 GMT
Author: kmarsden
Date: Thu Jun  2 16:23:32 2011
New Revision: 1130632

URL: http://svn.apache.org/viewvc?rev=1130632&view=rev
Log:
DERBY-5249 A table created with 10.0.2.1 with constraints cannot be dropped with 10.5 due
to NullPointerException with insane build or ASSERT FAILED Failed to find sharable conglomerate
descriptor for index conglomerate with sane build

Add a test for this issue. The test xtestDropTableAfterUpgradeWithConstraint()
is not currently enabled because the issue is not yet fixed. 
Remove the x to enable the test once the issue is fixed.


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=1130632&r1=1130631&r2=1130632&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
Thu Jun  2 16:23:32 2011
@@ -1,6 +1,6 @@
 /*
 
-Derby - Class org.apache.derbyTesting.functionTests.tests.upgradeTests.BasicSetup
+Derby - Class org.apache.dertbyTesting.functionTests.tests.upgradeTests.BasicSetup
 
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
@@ -29,6 +29,7 @@ import java.sql.Statement;
 import org.apache.derby.iapi.services.io.DerbyIOException;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.junit.Utilities;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -259,5 +260,57 @@ public class BasicSetup extends UpgradeC
                 }
             break;
         }
+    }  
+ 
+    
+    /**
+     * DERBY-5249 table created with primary and foreign key can't be dropped
+     * Test currently disabled. Remove the x from the name to enable the 
+     * test once the bug is fixed.
+     * 
+     */
+    public void xtestDropTableAfterUpgradeWithConstraint() throws SQLException {
+        final int phase = getPhase();
+
+        Statement s = createStatement();
+
+        switch (phase) {
+        case PH_CREATE:
+            s.executeUpdate("CREATE SCHEMA S");
+            s.executeUpdate("CREATE TABLE S.RS (R_TYPE_ID VARCHAR(64) "
+                    + "NOT NULL)");
+            s.executeUpdate("ALTER TABLE S.RS ADD CONSTRAINT PK_RS "
+                    + "PRIMARY KEY (R_TYPE_ID)");
+            s.executeUpdate("CREATE TABLE S.R_TYPE_ID (R_TYPE_ID "
+                    + "VARCHAR(64) NOT NULL)");
+            s.executeUpdate("ALTER TABLE S.R_TYPE_ID ADD CONSTRAINT "
+                    + "PK_R_TYPE_ID PRIMARY KEY (R_TYPE_ID)");
+            s.executeUpdate("ALTER TABLE S.RS ADD CONSTRAINT "
+                    + "FK_RS_TYPEID FOREIGN KEY (R_TYPE_ID) REFERENCES "
+                    + "S.R_TYPE_ID (R_TYPE_ID) ON DELETE CASCADE ON "
+                    + "UPDATE NO ACTION");
+            /*
+             * With 10.0 and early 10.1 releases a duplicate conglomerate entry
+             * shows in sys.sysconglomerates for the primary key PK_RS. It can
+             * be seen with this query.Utilities.showResultSet(s.executeQuery(
+             * "select c.constraintname, c.constraintid,  cong.conglomerateid, cong.conglomeratename
 from sys.sysconglomerates cong, sys.syskeys k, sys.sysconstraints c where c.constraintname
= 'PK_RS' and c.constraintid =k.constraintid and k.conglomerateid = cong.conglomerateid "
+             * ));
+             */
+            break;
+        case PH_SOFT_UPGRADE:
+            s.executeUpdate("ALTER TABLE S.RS DROP CONSTRAINT FK_RS_TYPEID");
+            s.executeUpdate("ALTER TABLE S.R_TYPE_ID ADD CONSTRAINT "
+                    + "PK_R_TYPE_ID PRIMARY KEY (R_TYPE_ID)");
+            s.executeUpdate("ALTER TABLE S.RS DROP CONSTRAINT PK_RS");
+            s.executeUpdate("DROP TABLE S.RS");
+            s.executeUpdate("DROP TABLE S.R_TYPE");
+            s.executeUpdate("DROP SCHEMA S RESTRICT");
+            break;
+        case PH_POST_SOFT_UPGRADE:
+            break;
+        case PH_HARD_UPGRADE:
+            break;
+        }
+
+    }
     }
-}



Mime
View raw message