db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1560507 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/UpdateNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Date Wed, 22 Jan 2014 20:56:59 GMT
Author: rhillegas
Date: Wed Jan 22 20:56:58 2014
New Revision: 1560507

URL: http://svn.apache.org/r1560507
Log:
DERBY-3155: Basic support for views as the source tables of MERGE statements; commit derby-3155-18-aa-basicView.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?rev=1560507&r1=1560506&r2=1560507&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java Wed
Jan 22 20:56:58 2014
@@ -381,7 +381,11 @@ public final class UpdateNode extends DM
 			((FromBaseTable) targetTable).markUpdated(
 												resultSet.getResultColumns());
 		}
-		else if (targetTable instanceof FromVTI)
+		else if
+            (
+             (targetTable instanceof FromVTI) ||
+             (targetTable instanceof FromSubquery)
+             )
 		{
             resultColumnList = resultSet.getResultColumns();
 		}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java?rev=1560507&r1=1560506&r2=1560507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Wed Jan 22 20:56:58 2014
@@ -4756,6 +4756,75 @@ public class MergeStatementTest extends 
         goodStatement( dboConnection, "drop table t2_030" );
     }
     
+    /**
+     * <p>
+     * Verify the fix to a query involving a view.
+     * </p>
+     */
+    public  void    test_031_view()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        //
+        // create schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_031(x int, y int)"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table tv_031(x int, y int)"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create view v_031 as select * from tv_031"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t1_031 values ( 1, 100 ), ( 2, 200 ), ( 3, 300 )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into tv_031 values ( 1, 1000 ), ( 3, 3000 ), ( 4, 4000 )"
+             );
+
+        // verify the fix
+        goodUpdate
+            (
+             dboConnection,
+             "merge into t1_031\n" +
+             "using v_031 on t1_031.x = v_031.x\n" +
+             "when matched then update set t1_031.y = v_031.y\n",
+             2
+             );
+        assertResults
+            (
+             dboConnection,
+             "select * from t1_031 order by x",
+             new String[][]
+             {
+                 { "1", "1000" },
+                 { "2", "200" },
+                 { "3", "3000" },
+             },
+             false
+             );
+
+        //
+        // drop schema
+        //
+        goodStatement( dboConnection, "drop view v_031" );
+        goodStatement( dboConnection, "drop table t1_031" );
+        goodStatement( dboConnection, "drop table tv_031" );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES



Mime
View raw message