db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r927599 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Date Thu, 25 Mar 2010 21:44:10 GMT
Author: kahatlen
Date: Thu Mar 25 21:44:09 2010
New Revision: 927599

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

Merged fix from trunk (revision 927430).

Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 25 21:44:09 2010
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,881074,881444,882732,884163,887246,892912,897161,901165,901648,901760,903108,911315,915733,916075,916897,918359,921028
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,881074,881444,882732,884163,887246,892912,897161,901165,901648,901760,903108,911315,915733,916075,916897,918359,921028,927430

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=927599&r1=927598&r2=927599&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
Thu Mar 25 21:44:09 2010
@@ -30,13 +30,13 @@ 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;
@@ -374,6 +374,17 @@ public class CoalesceFunctionNode extend
 		}
 		return returnNode;
 	}
+    /**
+     * 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/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java?rev=927599&r1=927598&r2=927599&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Thu Mar 25 21:44:09 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