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/09/08 16:52:51 UTC
svn commit: r812536 - 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: Tue Sep 8 14:52:50 2009
New Revision: 812536
URL: http://svn.apache.org/viewvc?rev=812536&view=rev
Log:
DERBY-4284: All Columns become Nullable when Using left join
Merged fix from trunk (revision 810860).
Added:
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
- copied unchanged from r810860, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Modified:
db/derby/code/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/FromList.java
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml148.out
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml162.out
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/wisconsin.out
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 8 14:52:50 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
+/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
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/FromList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/FromList.java?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/FromList.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/FromList.java Tue Sep 8 14:52:50 2009
@@ -385,27 +385,6 @@
}
/**
- * Returns true if any Outer joins present. Used to set Nullability
- *
- * @return True if has any outer joins. False otherwise.
- */
- public boolean hasOuterJoins()
- throws StandardException
- {
- FromTable fromTable;
-
- int size = size();
- for (int index = 0; index < size; index++)
- {
- fromTable = (FromTable) elementAt(index);
- if (fromTable instanceof HalfOuterJoinNode)
- return true;
- }
-
- return false;
- }
-
- /**
* Expand a "*" into the appropriate ResultColumnList. If the "*"
* is unqualified it will expand into a list of all columns in all
* of the base tables in the from list at the current nesting level;
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java Tue Sep 8 14:52:50 2009
@@ -572,6 +572,17 @@
throw StandardException.newException(SQLState.LANG_AMBIGUOUS_COLUMN_NAME,
columnReference.getSQLColumnName());
}
+
+ // All columns on the logical right side of a "half" outer join
+ // can contain nulls. The correct nullability is set by
+ // bindResultColumns()/buildRCL(). However, if bindResultColumns()
+ // has not been called yet, the caller of this method will see
+ // the wrong nullability. This problem is logged as DERBY-2916.
+ // Until that's fixed, set the nullability here too.
+ if (this instanceof HalfOuterJoinNode) {
+ rightRC.setNullability(true);
+ }
+
resultColumn = rightRC;
}
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Tue Sep 8 14:52:50 2009
@@ -635,10 +635,6 @@
{
throw StandardException.newException(SQLState.LANG_TOO_MANY_ELEMENTS);
}
-
- /* Fix nullability in case of any outer joins in the fromList */
- if (fromList.hasOuterJoins())
- resultColumns.setNullability(true);
}
/**
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml148.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml148.out?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml148.out (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml148.out Tue Sep 8 14:52:50 2009
@@ -162,13 +162,13 @@
FROM SEVEN_TYPES right outer JOIN HU.STAFF
ON GRADE IN (10, 11, 13) AND EMPNUM = T_CHAR
ORDER BY EMPNAME, T_INT;
-T_INT |T_CHAR |EMPNAME |EMP&|GRADE
-------------------------------------------------------
-NULL |NULL |Alice |E1 |12
-2 |E2 |Betty |E2 |10
-NULL |NULL |Carmen |E3 |13
-NULL |NULL |Don |E4 |12
-NULL |NULL |Ed |E5 |13
+T_INT |T_CHAR |EMPNAME |EM&|GRADE
+-----------------------------------------------------
+NULL |NULL |Alice |E1 |12
+2 |E2 |Betty |E2 |10
+NULL |NULL |Carmen |E3 |13
+NULL |NULL |Don |E4 |12
+NULL |NULL |Ed |E5 |13
ij> -- PASS:0844 If 5 rows selected with ordered rows and column values ?
-- PASS:0844 NULL NULL Alice E1 12 ?
-- PASS:0844 2 E2 Betty E2 10 ?
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml162.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml162.out?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml162.out (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/dml162.out Tue Sep 8 14:52:50 2009
@@ -45,21 +45,21 @@
SELECT * FROM HU.STAFF LEFT OUTER JOIN HU.WORKS
ON (HU.STAFF.EMPNUM=HU.WORKS.EMPNUM);
-EMP&|EMPNAME |GRADE|CITY |EMP&|PNUM|HOURS
-----------------------------------------------------------------
-E1 |Alice |12 |Deale |E1 |P1 |40
-E1 |Alice |12 |Deale |E1 |P2 |20
-E1 |Alice |12 |Deale |E1 |P3 |80
-E1 |Alice |12 |Deale |E1 |P4 |20
-E1 |Alice |12 |Deale |E1 |P5 |12
-E1 |Alice |12 |Deale |E1 |P6 |12
-E2 |Betty |10 |Vienna |E2 |P1 |40
-E2 |Betty |10 |Vienna |E2 |P2 |80
-E3 |Carmen |13 |Vienna |E3 |P2 |20
-E4 |Don |12 |Deale |E4 |P2 |20
-E4 |Don |12 |Deale |E4 |P4 |40
-E4 |Don |12 |Deale |E4 |P5 |80
-E5 |Ed |13 |Akron |NULL|NULL|NULL
+EM&|EMPNAME |GRADE|CITY |EMP&|PNUM|HOURS
+---------------------------------------------------------------
+E1 |Alice |12 |Deale |E1 |P1 |40
+E1 |Alice |12 |Deale |E1 |P2 |20
+E1 |Alice |12 |Deale |E1 |P3 |80
+E1 |Alice |12 |Deale |E1 |P4 |20
+E1 |Alice |12 |Deale |E1 |P5 |12
+E1 |Alice |12 |Deale |E1 |P6 |12
+E2 |Betty |10 |Vienna |E2 |P1 |40
+E2 |Betty |10 |Vienna |E2 |P2 |80
+E3 |Carmen |13 |Vienna |E3 |P2 |20
+E4 |Don |12 |Deale |E4 |P2 |20
+E4 |Don |12 |Deale |E4 |P4 |40
+E4 |Don |12 |Deale |E4 |P5 |80
+E5 |Ed |13 |Akron |NULL|NULL|NULL
ij> -- PASS:0863 If 13 rows are returned?
COMMIT WORK;
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out Tue Sep 8 14:52:50 2009
@@ -136,13 +136,13 @@
NULL
NULL
ij> select a.* from ((values ('a', 'b')) a inner join (values ('c', 'd')) b on 1=1) left outer join (values ('e', 'f')) c on 1=1;
-1 |2
----------
-a |b
+1|2
+---
+a|b
ij> select b.* from ((values ('a', 'b')) a inner join (values ('c', 'd')) b on 1=1) left outer join (values ('e', 'f')) c on 1=1;
-1 |2
----------
-c |d
+1|2
+---
+c|d
ij> select c.* from ((values ('a', 'b')) a inner join (values ('c', 'd')) b on 1=1) left outer join (values ('e', 'f')) c on 1=1;
1 |2
---------
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/wisconsin.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/wisconsin.out?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/wisconsin.out (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/wisconsin.out Tue Sep 8 14:52:50 2009
@@ -28980,11 +28980,9 @@
start position:
>= on first 1 column(s).
Ordered null semantics on the following columns:
-0
stop position:
> on first 1 column(s).
Ordered null semantics on the following columns:
-0
qualifiers:
None
Right result set:
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=812536&r1=812535&r2=812536&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java Tue Sep 8 14:52:50 2009
@@ -69,6 +69,7 @@
suite.addTest(GrantRevokeTest.suite());
suite.addTest(GroupByExpressionTest.suite());
suite.addTest(InsertTest.suite());
+ suite.addTest(JoinTest.suite());
suite.addTest(LangScripts.suite());
suite.addTest(MathTrigFunctionsTest.suite());
suite.addTest(PrepareExecuteDDL.suite());