@@ -55,7 +55,7 @@ static ValueExprNode* resolveUsingField(DsqlCompilerScratch* dsqlScratch, const
55
55
namespace
56
56
{
57
57
// Search through the list of ANDed booleans to find comparisons
58
- // referring streams of other select expressions .
58
+ // referring streams of the parent select expression .
59
59
// Extract those booleans and return them to the caller.
60
60
61
61
bool findDependentBooleans (CompilerScratch* csb,
@@ -92,7 +92,7 @@ namespace
92
92
93
93
for (const auto stream : streams)
94
94
{
95
- if (! rseStreams.exist (stream))
95
+ if (rseStreams.exist (stream))
96
96
{
97
97
booleanStack.push (boolean);
98
98
*parentBoolean = nullptr ;
@@ -109,6 +109,7 @@ namespace
109
109
// They are candidates to be converted into semi- or anti-joins.
110
110
111
111
bool findPossibleJoins (CompilerScratch* csb,
112
+ const StreamList& rseStreams,
112
113
BoolExprNode** parentBoolean,
113
114
RecordSourceNodeStack& rseStack,
114
115
BoolExprNodeStack& booleanStack)
@@ -118,10 +119,10 @@ namespace
118
119
const auto binaryNode = nodeAs<BinaryBoolNode>(boolNode);
119
120
if (binaryNode && binaryNode->blrOp == blr_and)
120
121
{
121
- const bool found1 = findPossibleJoins (csb, binaryNode-> arg1 . getAddress () ,
122
- rseStack, booleanStack);
123
- const bool found2 = findPossibleJoins (csb, binaryNode-> arg2 . getAddress () ,
124
- rseStack, booleanStack);
122
+ const bool found1 = findPossibleJoins (csb, rseStreams ,
123
+ binaryNode-> arg1 . getAddress (), rseStack, booleanStack);
124
+ const bool found2 = findPossibleJoins (csb, rseStreams ,
125
+ binaryNode-> arg2 . getAddress (), rseStack, booleanStack);
125
126
126
127
if (!binaryNode->arg1 && !binaryNode->arg2 )
127
128
*parentBoolean = nullptr ;
@@ -143,8 +144,7 @@ namespace
143
144
if (rse->rse_boolean && rse->rse_jointype == blr_inner &&
144
145
!rse->rse_first && !rse->rse_skip && !rse->rse_plan )
145
146
{
146
- StreamList rseStreams;
147
- rse->computeRseStreams (rseStreams);
147
+ // Find booleans convertable into semi-joins
148
148
149
149
BoolExprNodeStack booleans;
150
150
if (findDependentBooleans (csb, rseStreams,
@@ -173,7 +173,7 @@ namespace
173
173
bool dependent = false ;
174
174
for (const auto stream : streams)
175
175
{
176
- if (! rseStreams.exist (stream))
176
+ if (rseStreams.exist (stream))
177
177
{
178
178
dependent = true ;
179
179
break ;
@@ -3264,7 +3264,10 @@ RseNode* RseNode::processPossibleJoins(thread_db* tdbb, CompilerScratch* csb)
3264
3264
3265
3265
// Find possibly joinable sub-queries
3266
3266
3267
- if (!findPossibleJoins (csb, rse_boolean.getAddress (), rseStack, booleanStack))
3267
+ StreamList rseStreams;
3268
+ computeRseStreams (rseStreams);
3269
+
3270
+ if (!findPossibleJoins (csb, rseStreams, rse_boolean.getAddress (), rseStack, booleanStack))
3268
3271
return nullptr ;
3269
3272
3270
3273
fb_assert (rseStack.hasData () && booleanStack.hasData ());
0 commit comments