db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1067223 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/execute/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 04 Feb 2011 17:01:54 GMT
Author: mikem
Date: Fri Feb  4 17:01:54 2011
New Revision: 1067223

URL: http://svn.apache.org/viewvc?rev=1067223&view=rev
Log:
DERBY-4585 IndexChanger.doDelete throws NullPointerException

Make sure the cached index scan is not cleared too early by a result
set that doesn't use it. 

backporting fix (#931076) by kahatlen from trunk to 10.5 branch.


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/delete.out
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/delete.sql

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  4 17:01:54 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.6:942027,957000,962738,965351,987678,1055601
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291,1002682,1002853,102142
 6,1025795,1040658,1053724,1055169,1062096,1063809,1065061
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291,1002682,1002853
 ,1021426,1025795,1040658,1053724,1055169,1062096,1063809,1065061

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java?rev=1067223&r1=1067222&r2=1067223&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
Fri Feb  4 17:01:54 2011
@@ -682,7 +682,15 @@ class TableScanResultSet extends ScanRes
 				}
 	        	scanController.close();
 				scanController = null; // should not access after close
-				activation.clearIndexScanInfo();
+
+                // Updatable index scans are cached in the activation for
+                // easy access from IndexChanger. Remember to clear the cached
+                // info here, but only if this is the result set that cached
+                // it in the first place (DERBY-4585).
+                if (forUpdate && isKeyed) {
+                    activation.clearIndexScanInfo();
+                }
+
 			}
 			scanControllerOpened = false;
 			startPosition = null;

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/delete.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/delete.out?rev=1067223&r1=1067222&r2=1067223&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/delete.out
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/delete.out
Fri Feb  4 17:01:54 2011
@@ -314,4 +314,53 @@ drop table bug171_employee;
 0 rows inserted/updated/deleted
 ij> drop table bug171_bonuses;
 0 rows inserted/updated/deleted
+ij> --
+-- Test case for DERBY-4585
+--
+create table d4585_t1 (id int primary key, a int);
+0 rows inserted/updated/deleted
+ij> create table d4585_t2 (id int primary key, b int,
+                       constraint fk_t2 foreign key (b) references d4585_t1);
+0 rows inserted/updated/deleted
+ij> create table d4585_t3 (id int primary key, c int);
+0 rows inserted/updated/deleted
+ij> create table d4585_t4 (d int references d4585_t2);
+0 rows inserted/updated/deleted
+ij> insert into d4585_t1 values (16,51),(30,12),(39,24),(48,1),(53,46),(61,9);
+6 rows inserted/updated/deleted
+ij> insert into d4585_t2 values
+    (2,16),(3,61),(4,16),(6,30),(7,16),(10,48),(13,30),(15,48),(17,61),
+    (18,30),(21,48),(22,53),(23,61),(25,48),(26,30),(27,48),(29,16),(31,39),
+    (33,30),(35,61),(37,30),(40,53),(42,53),(45,16),(49,30),(54,53),(57,53),
+    (58,61),(60,30),(63,61),(64,30);
+31 rows inserted/updated/deleted
+ij> insert into d4585_t3 values
+    (1,50),(5,50),(8,50),(9,50),(11,36),(12,50),(14,50),(19,50),(20,50),
+    (24,36),(28,50),(32,50),(34,50),(38,50),(41,50),(43,50),(46,36),(47,36),
+    (51,36),(52,50),(55,36),(56,44),(59,36),(62,36);
+24 rows inserted/updated/deleted
+ij> insert into d4585_t4 values (7), (33), (57);
+3 rows inserted/updated/deleted
+ij> -- The query below resulted in a NullPointerException if a certain query plan
+-- was chosen. Use an optimizer override to force that plan.
+delete from d4585_t4 where d in
+  (select id from d4585_t2 --derby-properties constraint=fk_t2
+    where b in (select t1.id
+                       from d4585_t1 t1, d4585_t3 t3
+                       where t1.a=t3.id and t3.c=36));
+2 rows inserted/updated/deleted
+ij> -- Verify that the correct rows were deleted.
+select * from d4585_t4;
+D          
+-----------
+33         
+ij> -- Clean up
+drop table d4585_t4;
+0 rows inserted/updated/deleted
+ij> drop table d4585_t3;
+0 rows inserted/updated/deleted
+ij> drop table d4585_t2;
+0 rows inserted/updated/deleted
+ij> drop table d4585_t1;
+0 rows inserted/updated/deleted
 ij> 

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/delete.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/delete.sql?rev=1067223&r1=1067222&r2=1067223&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/delete.sql
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/delete.sql
Fri Feb  4 17:01:54 2011
@@ -230,3 +230,44 @@ autocommit on;
 
 drop table bug171_employee;
 drop table bug171_bonuses;
+
+--
+-- Test case for DERBY-4585
+--
+create table d4585_t1 (id int primary key, a int);
+create table d4585_t2 (id int primary key, b int,
+                       constraint fk_t2 foreign key (b) references d4585_t1);
+create table d4585_t3 (id int primary key, c int);
+create table d4585_t4 (d int references d4585_t2);
+
+insert into d4585_t1 values (16,51),(30,12),(39,24),(48,1),(53,46),(61,9);
+
+insert into d4585_t2 values
+    (2,16),(3,61),(4,16),(6,30),(7,16),(10,48),(13,30),(15,48),(17,61),
+    (18,30),(21,48),(22,53),(23,61),(25,48),(26,30),(27,48),(29,16),(31,39),
+    (33,30),(35,61),(37,30),(40,53),(42,53),(45,16),(49,30),(54,53),(57,53),
+    (58,61),(60,30),(63,61),(64,30);
+
+insert into d4585_t3 values
+    (1,50),(5,50),(8,50),(9,50),(11,36),(12,50),(14,50),(19,50),(20,50),
+    (24,36),(28,50),(32,50),(34,50),(38,50),(41,50),(43,50),(46,36),(47,36),
+    (51,36),(52,50),(55,36),(56,44),(59,36),(62,36);
+
+insert into d4585_t4 values (7), (33), (57);
+
+-- The query below resulted in a NullPointerException if a certain query plan
+-- was chosen. Use an optimizer override to force that plan.
+delete from d4585_t4 where d in
+  (select id from d4585_t2 --derby-properties constraint=fk_t2
+    where b in (select t1.id
+                       from d4585_t1 t1, d4585_t3 t3
+                       where t1.a=t3.id and t3.c=36));
+
+-- Verify that the correct rows were deleted.
+select * from d4585_t4;
+
+-- Clean up
+drop table d4585_t4;
+drop table d4585_t3;
+drop table d4585_t2;
+drop table d4585_t1;



Mime
View raw message