Skip to content

The sub-query conversion keeps a nested outer reference - #9334

Closed
sim1984 wants to merge 2 commits into
FirebirdSQL:v5.0-releasefrom
sim1984:work/sub-query-fix
Closed

sim1984 wants to merge 2 commits into
FirebirdSQL:v5.0-releasefrom
sim1984:work/sub-query-fix

Conversation

@sim1984

@sim1984 sim1984 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes the bug described in #9333

With SubQueryConversion = true a correlated EXISTS / IN sub-query became a semi-join even when it referred to an outer stream only from inside a nested record source (a derived table, an aggregate, a union, a window, DISTINCT or ORDER BY). rse->collectStreams() does not walk these parts. The inner side was evaluated without the outer record and the query returned a wrong result.

findPossibleJoins() now checks the sub-query with collectAllStreams().
findDependentBooleans() does not take an equality that refers to an outer stream or to a stream of the sub-query itself only through a nested record source.

Plain correlated EXISTS / IN sub-queries are converted as before.

@sim1984 sim1984 closed this Nov 21, 2026
@sim1984
sim1984 deleted the work/sub-query-fix branch November 21, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant