From derby-commits-return-12104-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Mon Sep 28 14:21:12 2009 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 70050 invoked from network); 28 Sep 2009 14:21:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Sep 2009 14:21:12 -0000 Received: (qmail 930 invoked by uid 500); 28 Sep 2009 14:21:12 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 847 invoked by uid 500); 28 Sep 2009 14:21:12 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 837 invoked by uid 99); 28 Sep 2009 14:21:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2009 14:21:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2009 14:21:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3F7D723888D7; Mon, 28 Sep 2009 14:20:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r819547 - 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: Mon, 28 Sep 2009 14:20:44 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090928142044.3F7D723888D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Mon Sep 28 14:20:43 2009 New Revision: 819547 URL: http://svn.apache.org/viewvc?rev=819547&view=rev Log: DERBY-4342: SQLSTATE 38000 (NullPointerException) at inner self join and value(x1, x2...) Merged fix from trunk (revision 819006). 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 Mon Sep 28 14:20:43 2009 @@ -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 +/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 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=819547&r1=819546&r2=819547&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 Mon Sep 28 14:20:43 2009 @@ -428,4 +428,20 @@ } } + /** + * Remap all the {@code ColumnReference}s in this tree to be clones of + * the underlying expression. + * + * @return the remapped tree + * @throws StandardException if an error occurs + */ + public ValueNode remapColumnReferencesToExpressions() + throws StandardException + { + for (int i = 0; i < argumentsList.size(); i++) { + ValueNode vn = (ValueNode) argumentsList.elementAt(i); + vn.remapColumnReferencesToExpressions(); + } + return this; + } } 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=819547&r1=819546&r2=819547&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 Mon Sep 28 14:20:43 2009 @@ -30,10 +30,10 @@ import java.io.UnsupportedEncodingException; import junit.framework.Test; -import junit.framework.TestSuite; import org.apache.derbyTesting.junit.BaseJDBCTestCase; import org.apache.derbyTesting.junit.TestConfiguration; import org.apache.derbyTesting.junit.CleanDatabaseTestSetup; +import org.apache.derbyTesting.junit.JDBC; /** @@ -1170,6 +1170,19 @@ expectedValues[index++]); } + /** + * Regression test for DERBY-4342. A self-join with COALESCE in the WHERE + * clause used to fail with a NullPointerException because + * CoalesceFunctionNode didn't remap column references correctly. + */ + public void testColumnRemappingDerby4342() throws SQLException { + JDBC.assertSingleValueResultSet(s.executeQuery( + "select t1.smallintcol from " + + "AllDataTypesTable t1 join AllDataTypesTable t2 " + + "on t1.smallintcol=t2.smallintcol where " + + "coalesce(t1.smallintcol, t1.integercol) = 1"), + "1"); + } /**************supporting methods *******************/ private void dumpRS(ResultSet rs, String expectedValue) throws SQLException