db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r652533 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Thu, 01 May 2008 14:28:20 GMT
Author: kmarsden
Date: Thu May  1 07:28:19 2008
New Revision: 652533

URL: http://svn.apache.org/viewvc?rev=652533&view=rev
Log:
DERBY-3649  can't call a stored function with an aggregate argument without getting the following
error: ERROR 42Y29

Move check for function in group by from AggregateExpressionVisitor to GroupByList


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java?rev=652533&r1=652532&r2=652533&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java Thu
May  1 07:28:19 2008
@@ -220,6 +220,13 @@
 				*/
 				numColsAddedHere++;
 			}
+			if (groupingCol.getColumnExpression() instanceof JavaToSQLValueNode) 
+			{
+				// disallow any expression which involves native java computation. 
+				// Not possible to consider java expressions for equivalence.
+				throw StandardException.newException(					
+						SQLState.LANG_INVALID_GROUPED_SELECT_LIST);
+			}
 		}
 
 		/* Verify that no subqueries got added to the dummy list */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java?rev=652533&r1=652532&r2=652533&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java
Thu May  1 07:28:19 2008
@@ -119,15 +119,7 @@
 							SQLState.LANG_INVALID_NON_GROUPED_SELECT_LIST :
 							SQLState.LANG_INVALID_GROUPED_SELECT_LIST);
 			}
-		} else if (node instanceof JavaToSQLValueNode) 
-		{
-			// disallow any expression which involves native java computation. 
-		    	// Not possible to consider java expressions for equivalence.
-			throw StandardException.newException( (groupByList == null) ?
-					SQLState.LANG_INVALID_NON_GROUPED_SELECT_LIST :
-						SQLState.LANG_INVALID_GROUPED_SELECT_LIST);
 		}
-
 		return node;
 	}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java?rev=652533&r1=652532&r2=652533&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
Thu May  1 07:28:19 2008
@@ -478,7 +478,9 @@
         // disallow java function 
         assertCompileError(
                 "42Y30", "select r(), count(*) from test group by r()");
-
+        
+        assertCompileError(
+                "42Y30", "select count(*) from test group by r()");
         // invalid grouping expression.
         assertCompileError(
                 "42Y30", "select c1+1, count(*) from test group by c1+2");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java?rev=652533&r1=652532&r2=652533&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Thu May  1 07:28:19 2008
@@ -23,6 +23,7 @@
 
 import java.io.UnsupportedEncodingException;
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Time;
@@ -461,6 +462,23 @@
         s.close();
     }
     
+    /**
+     * Test function with an aggregate argument. DERBY-3649
+     * @throws SQLException
+     */
+    public void testAggregateArgument() throws SQLException
+    {
+    	Statement s = createStatement();
+    	s.executeUpdate("CREATE TABLE TEST (I INT)");
+    	s.executeUpdate("INSERT INTO TEST VALUES(1)");
+    	s.executeUpdate("INSERT INTO TEST VALUES(2)");
+    	s.executeUpdate("CREATE FUNCTION CheckCount(count integer) RETURNS INTEGER PARAMETER
STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL NAME 'org.apache.derbyTesting.functionTests.tests.lang.RoutineTest.checkCount'");
+    	ResultSet rs = s.executeQuery("select checkCount(count(*)) from test");
+    	JDBC.assertSingleValueResultSet(rs, "2");
+    	
+    	
+    }
+    
     /*
     ** Routine implementations called from the tests but do
     *  not use DriverManager so that this test can be used on
@@ -492,5 +510,19 @@
         
         return t;
     }
+    
+
+    public static int checkCount(int count)
+               throws SQLException {
+           //   throws ZeroException {
+
+           if (count == 0) {
+               //throw new ZeroException();
+               throw new SQLException("No results found", "38777");
+           }
+
+           return count;
+       }
+
 }
 



Mime
View raw message