You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2009/10/15 11:46:01 UTC

svn commit: r825450 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/compile/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/

Author: kahatlen
Date: Thu Oct 15 09:46:00 2009
New Revision: 825450

URL: http://svn.apache.org/viewvc?rev=825450&view=rev
Log:
DERBY-4388: NullPointerException in RIGHT JOIN with NOT BETWEEN

Ported fix from trunk (revision 822289).

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

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 15 09:46:00 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,823659,824694
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java?rev=825450&r1=825449&r2=825450&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java Thu Oct 15 09:46:00 2009
@@ -127,11 +127,17 @@
 		/* Set type info for the operator node */
 		leftBCO.bindComparisonOperator();
 
+        // DERBY-4388: If leftOperand is a ColumnReference, it may be remapped
+        // during optimization, and that requires the less-than node and the
+        // greater-than node to have separate objects.
+        ValueNode leftClone = (leftOperand instanceof ColumnReference) ?
+            leftOperand.getClone() : leftOperand;
+
 		/* leftO > rightOList.elementAt(1) */
 		rightBCO = (BinaryComparisonOperatorNode) 
 					nodeFactory.getNode(
 								C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE,
-								leftOperand, 
+								leftClone,
 								rightOperandList.elementAt(1),
 								cm);
 		/* Set type info for the operator node */

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/inbetween.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/inbetween.out?rev=825450&r1=825449&r2=825450&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/inbetween.out (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/inbetween.out Thu Oct 15 09:46:00 2009
@@ -2375,4 +2375,25 @@
 0 rows inserted/updated/deleted
 ij> drop table t2;
 0 rows inserted/updated/deleted
+ij> create table t1(a int);
+0 rows inserted/updated/deleted
+ij> create table t2(b int);
+0 rows inserted/updated/deleted
+ij> insert into t1 values 0,1,2,3,4,5,6;
+7 rows inserted/updated/deleted
+ij> insert into t2 values 0,1,2,3;
+4 rows inserted/updated/deleted
+ij> --the next two statements failed with NPE before DERBY-4388
+select * from t1 left join t2 on a=b where b not between 1 and 5;
+A          |B          
+-----------------------
+0          |0          
+ij> select * from t2 right join t1 on a=b where b not between 1 and 5;
+B          |A          
+-----------------------
+0          |0          
+ij> drop table t1;
+0 rows inserted/updated/deleted
+ij> drop table t2;
+0 rows inserted/updated/deleted
 ij> 

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/inbetween.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/inbetween.sql?rev=825450&r1=825449&r2=825450&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/inbetween.sql (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/inbetween.sql Thu Oct 15 09:46:00 2009
@@ -935,3 +935,13 @@
 drop view v1;
 drop table t1;
 drop table t2;
+
+create table t1(a int);
+create table t2(b int);
+insert into t1 values 0,1,2,3,4,5,6;
+insert into t2 values 0,1,2,3;
+--the next two statements failed with NPE before DERBY-4388
+select * from t1 left join t2 on a=b where b not between 1 and 5;
+select * from t2 right join t1 on a=b where b not between 1 and 5;
+drop table t1;
+drop table t2;