db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r927430 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Date Thu, 25 Mar 2010 14:46:14 GMT
Author: kahatlen
Date: Thu Mar 25 14:46:14 2010
New Revision: 927430

URL: http://svn.apache.org/viewvc?rev=927430&view=rev
Log:
DERBY-4594: ArrayIndexOutOfBoundsException thrown in PreparedStatement execution

Added missing categorize() method in CoalesceFunctionNode.

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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=927430&r1=927429&r2=927430&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
Thu Mar 25 14:46:14 2010
@@ -30,13 +30,12 @@ import org.apache.derby.iapi.services.sa
 
 import org.apache.derby.iapi.error.StandardException;
 
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
 import org.apache.derby.iapi.services.compiler.LocalField;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.sql.compile.Visitable;
 import org.apache.derby.iapi.sql.compile.Visitor;
 
+import org.apache.derby.iapi.util.JBitSet;
+
 import java.lang.reflect.Modifier;
 
 import java.util.Vector;
@@ -398,6 +397,17 @@ public class CoalesceFunctionNode extend
 		}
 	}
 
+    /**
+     * Categorize this predicate.
+     *
+     * @see ValueNode#categorize(JBitSet, boolean)
+     */
+    public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+        throws StandardException
+    {
+        return argumentsList.categorize(referencedTabs, simplePredsOnly);
+    }
+
 	/**
 	 * Preprocess an expression tree.  We do a number of transformations
 	 * here (including subqueries, IN lists, LIKE and BETWEEN) plus

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java?rev=927430&r1=927429&r2=927430&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Thu Mar 25 14:46:14 2010
@@ -1184,6 +1184,26 @@ public class CoalesceTest extends BaseJD
                 "1");
     }
 
+    /**
+     * Regression test for DERBY-4594. A join with COALESCE in the WHERE
+     * clause failed with NullPointerException or with
+     * ArrayIndexOutOfBoundsException because the predicates had not been
+     * properly categorized in CoalesceFunctionNode.
+     */
+    public void testPredicateCategorizationDerby4594() throws SQLException {
+        s.execute("create table d4594_t1 (a1 int)");
+        s.execute("create table d4594_t2 (a2 int)");
+        s.execute("insert into d4594_t1 values 1");
+        // failed with NullPointerException
+        JDBC.assertEmpty(s.executeQuery(
+                "select 1 from d4594_t1 join d4594_t2 on 1=1 " +
+                "where coalesce(a2, 0) <> 1"));
+        // failed with ArrayIndexOutOfBoundsException
+        JDBC.assertEmpty(s.executeQuery(
+                "select 1 from d4594_t1 left join d4594_t2 on 1=1 " +
+                "where coalesce(a2, 0) <> 1"));
+    }
+
     /**************supporting methods *******************/
     private void dumpRS(ResultSet rs, String expectedValue) throws SQLException
     {



Mime
View raw message