db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1502371 - in /db/derby/code/branches/10.9: ./ java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/OrderByAndOffsetFetchInSubqueries.java
Date Thu, 11 Jul 2013 21:24:28 GMT
Author: mikem
Date: Thu Jul 11 21:24:28 2013
New Revision: 1502371

URL: http://svn.apache.org/r1502371
Log:
DERBY-6006: NullPointerException in INSERT INTO ... SELECT FROM ... ORDER BY

backporting change #1417991 by kahatlen from 10.10 to 10.9 branch.

A NormalizeResultSet should not expose generated ORDER BY columns to
its parent. 



Modified:
    db/derby/code/branches/10.9/   (props changed)
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
    db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OrderByAndOffsetFetchInSubqueries.java

Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1417991

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java?rev=1502371&r1=1502370&r2=1502371&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
Thu Jul 11 21:24:28 2013
@@ -605,6 +605,8 @@ public class NormalizeResultSetNode exte
 		rsn.setResultColumns(rcl.copyListAndObjects());
 		// Remove any columns that were generated.
 		prRCList.removeGeneratedGroupingColumns();
+        // And also columns that were added for ORDER BY (DERBY-6006).
+        prRCList.removeOrderByColumns();
 
 		/* Replace ResultColumn.expression with new VirtualColumnNodes
 		 * in the NormalizeResultSetNode's ResultColumnList.  (VirtualColumnNodes include

Modified: db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OrderByAndOffsetFetchInSubqueries.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OrderByAndOffsetFetchInSubqueries.java?rev=1502371&r1=1502370&r2=1502371&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OrderByAndOffsetFetchInSubqueries.java
(original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OrderByAndOffsetFetchInSubqueries.java
Thu Jul 11 21:24:28 2013
@@ -309,6 +309,21 @@ public class OrderByAndOffsetFetchInSubq
             s.executeQuery("select * from t4496"),
             new String[][]{{"Y"}});
 
+        // DERBY-6006. INSERT INTO ... SELECT FROM could fail with a
+        // NullPointerException in insane builds, or XSCH5 or assert in sane
+        // builds, if the SELECT had an ORDER BY column that was not referenced
+        // in the select list, and if normalization was required because the
+        // types in the select list didn't exactly match the types in the
+        // target table.
+        //
+        // In the test case below, the select list has an INT (the literal 1),
+        // whereas the target type is DOUBLE. Also, the ORDER BY column (X) is
+        // not in the select list.
+        s.execute("create table t6006(x double)");
+        assertUpdateCount(s, 6, "insert into t6006 values 1,2,3,4,5,6");
+        assertUpdateCount(s, 6,
+                "insert into t6006 select 1 from t6006 order by x");
+
         rollback();
     }
 



Mime
View raw message