You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2015/01/22 19:13:37 UTC

svn commit: r1653986 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java

Author: mamta
Date: Thu Jan 22 18:13:37 2015
New Revision: 1653986

URL: http://svn.apache.org/r1653986
Log:
DERBY-6788(Wrong value inserted by INSERT INTO with multiple subselects)

Adding a junit test case for DERBY-6788. This bug might be related to DERBY-6786(NullPointerException in INSERT INTO statement with  multiple subselects)

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java?rev=1653986&r1=1653985&r2=1653986&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java Thu Jan 22 18:13:37 2015
@@ -44,6 +44,51 @@ public class InsertTest extends BaseJDBC
     public static Test suite() {
         return TestConfiguration.defaultSuite(InsertTest.class);
     }
+
+    //DERBY-6788(Wrong value inserted by INSERT INTO with multiple subselects)
+    //Following test case has zz against its name and hence it won't run. 
+    // This is because one INSERT with JOIN in the test can cause data .  
+    // corruption. Once DERBY-6788 is fixed, following test should be enabled 
+    // by removing zz. This bug might be related to 
+    // DERBY-6786(NullPointerException in INSERT INTO statement with multiple 
+    //  subselects)
+    public void zztestDerby6788() throws SQLException {
+        Statement s = createStatement();
+        s.execute("CREATE TABLE M1 (K varchar(64), S decimal)");
+        s.execute("CREATE TABLE M2 (K varchar(64), S decimal)");
+        s.execute("CREATE TABLE V  (S DECIMAL)");
+        s.execute("INSERT INTO M1 VALUES ('Bug', 2015)");
+        s.execute("INSERT INTO M2 VALUES ('Bug', 1957)");
+        JDBC.assertFullResultSet(
+            s.executeQuery(
+            "SELECT res.* FROM (SELECT d2.s FROM m1 "+
+            "LEFT JOIN " +
+            "(SELECT k,s FROM m2) AS d2 ON m1.k=d2.k) AS res"),
+            new String[][]{{"1957"}});
+        //The INSERT below will insert incorrect value into V because of
+        // DERBY-6788. This bug might be related to 
+        // DERBY-6786(NullPointerException in INSERT INTO statement with  
+        //  multiple subselects)
+        s.execute("INSERT INTO V "+
+                "(SELECT res.* FROM (SELECT d2.s FROM m1 " +
+        		"LEFT JOIN " +
+                "(SELECT k,s FROM m2) AS d2 ON m1.k=d2.k) AS res)");
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                "SELECT * FROM V"),
+                new String[][]{{"1957"}});
+        s.execute("INSERT INTO V "+
+                "(SELECT res.* FROM (SELECT d2.s*1 FROM m1 " +
+        		"LEFT JOIN " +
+                "(SELECT k,s FROM m2) AS d2 ON m1.k=d2.k) AS res)");
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                "SELECT * FROM V"),
+                new String[][]{{"1957"},{"1957"}});
+        s.execute("DROP   TABLE M1");
+        s.execute("DROP   TABLE M2");
+        s.execute("DROP   TABLE V");
+    }
     
     public void testDerby6786Case1() throws SQLException {
         Statement s = createStatement();