Skip to content

Commit 1ecd363

Browse files
committed
Fix #9063: Incorrect results for DISTINCT used together with IN/EXISTS which is converted into a semi-join
1 parent 6e769db commit 1ecd363

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/jrd/RecordSourceNodes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,14 +3638,17 @@ RseNode* RseNode::processPossibleJoins(thread_db* tdbb, CompilerScratch* csb)
36383638
fb_assert(specialJoins.hasData());
36393639

36403640
// Create joins between the original node and detected joinable nodes.
3641-
// Preserve FIRST/SKIP nodes at their original position, i.e. outside semi-joins.
3641+
// Preserve FIRST/SKIP/DISTINCT nodes at their original position, i.e. outside semi-joins.
36423642

36433643
const auto first = rse_first;
36443644
rse_first = nullptr;
36453645

36463646
const auto skip = rse_skip;
36473647
rse_skip = nullptr;
36483648

3649+
const auto projection = rse_projection;
3650+
rse_projection = nullptr;
3651+
36493652
const auto orgFlags = flags;
36503653
flags = 0;
36513654

@@ -3666,7 +3669,7 @@ RseNode* RseNode::processPossibleJoins(thread_db* tdbb, CompilerScratch* csb)
36663669
rse = newRse;
36673670
}
36683671

3669-
if (first || skip)
3672+
if (first || skip || projection)
36703673
{
36713674
const auto newRse = FB_NEW_POOL(*tdbb->getDefaultPool())
36723675
RseNode(*tdbb->getDefaultPool());
@@ -3675,6 +3678,7 @@ RseNode* RseNode::processPossibleJoins(thread_db* tdbb, CompilerScratch* csb)
36753678
newRse->rse_jointype = INNER_JOIN;
36763679
newRse->rse_first = first;
36773680
newRse->rse_skip = skip;
3681+
newRse->rse_projection = projection;
36783682

36793683
rse = newRse;
36803684
}

0 commit comments

Comments
 (0)