db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r615042 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/sql/compile/AggregateNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
Date Thu, 24 Jan 2008 21:57:42 GMT
Author: kmarsden
Date: Thu Jan 24 13:57:41 2008
New Revision: 615042

URL: http://svn.apache.org/viewvc?rev=615042&view=rev
Log:
DERBY-3231 Sorting on COUNT with OR and GROUP BY delivers wrong results.
port revision 603954 from trunk.
Fix contributed by Manish Khettry.


Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?rev=615042&r1=615041&r2=615042&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
Thu Jan 24 13:57:41 2008
@@ -620,4 +620,14 @@
 			return "";
 		}
 	}
+
+	public boolean isConstant()
+	{
+		return false;
+	}
+	
+	public boolean constantExpression(PredicateList where)
+	{
+		return false;
+	}
 }

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java?rev=615042&r1=615041&r2=615042&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
Thu Jan 24 13:57:41 2008
@@ -132,5 +132,39 @@
         JDBC.assertFullResultSet(rs, expectedRows);
         s.executeUpdate("DROP TABLE TAB");
     }
+
+	public void testDerbyOrderByOnAggregate() throws SQLException
+	{
+		Statement s = createStatement();
+		s.executeUpdate("create table yy (a double, b double)");
+		s.executeUpdate("insert into yy values (2,4), (2, 4), " +
+			"(5,7), (2,3), (2,3), (2,3), (2,3), (9,7)");
+
+		ResultSet rs = s.executeQuery(
+			"select b, count(*) from yy where a=5 or a=2 " +
+			"group by b order by count(*) desc");
+
+		JDBC.assertFullResultSet(
+				rs,
+				new Object[][]{
+						{new Double(3), new Integer(4)},
+						{new Double(4), new Integer(2)},
+						{new Double(7), new Integer(1)}},
+				false);
+
+		rs = s.executeQuery(
+			"select b, count(*) from yy where a=5 or a=2 " +
+			"group by b order by count(*) asc");
+
+		JDBC.assertFullResultSet(
+				rs,
+				new Object[][]{
+						{new Double(7), new Integer(1)},
+						{new Double(4), new Integer(2)},
+						{new Double(3), new Integer(4)}},
+				false);
+
+		s.executeUpdate("drop table yy");
+	}
 }
 



Mime
View raw message