Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 20601 invoked from network); 8 Jun 2006 18:57:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Jun 2006 18:57:25 -0000 Received: (qmail 59698 invoked by uid 500); 8 Jun 2006 18:57:25 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 59671 invoked by uid 500); 8 Jun 2006 18:57:25 -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 59659 invoked by uid 99); 8 Jun 2006 18:57:24 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 11:57:24 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 11:57:24 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 1AEB41A983A; Thu, 8 Jun 2006 11:57:04 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r412832 - in /db/derby/code/branches/10.1/java: engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java testing/org/apache/derbyTesting/functionTests/master/update.out testing/org/apache/derbyTesting/functionTests/tests/lang/update.sql Date: Thu, 08 Jun 2006 18:57:03 -0000 To: derby-commits@db.apache.org From: bandaram@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060608185704.1AEB41A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: bandaram Date: Thu Jun 8 11:57:02 2006 New Revision: 412832 URL: http://svn.apache.org/viewvc?rev=412832&view=rev Log: DERBY-1329: Set ColumnReference in CurrentOfNode when a match is found. Merging from trunk. Submitted by Army Brown (gozinx@gmail.com) Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/update.out db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/update.sql Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java?rev=412832&r1=412831&r2=412832&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java Thu Jun 8 11:57:02 2006 @@ -346,6 +346,16 @@ if (resultColumn != null) { + // If we found the ResultColumn, set the ColumnReference's + // table number accordingly. Note: we used to only set + // the tableNumber for correlated references (as part of + // changes for DERBY-171) but inspection of code (esp. + // the comments in FromList.bindColumnReferences() and + // the getMatchingColumn() methods on other FromTables) + // suggests that we should always set the table number + // if we've found the ResultColumn. So we do that here. + columnReference.setTableNumber( tableNumber ); + // If there is a result column, are we really updating it? // If so, verify that the column is updatable as well notfound = Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/update.out URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/update.out?rev=412832&r1=412831&r2=412832&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/update.out (original) +++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/update.out Thu Jun 8 11:57:02 2006 @@ -436,4 +436,51 @@ ij> autocommit on; ij> drop table tab1; 0 rows inserted/updated/deleted +ij> -- +-- DERBY-1329: Correlated subquery in UPDATE ... SET ... WHERE CURRENT OF +-- +CREATE TABLE BASICTABLE1(ID INTEGER, C3 CHAR(10)); +0 rows inserted/updated/deleted +ij> CREATE TABLE BASICTABLE2(IID INTEGER, CC3 CHAR(10)); +0 rows inserted/updated/deleted +ij> insert into BASICTABLE1 (C3, ID) values ('abc', 1); +1 row inserted/updated/deleted +ij> insert into BASICTABLE2 (CC3, IID) values ('def', 1); +1 row inserted/updated/deleted +ij> -- Check data. +select * from BASICTABLE1; +ID |C3 +---------------------- +1 |abc +ij> select * from BASICTABLE2; +IID |CC3 +---------------------- +1 |def +ij> autocommit off; +ij> get cursor c1 as 'select c3, id from basictable1 for update'; +ij> next c1; +C3 |ID +---------------------- +abc |1 +ij> -- Before fix for DERBY-1329 the following statement would fail with +-- an ASSERT failure or an IndexOutOfBoundsException; after the fix +-- the statement should succeed and the update as well. +update BASICTABLE1 set C3 = (SELECT CC3 FROM BASICTABLE2 + WHERE BASICTABLE1.ID=BASICTABLE2.IID) where current of c1; +1 row inserted/updated/deleted +ij> -- Check data; BASICTABLE1 should have been updated. +select * from BASICTABLE1; +ID |C3 +---------------------- +1 |def +ij> select * from BASICTABLE2; +IID |CC3 +---------------------- +1 |def +ij> -- Cleanup. +rollback; +ij> drop table BASICTABLE1; +0 rows inserted/updated/deleted +ij> drop table BASICTABLE2; +0 rows inserted/updated/deleted ij> Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/update.sql URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/update.sql?rev=412832&r1=412831&r2=412832&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/update.sql (original) +++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/update.sql Thu Jun 8 11:57:02 2006 @@ -251,3 +251,34 @@ autocommit on; drop table tab1; + +-- +-- DERBY-1329: Correlated subquery in UPDATE ... SET ... WHERE CURRENT OF +-- +CREATE TABLE BASICTABLE1(ID INTEGER, C3 CHAR(10)); +CREATE TABLE BASICTABLE2(IID INTEGER, CC3 CHAR(10)); +insert into BASICTABLE1 (C3, ID) values ('abc', 1); +insert into BASICTABLE2 (CC3, IID) values ('def', 1); + +-- Check data. +select * from BASICTABLE1; +select * from BASICTABLE2; + +autocommit off; +get cursor c1 as 'select c3, id from basictable1 for update'; +next c1; + +-- Before fix for DERBY-1329 the following statement would fail with +-- an ASSERT failure or an IndexOutOfBoundsException; after the fix +-- the statement should succeed and the update as well. +update BASICTABLE1 set C3 = (SELECT CC3 FROM BASICTABLE2 + WHERE BASICTABLE1.ID=BASICTABLE2.IID) where current of c1; + +-- Check data; BASICTABLE1 should have been updated. +select * from BASICTABLE1; +select * from BASICTABLE2; + +-- Cleanup. +rollback; +drop table BASICTABLE1; +drop table BASICTABLE2;