[ 
https://issues.apache.org/jira/browse/DERBY-4660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12869937#action_12869937
 ] 

Knut Anders Hatlen commented on DERBY-4660:
-------------------------------------------

I think there may be a bug MergeJoinResultSet. We should look into it once we 
have it enabled and can test it.

Here's what I think is wrong: In getNextRowCore() we move forward in the right 
result until we find a row with a key that matches the current row in the left 
result. If that row also satisfies the restriction in 
JoinResultSet.restriction, the row is returned. Otherwise, we move to the next 
row in the left result. But we have no guarantee that there are no more rows in 
the right result that match the current row in the left result, and that do 
satisfy the restriction, even if we found one match that didn't satisfy the 
restriction. So I think we may skip some rows in the right result.

This won't be a problem if the join key is known to be unique in the right 
result, but the comments in the class suggest that only the left result has to 
be unique.

> Expose merge join through optimizer override
> --------------------------------------------
>
>                 Key: DERBY-4660
>                 URL: https://issues.apache.org/jira/browse/DERBY-4660
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.7.0.0
>            Reporter: Knut Anders Hatlen
>            Priority: Minor
>
> Derby comes with a class called MergeJoinResultSet which is not currently 
> used. As a first step towards full support for merge joins, we should expose 
> the functionality provided by this class through an optimizer override, so 
> that we can start testing it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to