db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
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 GMT
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;



Mime
View raw message