db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r411428 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/fun...
Date Sat, 03 Jun 2006 13:00:51 GMT
Author: kahatlen
Date: Sat Jun  3 06:00:50 2006
New Revision: 411428

URL: http://svn.apache.org/viewvc?rev=411428&view=rev
Log:
DERBY-1356: Positioned update/delete when positioned after last or
before first causes NullPointerException

Patch contributed by Fernanda Pizzorno <Fernanda.Pizzorno@Sun.COM>.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SURTest_ij.out
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/SURTest_ij.out
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij.sql
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij_app.properties
  (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?rev=411428&r1=411427&r2=411428&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
Sat Jun  3 06:00:50 2006
@@ -1124,10 +1124,13 @@
 	 * @exception StandardException on error
 	 */
 	public boolean isDeleted() throws StandardException  {
-		positionInHashTable.setValue(currentPosition);
-		DataValueDescriptor[] hashRowArray = (DataValueDescriptor[]) 
-				ht.get(positionInHashTable);
-		return hashRowArray[POS_ROWDELETED].getBoolean();
+		if (currentPosition <= positionInSource && currentPosition > 0) {
+			positionInHashTable.setValue(currentPosition);
+			DataValueDescriptor[] hashRowArray = (DataValueDescriptor[]) 
+					ht.get(positionInHashTable);
+			return hashRowArray[POS_ROWDELETED].getBoolean();
+		}
+		return false;
 	}
 
 	/**
@@ -1139,10 +1142,13 @@
 	 * @exception StandardException on error
 	 */
 	public boolean isUpdated() throws StandardException {
-		positionInHashTable.setValue(currentPosition);
-		DataValueDescriptor[] hashRowArray = (DataValueDescriptor[]) 
-				ht.get(positionInHashTable);
-		return hashRowArray[POS_ROWUPDATED].getBoolean();			
+		if (currentPosition <= positionInSource && currentPosition > 0) {
+			positionInHashTable.setValue(currentPosition);
+			DataValueDescriptor[] hashRowArray = (DataValueDescriptor[]) 
+					ht.get(positionInHashTable);
+			return hashRowArray[POS_ROWUPDATED].getBoolean();
+		}
+		return false;
 	}
 
 	public boolean isForUpdate() {

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SURTest_ij.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SURTest_ij.out?rev=411428&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SURTest_ij.out
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SURTest_ij.out
Sat Jun  3 06:00:50 2006
@@ -0,0 +1,161 @@
+CONNECTION0* - 	jdbc:derby://xxxFILTERED_HOSTNAMExxx:1527/SURTest;create=true
+* = current connection
+ij> connect 'SURTest;create=true;';
+ij(CONNECTION1)> autocommit off;
+ij(CONNECTION1)> create table t1 (c1 int primary key, c2 int);
+0 rows inserted/updated/deleted
+ij(CONNECTION1)> insert into t1 values 
+    (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), 
+    (6, 6), (7, 7), (8, 8), (9, 9), (10, 10);
+10 rows inserted/updated/deleted
+ij(CONNECTION1)> get scroll insensitive cursor sc1 as 'SELECT * FROM t1 FOR UPDATE';
+ij(CONNECTION1)> next sc1;
+C1 |C2         
+-----
+1 |1          
+ij(CONNECTION1)> next sc1;
+C1 |C2         
+-----
+2 |2          
+ij(CONNECTION1)> -- update row nr. 2 after positioning with next
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> absolute 5 sc1;
+C1 |C2         
+-----
+5 |5          
+ij(CONNECTION1)> -- update row nr. 5 after positioning with absolute
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative 2 sc1;
+C1 |C2         
+-----
+7 |7          
+ij(CONNECTION1)> -- update row nr. 7 after positioning with relative
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> previous sc1;
+C1 |C2         
+-----
+6 |6          
+ij(CONNECTION1)> -- update row nr. 6 after positioning with previous
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative -1 sc1;
+C1 |C2         
+-----
+5 |25         
+ij(CONNECTION1)> last sc1;
+C1 |C2         
+-----
+10 |10         
+ij(CONNECTION1)> -- update row nr. 10 after positioning with last
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> after last sc1;
+No current row
+ij(CONNECTION1)> -- update when positioned after last should cause an error
+update t1 set c2 = c1 + 20 where current of sc1;
+ERROR XCL08: Cursor 'SQL_CURLH000C1' is not on a row.
+ij(CONNECTION1)> first sc1;
+C1 |C2         
+-----
+1 |1          
+ij(CONNECTION1)> -- update row nr. 1 after positioning with first
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> before first sc1;
+No current row
+ij(CONNECTION1)> -- update when positioned before first should cause an error
+update t1 set c2 = c1 + 20 where current of sc1;
+ERROR XCL08: Cursor 'SQL_CURLH000C1' is not on a row.
+ij(CONNECTION1)> close sc1;
+ij(CONNECTION1)> commit;
+ij(CONNECTION1)> -- check that row where correctly updated
+select * from t1;
+C1 |C2         
+-----
+1 |21         
+2 |22         
+3 |3          
+4 |4          
+5 |25         
+6 |26         
+7 |27         
+8 |8          
+9 |9          
+10 |30         
+10 rows selected
+ij(CONNECTION1)> get scroll insensitive cursor sc1 as 'SELECT * FROM t1 FOR UPDATE';
+ij(CONNECTION1)> next sc1;
+C1 |C2         
+-----
+1 |21         
+ij(CONNECTION1)> next sc1;
+C1 |C2         
+-----
+2 |22         
+ij(CONNECTION1)> -- delete row nr. 2 after positioning with next
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> absolute 5 sc1;
+C1 |C2         
+-----
+5 |25         
+ij(CONNECTION1)> -- delete row nr. 5 after positioning with absolute
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative 2 sc1;
+C1 |C2         
+-----
+7 |27         
+ij(CONNECTION1)> -- delete row nr. 7 after positioning with relative
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> previous sc1;
+C1 |C2         
+-----
+6 |26         
+ij(CONNECTION1)> -- delete row nr. 6 after positioning with previous
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative -1 sc1;
+C1 |C2         
+-----
+NULL |NULL       
+ij(CONNECTION1)> last sc1;
+C1 |C2         
+-----
+10 |30         
+ij(CONNECTION1)> -- delete row nr. 10 after positioning with last
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> after last sc1;
+No current row
+ij(CONNECTION1)> -- delete when positioned after last should cause an error
+delete from t1 where current of sc1;
+ERROR XCL08: Cursor 'SQL_CURLH000C1' is not on a row.
+ij(CONNECTION1)> first sc1;
+C1 |C2         
+-----
+1 |21         
+ij(CONNECTION1)> -- delete row nr. 1 after positioning with first
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> before first sc1;
+No current row
+ij(CONNECTION1)> -- delete when positioned before first should cause an error
+delete from t1 where current of sc1;
+ERROR XCL08: Cursor 'SQL_CURLH000C1' is not on a row.
+ij(CONNECTION1)> close sc1;
+ij(CONNECTION1)> commit;
+ij(CONNECTION1)> -- check that row where correctly updated
+select * from t1;
+C1 |C2         
+-----
+3 |3          
+4 |4          
+8 |8          
+9 |9          
+4 rows selected
+ij(CONNECTION1)> 

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SURTest_ij.out
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/SURTest_ij.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/SURTest_ij.out?rev=411428&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/SURTest_ij.out
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/SURTest_ij.out
Sat Jun  3 06:00:50 2006
@@ -0,0 +1,162 @@
+CONNECTION0* - 	jdbc:derby:SURTest
+* = current connection
+ij> connect 'SURTest;create=true;';
+WARNING 01J01: Database 'SURTest' not created, connection made to existing database instead.
+ij(CONNECTION1)> autocommit off;
+ij(CONNECTION1)> create table t1 (c1 int primary key, c2 int);
+0 rows inserted/updated/deleted
+ij(CONNECTION1)> insert into t1 values 
+    (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), 
+    (6, 6), (7, 7), (8, 8), (9, 9), (10, 10);
+10 rows inserted/updated/deleted
+ij(CONNECTION1)> get scroll insensitive cursor sc1 as 'SELECT * FROM t1 FOR UPDATE';
+ij(CONNECTION1)> next sc1;
+C1         |C2         
+-----------------------
+1          |1          
+ij(CONNECTION1)> next sc1;
+C1         |C2         
+-----------------------
+2          |2          
+ij(CONNECTION1)> -- update row nr. 2 after positioning with next
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> absolute 5 sc1;
+C1         |C2         
+-----------------------
+5          |5          
+ij(CONNECTION1)> -- update row nr. 5 after positioning with absolute
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative 2 sc1;
+C1         |C2         
+-----------------------
+7          |7          
+ij(CONNECTION1)> -- update row nr. 7 after positioning with relative
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> previous sc1;
+C1         |C2         
+-----------------------
+6          |6          
+ij(CONNECTION1)> -- update row nr. 6 after positioning with previous
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative -1 sc1;
+C1         |C2         
+-----------------------
+5          |25         
+ij(CONNECTION1)> last sc1;
+C1         |C2         
+-----------------------
+10         |10         
+ij(CONNECTION1)> -- update row nr. 10 after positioning with last
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> after last sc1;
+No current row
+ij(CONNECTION1)> -- update when positioned after last should cause an error
+update t1 set c2 = c1 + 20 where current of sc1;
+ERROR XCL08: Cursor 'SC1' is not on a row.
+ij(CONNECTION1)> first sc1;
+C1         |C2         
+-----------------------
+1          |1          
+ij(CONNECTION1)> -- update row nr. 1 after positioning with first
+update t1 set c2 = c1 + 20 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> before first sc1;
+No current row
+ij(CONNECTION1)> -- update when positioned before first should cause an error
+update t1 set c2 = c1 + 20 where current of sc1;
+ERROR XCL08: Cursor 'SC1' is not on a row.
+ij(CONNECTION1)> close sc1;
+ij(CONNECTION1)> commit;
+ij(CONNECTION1)> -- check that row where correctly updated
+select * from t1;
+C1         |C2         
+-----------------------
+1          |21         
+2          |22         
+3          |3          
+4          |4          
+5          |25         
+6          |26         
+7          |27         
+8          |8          
+9          |9          
+10         |30         
+10 rows selected
+ij(CONNECTION1)> get scroll insensitive cursor sc1 as 'SELECT * FROM t1 FOR UPDATE';
+ij(CONNECTION1)> next sc1;
+C1         |C2         
+-----------------------
+1          |21         
+ij(CONNECTION1)> next sc1;
+C1         |C2         
+-----------------------
+2          |22         
+ij(CONNECTION1)> -- delete row nr. 2 after positioning with next
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> absolute 5 sc1;
+C1         |C2         
+-----------------------
+5          |25         
+ij(CONNECTION1)> -- delete row nr. 5 after positioning with absolute
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative 2 sc1;
+C1         |C2         
+-----------------------
+7          |27         
+ij(CONNECTION1)> -- delete row nr. 7 after positioning with relative
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> previous sc1;
+C1         |C2         
+-----------------------
+6          |26         
+ij(CONNECTION1)> -- delete row nr. 6 after positioning with previous
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> relative -1 sc1;
+C1         |C2         
+-----------------------
+NULL       |NULL       
+ij(CONNECTION1)> last sc1;
+C1         |C2         
+-----------------------
+10         |30         
+ij(CONNECTION1)> -- delete row nr. 10 after positioning with last
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> after last sc1;
+No current row
+ij(CONNECTION1)> -- delete when positioned after last should cause an error
+delete from t1 where current of sc1;
+ERROR XCL08: Cursor 'SC1' is not on a row.
+ij(CONNECTION1)> first sc1;
+C1         |C2         
+-----------------------
+1          |21         
+ij(CONNECTION1)> -- delete row nr. 1 after positioning with first
+delete from t1 where current of sc1;
+1 row inserted/updated/deleted
+ij(CONNECTION1)> before first sc1;
+No current row
+ij(CONNECTION1)> -- delete when positioned before first should cause an error
+delete from t1 where current of sc1;
+ERROR XCL08: Cursor 'SC1' is not on a row.
+ij(CONNECTION1)> close sc1;
+ij(CONNECTION1)> commit;
+ij(CONNECTION1)> -- check that row where correctly updated
+select * from t1;
+C1         |C2         
+-----------------------
+3          |3          
+4          |4          
+8          |8          
+9          |9          
+4 rows selected
+ij(CONNECTION1)> 

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/SURTest_ij.out
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude?rev=411428&r1=411427&r2=411428&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
Sat Jun  3 06:00:50 2006
@@ -46,3 +46,4 @@
 # Excluding checkDataSource and checkDataSource30 because JCC has no XA
 jdbcapi/checkDataSource30.java
 jdbcapi/checkDataSource.java
+jdbcapi/SURTest_ij.sql

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall?rev=411428&r1=411427&r2=411428&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
Sat Jun  3 06:00:50 2006
@@ -25,3 +25,4 @@
 jdbcapi/SURQueryMixTest.junit
 jdbcapi/SURTest.junit
 jdbcapi/URCoveringIndexTest.junit
+jdbcapi/SURTest_ij.sql

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij.sql?rev=411428&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij.sql
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij.sql
Sat Jun  3 06:00:50 2006
@@ -0,0 +1,68 @@
+connect 'SURTest;create=true;';
+autocommit off;
+create table t1 (c1 int primary key, c2 int);
+insert into t1 values 
+    (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), 
+    (6, 6), (7, 7), (8, 8), (9, 9), (10, 10);
+get scroll insensitive cursor sc1 as 'SELECT * FROM t1 FOR UPDATE';
+next sc1;
+next sc1;
+-- update row nr. 2 after positioning with next
+update t1 set c2 = c1 + 20 where current of sc1;
+absolute 5 sc1;
+-- update row nr. 5 after positioning with absolute
+update t1 set c2 = c1 + 20 where current of sc1;
+relative 2 sc1;
+-- update row nr. 7 after positioning with relative
+update t1 set c2 = c1 + 20 where current of sc1;
+previous sc1;
+-- update row nr. 6 after positioning with previous
+update t1 set c2 = c1 + 20 where current of sc1;
+relative -1 sc1;
+last sc1;
+-- update row nr. 10 after positioning with last
+update t1 set c2 = c1 + 20 where current of sc1;
+after last sc1;
+-- update when positioned after last should cause an error
+update t1 set c2 = c1 + 20 where current of sc1;
+first sc1;
+-- update row nr. 1 after positioning with first
+update t1 set c2 = c1 + 20 where current of sc1;
+before first sc1;
+-- update when positioned before first should cause an error
+update t1 set c2 = c1 + 20 where current of sc1;
+close sc1;
+commit;
+-- check that row where correctly updated
+select * from t1;
+get scroll insensitive cursor sc1 as 'SELECT * FROM t1 FOR UPDATE';
+next sc1;
+next sc1;
+-- delete row nr. 2 after positioning with next
+delete from t1 where current of sc1;
+absolute 5 sc1;
+-- delete row nr. 5 after positioning with absolute
+delete from t1 where current of sc1;
+relative 2 sc1;
+-- delete row nr. 7 after positioning with relative
+delete from t1 where current of sc1;
+previous sc1;
+-- delete row nr. 6 after positioning with previous
+delete from t1 where current of sc1;
+relative -1 sc1;
+last sc1;
+-- delete row nr. 10 after positioning with last
+delete from t1 where current of sc1;
+after last sc1;
+-- delete when positioned after last should cause an error
+delete from t1 where current of sc1;
+first sc1;
+-- delete row nr. 1 after positioning with first
+delete from t1 where current of sc1;
+before first sc1;
+-- delete when positioned before first should cause an error
+delete from t1 where current of sc1;
+close sc1;
+commit;
+-- check that row where correctly updated
+select * from t1;

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij.sql
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij_app.properties?rev=411428&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij_app.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij_app.properties
Sat Jun  3 06:00:50 2006
@@ -0,0 +1,2 @@
+ij.protocol=jdbc:derby:
+ij.database=SURTest;create=true;

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest_ij_app.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message