db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1582819 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrimaryKeyTest.java
Date Fri, 28 Mar 2014 16:46:14 GMT
Author: dag
Date: Fri Mar 28 16:46:14 2014
New Revision: 1582819

URL: http://svn.apache.org/r1582819
Log:
DERBY-5111 NullPointerException on unique constraint violation with unique index

Patch derby-5111-test, which adds the repro for this issue as a new test case.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrimaryKeyTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrimaryKeyTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrimaryKeyTest.java?rev=1582819&r1=1582818&r2=1582819&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrimaryKeyTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrimaryKeyTest.java
Fri Mar 28 16:46:14 2014
@@ -25,13 +25,10 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
-
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.Utilities;
 
 public class PrimaryKeyTest extends BaseJDBCTestCase
 {	
@@ -41,13 +38,12 @@ public class PrimaryKeyTest extends Base
 	public static Test suite() {
 		return new TestSuite(PrimaryKeyTest.class);
 	}
+
+    @Override
 	protected void setUp() throws Exception {
 		super.setUp();
 		getConnection().setAutoCommit(false);
 	}
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
 
 					/************ NEGATIVE TESTS ************/	
 	/**
@@ -278,5 +274,27 @@ public class PrimaryKeyTest extends Base
 		assertUpdateCount(s , 0 , "drop table B5420_5.t5");
 		assertUpdateCount(s , 0 , "drop table B5420_6.t6");
 	}
+
+    public void testDerby5111() throws SQLException {
+        final Statement s = createStatement();
+        s.executeUpdate("create table t1 (t1_id integer not null, " +
+                "t0_id integer not null, value varchar(75) not null)");
+
+        try {
+            s.executeUpdate("create unique index ui1 on t1 (t1_id)");
+            s.executeUpdate("alter table t1 add constraint pk1 " +
+                    "                       primary key (t1_id)");
+            s.executeUpdate("create unique index ui2 on t1 (t0_id, value)");
+
+            s.executeUpdate("insert into t1 values(0, 0, 'Test')");
+
+            // The next statement tries to insert a duplicate.  It used to
+            // throw an NPE before the fix.
+            assertStatementError(
+                    "23505", s, "insert into t1 values(1, 0, 'Test')");
+        } finally {
+            try { s.executeUpdate("drop table t1"); } catch (SQLException e){}
+        }
+    }
 }
 



Mime
View raw message