db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r910294 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
Date Mon, 15 Feb 2010 18:43:57 GMT
Author: mamta
Date: Mon Feb 15 18:43:57 2010
New Revision: 910294

URL: http://svn.apache.org/viewvc?rev=910294&view=rev
Log:
Backporting change for DERBY-4402 in 10.5 codeline


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 15 18:43:57 2010
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,882732,884163,887246,892912,897161,901165,901648,901760,903108
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,881074,881444,882732,884163,887246,892912,897161,901165,901648,901760,903108

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=910294&r1=910293&r2=910294&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
Mon Feb 15 18:43:57 2010
@@ -9692,17 +9692,18 @@
 {
 	columnExpression = additiveExpression(null, 0, false)
 	{
+		/* Aggregates not allowed in group by */
+		HasNodeVisitor visitor =
+			new HasNodeVisitor(AggregateNode.class);
+		columnExpression.accept(visitor);
+		if (visitor.hasNode())
+		{
+			throw StandardException.newException(SQLState.LANG_AGGREGATE_IN_GROUPBY_LIST);
+		}
 		if (columnExpression.isParameterNode()) 
 	    	{
 			throw StandardException.newException(SQLState.LANG_SYNTAX_ERROR, "?");
 	    	}
-		if (columnExpression instanceof AggregateNode)
-		{
-			AggregateNode agNode = (AggregateNode)columnExpression;
-			throw StandardException.newException(
-				SQLState.LANG_AGGREGATE_IN_GROUPBY_LIST, 
-				agNode.getAggregateName());
-		}        
 		groupingCols.addGroupByColumn(
 			(GroupByColumn) nodeFactory.getNode(
 							C_NodeTypes.GROUP_BY_COLUMN,

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java?rev=910294&r1=910293&r2=910294&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
Mon Feb 15 18:43:57 2010
@@ -123,6 +123,18 @@
     }
     
     /**
+     * DERBY-4202 Aggregates not allowed in group by
+     * @throws Exception
+     */
+    public void testDerby4402AggregateInGroupBy() throws Exception
+    {
+    	assertCompileError(
+                "42Y26", "select c1 from test group by sum(c3)");
+    	assertCompileError(
+                "42Y26", "select c1 from test group by (c1+sum(c3))");
+    }
+    
+    /**
      * queries which combine compound expressions and simple column refs.
      */
     public void testDerby3094Expressions() throws Exception



Mime
View raw message