db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r829041 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/JoinNode.java engine/org/apache/derby/impl/sql/compile/ResultSetNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Date Fri, 23 Oct 2009 13:01:35 GMT
Author: kahatlen
Date: Fri Oct 23 13:01:34 2009
New Revision: 829041

URL: http://svn.apache.org/viewvc?rev=829041&view=rev
Log:
DERBY-4414: NullPointerException with JOIN...USING and invalid table name in select list

Fail gracefully if the table name in an asterisked identifier chain
doesn't match any of the joined tables.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?rev=829041&r1=829040&r2=829041&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java Fri Oct
23 13:01:34 2009
@@ -428,11 +428,20 @@
 		 */
 		if (leftRCL == null)
 		{
+			if (rightRCL == null)
+			{
+				// Both sides are null. This only happens if allTableName is
+				// non-null and doesn't match the table name of any of the
+				// join tables (DERBY-4414).
+				return null;
+			}
 			rightRCL.resetVirtualColumnIds();
 			return rightRCL;
 		}
 		else if (rightRCL == null)
 		{
+			// leftRCL is non-null, otherwise the previous leg of the if
+			// statement would have been chosen.
 			leftRCL.resetVirtualColumnIds();
 			return leftRCL;
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?rev=829041&r1=829040&r2=829041&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Fri
Oct 23 13:01:34 2009
@@ -484,7 +484,9 @@
 	 *
 	 * @param allTableName		The qualifier on the "*"
 	 *
-	 * @return ResultColumnList The expanded list
+	 * @return ResultColumnList The expanded list, or {@code null} if
+	 * {@code allTableName} is non-null and doesn't match a table name in
+	 * this result set
 	 *
 	 * @exception StandardException		Thrown on error
 	 */

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java?rev=829041&r1=829040&r2=829041&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Fri Oct 23 13:01:34 2009
@@ -39,6 +39,7 @@
     private static final String COLUMN_NOT_IN_SCOPE = "42X04";
     private static final String NON_COMPARABLE = "42818";
     private static final String NO_COLUMNS = "42X81";
+    private static final String TABLE_NAME_NOT_IN_SCOPE = "42X10";
 
     public JoinTest(String name) {
         super(name);
@@ -658,5 +659,11 @@
         // resulted in a NullPointerException.
         assertStatementError(NO_COLUMNS, s,
                 "select x.*, y.* from t1 x inner join t1 y using (a, b, c)");
+
+        // DERBY-4414: If the table name in an asterisked identifier chain does
+        // not match the table names of either side in the join, the query
+        // should fail gracefully and not throw a NullPointerException.
+        assertStatementError(TABLE_NAME_NOT_IN_SCOPE, s,
+                "select xyz.* from t1 join t2 using (b)");
     }
 }



Mime
View raw message