db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r561860 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/AggregateNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
Date Wed, 01 Aug 2007 16:27:49 GMT
Author: djd
Date: Wed Aug  1 09:27:46 2007
New Revision: 561860

URL: http://svn.apache.org/viewvc?view=rev&rev=561860
Log:
DERBY-2937 Add a test case for the error seen in this bug and ensure that when a column reference
is created for an aggregate node that it points to its source.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.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/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?view=diff&rev=561860&r1=561859&r2=561860
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Wed
Aug  1 09:27:46 2007
@@ -168,26 +168,17 @@
 			/*
 			** Parse time.	
 			*/
-			if (getTypeServices() == null)
-			{
-				generatedRef = (ColumnReference) getNodeFactory().getNode(
-												C_NodeTypes.COLUMN_REFERENCE,
-												generatedColName,
-												null,
-												getContextManager());
-			}
-			else
-			{
-				generatedRef = (ColumnReference) getNodeFactory().getNode(
+			generatedRef = (ColumnReference) getNodeFactory().getNode(
 												C_NodeTypes.COLUMN_REFERENCE,
 												generatedRC.getName(),
 												null,
 												getContextManager());
-				generatedRef.setType(this.getTypeServices());
-			}
+
 			// RESOLVE - unknown nesting level, but not correlated, so nesting levels must be 0
+            generatedRef.setSource(generatedRC);
 			generatedRef.setNestingLevel(0);
 			generatedRef.setSourceLevel(0);
+            
 			if (tableNumber != -1)
 			{
 				generatedRef.setTableNumber(tableNumber);

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?view=diff&rev=561860&r1=561859&r2=561860
==============================================================================
--- 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
Wed Aug  1 09:27:46 2007
@@ -21,6 +21,7 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
@@ -110,5 +111,28 @@
 		s.close();
 		rollback();
 	}
+    
+    /**
+     * DERBY-2397 showed incorrect typing of aggregate nodes
+     * that lead to a SUBSTR throwing an exception that its
+     * position/length were out of range.
+     * @throws SQLException
+     */
+    public void testDERBY2937() throws SQLException {
+        Statement s = createStatement();
+        
+        s.executeUpdate("CREATE TABLE A2937 (C CHAR(10) NOT NULL, " +
+                "D DATE NOT NULL, DC DECIMAL(6,2))");
+        s.executeUpdate("INSERT INTO A2937 VALUES ('aaa', " +
+                "DATE('2007-07-10'), 500.00)");
+        
+        ResultSet rs = s.executeQuery("SELECT A.C, SUBSTR (MAX(CAST(A.D AS CHAR(10)) || "
+
+                "CAST(A.DC AS CHAR(8))), 11, 8) AS BUG " +
+                "FROM A2937 A GROUP BY A.C");
+        JDBC.assertFullResultSet(rs,
+                new String[][] {{"aaa","500.00"}});
+        s.executeUpdate("DROP TABLE A2937");
+        
+    }
 }
 



Mime
View raw message