Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 45227 invoked from network); 20 Mar 2008 15:32:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Mar 2008 15:32:17 -0000 Received: (qmail 26501 invoked by uid 500); 20 Mar 2008 15:32:15 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 26469 invoked by uid 500); 20 Mar 2008 15:32:15 -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 26457 invoked by uid 99); 20 Mar 2008 15:32:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 08:32:15 -0700 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.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 15:31:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2214E1A983A; Thu, 20 Mar 2008 08:31:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r639316 - in /db/derby/code/branches/10.1/java: engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/ Date: Thu, 20 Mar 2008 15:31:52 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080320153153.2214E1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Thu Mar 20 08:31:50 2008 New Revision: 639316 URL: http://svn.apache.org/viewvc?rev=639316&view=rev Log: DERBY-3538 NullPointerException during execution for query with LEFT OUTER JOIN whose inner table selects all constants. Contributeed by Army Brown. port from trunk revision 638425 Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/joins.out db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java?rev=639316&r1=639315&r2=639316&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java Thu Mar 20 08:31:50 2008 @@ -483,6 +483,15 @@ // No need to use reflection if reusing the result if (reuseResult && projRow != null) { + /* Make sure we reset the current row based on the re-used + * result. Otherwise, if the "current row" for this result + * set was nulled out in a previous call to getNextRow(), + * which can happen if this node is the right-side of + * a left outer join, the "current row" stored for this + * result set in activation.row would remain null, which + * would be wrong. DERBY-3538. + */ + setCurrentRow(projRow); return projRow; } Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/joins.out URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/joins.out?rev=639316&r1=639315&r2=639316&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/joins.out (original) +++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/joins.out Thu Mar 20 08:31:50 2008 @@ -366,6 +366,23 @@ ----------------------------------------------------------------------- 1 |1 |1 |1 |1 |2 7 |7 |8 |9 |1 |3 +ij> -- DERBY-3538 NullPointerException during execution for query with LEFT +-- OUTER JOIN whose inner table selects all constants. +create table t3538 (i int, j int); +0 rows inserted/updated/deleted +ij> insert into t3538 values (-1, -2), (-2, -4), (-3, -9); +3 rows inserted/updated/deleted +ij> select * from +t3538 left outer join + (select -1 a, 1 b from t3538) x0 --DERBY-PROPERTIES joinStrategy=NESTEDLOOP + on x0.a = t3538.i; +I |J |A |B +----------------------------------------------- +-1 |-2 |-1 |1 +-1 |-2 |-1 |1 +-1 |-2 |-1 |1 +-2 |-4 |NULL |NULL +-3 |-9 |NULL |NULL ij> ----------------------------------- -- clean up ---------------------------------- @@ -390,5 +407,7 @@ ij> drop table x; 0 rows inserted/updated/deleted ij> drop table y; +0 rows inserted/updated/deleted +ij> drop table t3538; 0 rows inserted/updated/deleted ij> Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql?rev=639316&r1=639315&r2=639316&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql (original) +++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql Thu Mar 20 08:31:50 2008 @@ -170,6 +170,17 @@ from D join ((B join C on b2=c2) right outer join A on a1=b1) on d3=b3 and d1=a2; + +-- DERBY-3538 NullPointerException during execution for query with LEFT +-- OUTER JOIN whose inner table selects all constants. +create table t3538 (i int, j int); +insert into t3538 values (-1, -2), (-2, -4), (-3, -9); + +select * from +t3538 left outer join + (select -1 a, 1 b from t3538) x0 --DERBY-PROPERTIES joinStrategy=NESTEDLOOP + on x0.a = t3538.i; + ----------------------------------- -- clean up ---------------------------------- @@ -184,3 +195,5 @@ drop table instab; drop table x; drop table y; +drop table t3538; +