jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1433915 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ oak-jcr/
Date Wed, 16 Jan 2013 12:38:30 GMT
Author: thomasm
Date: Wed Jan 16 12:38:30 2013
New Revision: 1433915

URL: http://svn.apache.org/viewvc?rev=1433915&view=rev
Log:
OAK-559 Outer join can produce wrong result

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java?rev=1433915&r1=1433914&r2=1433915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
Wed Jan 16 12:38:30 2013
@@ -78,7 +78,8 @@ public class JoinImpl extends SourceImpl
             right.addJoinCondition(joinCondition, true);
             break;
         case LEFT_OUTER:
-            right.setOuterJoin(true);
+            left.setOuterJoin(true, false);
+            right.setOuterJoin(false, true);
             left.addJoinCondition(joinCondition, false);
             right.addJoinCondition(joinCondition, true);
             break;
@@ -90,7 +91,8 @@ public class JoinImpl extends SourceImpl
             SourceImpl temp = left;
             left = right;
             right = temp;
-            right.setOuterJoin(true);
+            left.setOuterJoin(true, false);
+            right.setOuterJoin(false, true);
             left.addJoinCondition(joinCondition, false);
             right.addJoinCondition(joinCondition, true);
             break;
@@ -157,7 +159,7 @@ public class JoinImpl extends SourceImpl
             }
             // for an outer join, if no matching result was found,
             // one row returned (with all values set to null)
-            if (right.outerJoin && leftNeedNext && !foundJoinedRow) {
+            if (right.outerJoinRightHandSide && leftNeedNext && !foundJoinedRow)
{
                 return true;
             }
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java?rev=1433915&r1=1433914&r2=1433915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
Wed Jan 16 12:38:30 2013
@@ -52,7 +52,7 @@ public class NotImpl extends ConstraintI
 
     @Override
     public void restrict(FilterImpl f) {
-        if (f.getSelector().outerJoin) {
+        if (f.getSelector().outerJoinRightHandSide) {
             // we need to be careful with the condition 
             // "NOT (property IS NOT NULL)"
             // (which is the same as 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1433915&r1=1433914&r2=1433915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Wed Jan 16 12:38:30 2013
@@ -101,8 +101,10 @@ public class SelectorImpl extends Source
         if (queryConstraint != null) {
             queryConstraint.restrictPushDown(this);
         }
-        for (JoinConditionImpl c : allJoinConditions) {
-            c.restrictPushDown(this);
+        if (!outerJoinLeftHandSide && !outerJoinRightHandSide) {
+            for (JoinConditionImpl c : allJoinConditions) {
+                c.restrictPushDown(this);
+            }
         }
         index = query.getBestIndex(createFilter());
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java?rev=1433915&r1=1433914&r2=1433915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
Wed Jan 16 12:38:30 2013
@@ -57,12 +57,18 @@ public abstract class SourceImpl extends
     protected boolean join;
 
     /**
-     * Whether this selector is the right hand side of a left outer join.
+     * Whether this selector is the left hand side of a left outer join.
      * Right outer joins are converted to left outer join.
      */
-    protected boolean outerJoin;
+    protected boolean outerJoinLeftHandSide;
 
     /**
+     * Whether this selector is the right hand side of a left outer join.
+     * Right outer joins are converted to left outer join.
+     */
+    protected boolean outerJoinRightHandSide;
+    
+    /**
      * Set the complete constraint of the query (the WHERE ... condition).
      *
      * @param queryConstraint the constraint
@@ -86,12 +92,14 @@ public abstract class SourceImpl extends
     }
 
     /**
-     * Set whether this source is the right hand side of a left outer join.
+     * Set whether this source is the left hand side or right hand side of a left outer join.
      *
-     * @param outerJoin true if yes
+     * @param outerJoinLeftHandSide true if yes
+     * @param outerJoinRightHandSide true if yes
      */
-    public void setOuterJoin(boolean outerJoin) {
-        this.outerJoin = outerJoin;
+    public void setOuterJoin(boolean outerJoinLeftHandSide, boolean outerJoinRightHandSide)
{
+        this.outerJoinLeftHandSide = outerJoinLeftHandSide;
+        this.outerJoinRightHandSide = outerJoinRightHandSide;
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1433915&r1=1433914&r2=1433915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Jan 16 12:38:30 2013
@@ -201,6 +201,8 @@
       org.apache.jackrabbit.test.api.query.qom.ColumnTest#testExpandColumnsForNodeType  
            <!-- OAK-323 -->
       org.apache.jackrabbit.test.api.query.GetPropertyNamesTest#testGetPropertyNames    
            <!-- OAK-323 -->
       org.apache.jackrabbit.test.api.query.qom.SelectorTest#testUnknownNodeType         
            <!-- OAK-476 -->
+      org.apache.jackrabbit.test.api.query.qom.EquiJoinConditionTest#testRightOuterJoin1
<!-- bug in test case, see OAK-559 -->
+      org.apache.jackrabbit.test.api.query.qom.EquiJoinConditionTest#testLeftOuterJoin2 <!--
bug in test case, see OAK-559 -->
       org.apache.jackrabbit.test.api.observation.EventTest#testGetUserId
       org.apache.jackrabbit.test.api.observation.NodeMovedTest#testMoveNode
       org.apache.jackrabbit.test.api.observation.NodeMovedTest#testMoveTree



Mime
View raw message