db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1618114 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 15 Aug 2014 08:20:31 GMT
Author: kahatlen
Date: Fri Aug 15 08:20:30 2014
New Revision: 1618114

URL: http://svn.apache.org/r1618114
Log:
DERBY-6703: MERGE statement fails with NullPointerException if ON clause references non-existent
column

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MergeNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?rev=1618114&r1=1618113&r2=1618114&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
Fri Aug 15 08:20:30 2014
@@ -387,7 +387,7 @@ public class ColumnReference extends Val
 	 * @exception StandardException		Thrown on error
 	 */
     @Override
-    ValueNode bindExpression(FromList fromList,
+    ColumnReference bindExpression(FromList fromList,
                              SubqueryList subqueryList,
                              List<AggregateNode> aggregates)
             throws StandardException

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java?rev=1618114&r1=1618113&r2=1618114&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java Fri Aug
15 08:20:30 2014
@@ -622,7 +622,8 @@ class FromList extends    QueryTreeNodeV
 	 *
 	 * @param columnReference	The ColumnReference describing the column to bind
 	 *
-	 * @return	ResultColumn	The matching ResultColumn
+     * @return ResultColumn     The matching ResultColumn, or {@code null} if
+     *                          there is no matching column
 	 *
 	 * @exception StandardException		Thrown on error
 	 */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MergeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MergeNode.java?rev=1618114&r1=1618113&r2=1618114&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MergeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MergeNode.java Fri Aug
15 08:20:30 2014
@@ -942,9 +942,11 @@ public final class MergeNode extends DML
     {
         if ( cr.getTableName() == null )
         {
-            ResultColumn    rc = _leftJoinFromList.bindColumnReference( cr );
+            cr = cr.bindExpression(
+                    _leftJoinFromList,
+                    new SubqueryList(getContextManager()),
+                    new ArrayList<AggregateNode>());
             TableName       tableName = cr.getQualifiedTableName();
-            if ( tableName == null ) { tableName = new TableName( null, rc.getTableName(),
getContextManager() ); }
             cr = new ColumnReference( cr.getColumnName(), tableName, getContextManager()
);
         }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java?rev=1618114&r1=1618113&r2=1618114&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Fri Aug 15 08:20:30 2014
@@ -324,6 +324,13 @@ public class MergeStatementTest extends 
               "when matched then delete\n"
               );
 
+        // Variant of the above, where no table name is specified in the
+        // column reference that is out of scope. Used to fail with a
+        // NullPointerException (DERBY-6703).
+        expectCompilationError(dboConnection, COLUMN_OUT_OF_SCOPE,
+                "merge into t1 using t2 on no_such_column " +
+                "when matched then delete");
+
         //
         // The matching refinement clauses can only mention columns in the
         // source and target tables.



Mime
View raw message