You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2009/10/23 14:46:12 UTC
svn commit: r829034 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Author: kahatlen
Date: Fri Oct 23 12:46:12 2009
New Revision: 829034
URL: http://svn.apache.org/viewvc?rev=829034&view=rev
Log:
DERBY-4410: NullPointerException when USING clause contains all columns in both join tables
Adjust index properly when looping through the result columns and
expanding *. The old code didn't expect the number of columns to
decrease after the expansion and could therefore potentially skip
the processing of some of the columns.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.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/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=829034&r1=829033&r2=829034&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java Fri Oct 23 12:46:12 2009
@@ -1609,6 +1609,16 @@
insertElementAt(allExpansion.elementAt(inner), index + inner);
}
+ // Move the index position to account for the removals and the
+ // insertions. Should be positioned on the last column in the
+ // expansion to prevent double processing of the columns.
+ // DERBY-4410: If the expansion is empty, this will move the
+ // position one step back because the * was removed and nothing
+ // was inserted, so all columns to the right of the current
+ // position have been moved one position to the left. If we
+ // don't adjust the position, we end up skipping columns.
+ index += (allExpansion.size() - 1);
+
// If the rc was a "*", we need to set the initial list size
// to the number of columns that are actually returned to
// the user.
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=829034&r1=829033&r2=829034&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 12:46:12 2009
@@ -652,5 +652,11 @@
"select x.* from t1 x left join t1 y using (a,b,c)");
assertStatementError(NO_COLUMNS, s,
"select x.* from t1 x right join t1 y using (a,b,c)");
+
+ // DERBY-4410: If X.* expanded to no columns, the result column that
+ // immediately followed it (Y.*) would not be expanded, which eventually
+ // resulted in a NullPointerException.
+ assertStatementError(NO_COLUMNS, s,
+ "select x.*, y.* from t1 x inner join t1 y using (a, b, c)");
}
}