db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r676819 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ResultColumnList.java testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
Date Tue, 15 Jul 2008 07:35:09 GMT
Author: kahatlen
Date: Tue Jul 15 00:35:08 2008
New Revision: 676819

URL: http://svn.apache.org/viewvc?rev=676819&view=rev
Log:
DERBY-3764: Union Query fail on Derby 10.4.1.3

Only look at the visible columns when checking that the expressions in
a UNION query are compatible. This prevents
ArrayIndexOutOfBoundsException from being thrown when preparing some
queries that contain GROUP BY clauses. It is only a partial fix, since
some of the queries run into other problems later in the execution.

Modified:
    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/GroupByTest.java

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=676819&r1=676818&r2=676819&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 Jul 15 00:35:08 2008
@@ -2233,7 +2233,7 @@
 
 		ContextManager cm = getContextManager();
 
-		int size = size();
+		int size = visibleSize();
 		for (int index = 0; index < size; index++)
 		{
 			boolean		 nullableResult;
@@ -2344,7 +2344,7 @@
 	 */
 	public boolean isExactTypeAndLengthMatch(ResultColumnList otherRCL) throws StandardException
 	{
-		int size = size();
+		int size = visibleSize();
 		for (int index = 0; index < size; index++)
 		{
 			ResultColumn thisRC = (ResultColumn) elementAt(index);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java?rev=676819&r1=676818&r2=676819&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
Tue Jul 15 00:35:08 2008
@@ -1758,5 +1758,22 @@
                     " group by name having sum(amount) > 2"),
             new String[][] {  {"Jerry", "57"}, {"John","113"} } );
     }
+
+    /**
+     * Test that GROUP BY can be used in the sub-queries of a UNION.
+     * DERBY-3764.
+     */
+    public void testUnionAndGroupBy() throws SQLException {
+        PreparedStatement ps1 =
+            prepareStatement("select sum(a) from yy group by a union values 1");
+        // The bug is not completely fixed, so executing the statement fail
+        // JDBC.assertDrainResults(ps1.executeQuery());
+
+        PreparedStatement ps2 =
+            prepareStatement("select sum(a) from yy group by a union " +
+                             "select sum(a) from yy group by a");
+        // The bug is not completely fixed, so executing the statement fail
+        // JDBC.assertDrainResults(ps2.executeQuery());
+    }
 }
 



Mime
View raw message