Skip to content

Commit 92316f0

Browse files
committed
Temporary fix for #8265: Nested IN/EXISTS subqueries should not be converted into semi-joins if the outer context is a sub-query which wasn't unnested
1 parent aae2ae3 commit 92316f0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/jrd/RecordSourceNodes.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,6 +3259,23 @@ RseNode* RseNode::processPossibleJoins(thread_db* tdbb, CompilerScratch* csb)
32593259
if (!dbb->dbb_config->getSubQueryConversion())
32603260
return nullptr;
32613261

3262+
// If the sub-query is nested inside the other sub-query which wasn't converted into semi-join,
3263+
// it makes no sense to apply a semi-join at the deeper levels, as a sub-query is expected
3264+
// to be executed repeatedly.
3265+
// This is a temporary fix until nested loop semi-joins are allowed by the optimizer.
3266+
3267+
if (flags & FLAG_SUB_QUERY)
3268+
return nullptr;
3269+
3270+
for (const auto node : csb->csb_current_nodes)
3271+
{
3272+
if (const auto rse = nodeAs<RseNode>(node))
3273+
{
3274+
if (rse->flags & FLAG_SUB_QUERY)
3275+
return nullptr;
3276+
}
3277+
}
3278+
32623279
RecordSourceNodeStack rseStack;
32633280
BoolExprNodeStack booleanStack;
32643281

0 commit comments

Comments
 (0)