db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1560134 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 21 Jan 2014 18:38:08 GMT
Author: rhillegas
Date: Tue Jan 21 18:38:08 2014
New Revision: 1560134

URL: http://svn.apache.org/r1560134
Log:
DERBY-3155: Allow for row location columns in the result column list of base tables; tests
passed cleanly for me on derby-3155-16-aa-treatCurrentRowLocationNodeLikeBaseColumnNode.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.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/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=1560134&r1=1560133&r2=1560134&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Tue
Jan 21 18:38:08 2014
@@ -2926,6 +2926,7 @@ class FromBaseTable extends FromTable
 		 */
 		ResultColumnList prRCList = resultColumns;
 		resultColumns = resultColumns.copyListAndObjects();
+		resultColumns.setIndexRow( baseConglomerateDescriptor.getConglomerateNumber(), forUpdate()
);
 
 		/* Replace ResultColumn.expression with new VirtualColumnNodes
 		 * in the ProjectRestrictNode's ResultColumnList.  (VirtualColumnNodes include

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=1560134&r1=1560133&r2=1560134&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Tue Jan 21 18:38:08 2014
@@ -3648,7 +3648,13 @@ class ResultColumnList extends QueryTree
 				 */
 				if (onlyBCNs && ! (oldCol.getExpression() instanceof BaseColumnNode))
 				{
-					continue;
+                    boolean skipable =
+                        ( ! (oldCol.getExpression() instanceof BaseColumnNode) ) &&
+                        ( ! (oldCol.getExpression() instanceof CurrentRowLocationNode) );
+                    if ( skipable )
+                    {
+                        continue;
+                    }
 				}
 				newReferencedCols.set(index);
 				colsAdded++;

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=1560134&r1=1560133&r2=1560134&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
Tue Jan 21 18:38:08 2014
@@ -4634,6 +4634,65 @@ public class MergeStatementTest extends 
         goodStatement( dboConnection, "drop view singlerow_028" );
     }
     
+    /**
+     * <p>
+     * This case tests a problem query which causes an index scan to
+     * be selected for the target table. Row locations weren't being treated
+     * as columns in the result row and conglomerate info was not being
+     * propagated to copied ResultColumnLists.
+     * </p>
+     */
+    public  void    test_029_scanViaIndex()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        //
+        // create schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_029(x int primary key)"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t2_029(x int)"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t2_029 values( 33 )"
+             );
+
+        // this was the problem query
+        goodUpdate
+            (
+             dboConnection,
+             "merge into t1_029\n" +
+             "using t2_029 on t1_029.x = 42\n" +
+             "when not matched then insert (x) values (42)\n",
+             1
+             );
+        assertResults
+            (
+             dboConnection,
+             "select  * from t1_029 order by x",
+             new String[][]
+             {
+                 { "42" },
+             },
+             false
+             );
+
+        //
+        // drop schema
+        //
+        goodStatement( dboConnection, "drop table t1_029" );
+        goodStatement( dboConnection, "drop table t2_029" );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES



Mime
View raw message