db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1560452 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/MergeResultSet.java testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Date Wed, 22 Jan 2014 18:14:16 GMT
Author: rhillegas
Date: Wed Jan 22 18:14:16 2014
New Revision: 1560452

URL: http://svn.apache.org/r1560452
Log:
DERBY-3155: Make MERGE statement serialize SQLRefs rather than HeapRowLocations; commit derby-3155-17-aa-serializingRowLocations.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MergeResultSet.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/execute/MergeResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MergeResultSet.java?rev=1560452&r1=1560451&r2=1560452&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MergeResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MergeResultSet.java
Wed Jan 22 18:14:16 2014
@@ -33,6 +33,7 @@ import org.apache.derby.iapi.sql.execute
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.RowLocation;
+import org.apache.derby.iapi.types.SQLRef;
 
 /**
  * INSERT/UPDATE/DELETE a target table based on how it outer joins
@@ -204,6 +205,10 @@ class MergeResultSet extends NoRowsResul
                 {
                     matched = true;
                     baseRowLocation = (RowLocation) rlColumn.getObject();
+                    
+                    // change the HeapRowLocation into a SQLRef, something which the
+                    // temporary table can (de)serialize correctly
+                    _row.setColumn( _row.nColumns(), new SQLRef( baseRowLocation ) );
                 }
             }
 

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=1560452&r1=1560451&r2=1560452&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 18:14:16 2014
@@ -4693,6 +4693,69 @@ public class MergeStatementTest extends 
         goodStatement( dboConnection, "drop table t2_029" );
     }
     
+    /**
+     * <p>
+     * Verify the fix to a query which broke the serialization of
+     * row locations.
+     * </p>
+     */
+    public  void    test_030_SQLRef_serialization()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        //
+        // create schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_030(x int, y varchar(100))"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t2_030(x int)"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t2_030 values 1, 1, 2"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t1_030 values (1, null), (2, '')"
+             );
+
+        // verify the fix
+        goodUpdate
+            (
+             dboConnection,
+             "merge into t1_030\n" +
+             "using t2_030 on true\n" +
+             "when matched then update set y = y || 'x'\n",
+             6
+             );
+        assertResults
+            (
+             dboConnection,
+             "select  * from t1_030 order by x, y",
+             new String[][]
+             {
+                 { "1", null },
+                 { "2", "x" },
+             },
+             false
+             );
+
+        //
+        // drop schema
+        //
+        goodStatement( dboConnection, "drop table t1_030" );
+        goodStatement( dboConnection, "drop table t2_030" );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES



Mime
View raw message