db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1587317 - 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 Mon, 14 Apr 2014 20:56:59 GMT
Author: rhillegas
Date: Mon Apr 14 20:56:58 2014
New Revision: 1587317

URL: http://svn.apache.org/r1587317
Log:
DERBY-3155: Fix bug in MERGE statement fired by a trigger; commit derby-3155-53-aa-transitionSimpleColumn.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=1587317&r1=1587316&r2=1587317&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 Mon
Apr 14 20:56:58 2014
@@ -1538,7 +1538,12 @@ public final class UpdateNode extends DM
 		{
 			boolean foundMatchingTable = false;			
 
-			if (column.getTableName() != null) {
+            //
+            // The check for whether we are in the matching clause fixes
+            // the bug tracked by MergeStatementTest.test_060_transitionTableSimpleColumn().
+            // That bug was addressed by derby-3155-53-aa-transitionSimpleColumn.diff.
+            //
+			if ( (column.getTableName() != null) && (!inMatchingClause()) ) {
                 for (ResultSetNode rsn : ((SelectNode)resultSet).fromList) {
                     FromTable fromTable = (FromTable)rsn;
 

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=1587317&r1=1587316&r2=1587317&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
Mon Apr 14 20:56:58 2014
@@ -9436,6 +9436,70 @@ public class MergeStatementTest extends 
         goodStatement( dboConnection, "drop function mb_059" );
     }
     
+    /**
+     * <p>
+     * Test that the UPDATE actions of MERGE statements work with
+     * trigger transition tables and simple column expressions from the transition tables.
+     * </p>
+     */
+    public  void    test_060_transitionTableSimpleColumn()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        //
+        // Schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_060( x int, x1 int )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t2_060( y int, y1 int )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create trigger tr1 after insert on t1_060\n" +
+             "referencing new table as new\n" +
+             "merge into t2_060\n" +
+             "using new on x1 = y1\n" +
+             "when matched then update set y = x\n"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t2_060 values ( 1, 100 ), ( 2, 200 )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t1_060 values ( 1000, 100 ), ( 3000, 300 )"
+             );
+
+        // verify the results
+        assertResults
+            (
+             dboConnection,
+             "select * from t2_060 order by y, y1",
+             new String[][]
+             {
+                 { "2", "200" },
+                 { "1000", "100" },
+             },
+             false
+             );
+
+        //
+        // Drop schema
+        //
+        goodStatement( dboConnection, "drop table t1_060" );
+        goodStatement( dboConnection, "drop table t2_060" );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES



Mime
View raw message