Skip to content

Commit 52a9136

Browse files
committed
Fix the csb_sub_stream litetime accidentally broken by my refactoring
1 parent aca12f5 commit 52a9136

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

src/jrd/RecordSourceNodes.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,37 @@ static ValueExprNode* resolveUsingField(DsqlCompilerScratch* dsqlScratch, const
5454

5555
namespace
5656
{
57+
class AutoActivateResetStreams : public AutoStorage
58+
{
59+
public:
60+
AutoActivateResetStreams(CompilerScratch* csb, const RseNode* rse)
61+
: m_csb(csb), m_streams(getPool()), m_flags(getPool())
62+
{
63+
rse->computeRseStreams(m_streams);
64+
65+
m_flags.resize(m_streams.getCount());
66+
67+
FB_SIZE_T pos = 0;
68+
for (const auto stream : m_streams)
69+
{
70+
m_flags[pos++] = m_csb->csb_rpt[stream].csb_flags;
71+
m_csb->csb_rpt[stream].csb_flags |= (csb_active | csb_sub_stream);
72+
}
73+
}
74+
75+
~AutoActivateResetStreams()
76+
{
77+
FB_SIZE_T pos = 0;
78+
for (const auto stream : m_streams)
79+
m_csb->csb_rpt[stream].csb_flags = m_flags[pos++];
80+
}
81+
82+
private:
83+
CompilerScratch* m_csb;
84+
StreamList m_streams;
85+
HalfStaticArray<USHORT, OPT_STATIC_ITEMS> m_flags;
86+
};
87+
5788
// Search through the list of ANDed booleans to find comparisons
5889
// referring streams of the parent select expression.
5990
// Extract those booleans and return them to the caller.
@@ -3604,10 +3635,7 @@ bool RseNode::computable(CompilerScratch* csb, StreamType stream,
36043635
return false;
36053636

36063637
// Set sub-streams of rse active
3607-
StreamList streams;
3608-
computeRseStreams(streams);
3609-
StreamStateHolder streamHolder(csb, streams);
3610-
streamHolder.activate(true);
3638+
AutoActivateResetStreams activator(csb, this);
36113639

36123640
// Check sub-stream
36133641
if ((rse_boolean && !rse_boolean->computable(csb, stream, allowOnlyCurrentStream)) ||

src/jrd/exe.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ class CompilerScratch : public pool_alloc<type_csb>
609609
// We must zero-initialize this one
610610
csb_repeat();
611611

612-
void activate(bool subStream = false);
612+
void activate();
613613
void deactivate();
614614

615615
Nullable<USHORT> csb_cursor_number; // Cursor number for this stream
@@ -659,12 +659,9 @@ inline CompilerScratch::csb_repeat::csb_repeat()
659659
{
660660
}
661661

662-
inline void CompilerScratch::csb_repeat::activate(bool subStream)
662+
inline void CompilerScratch::csb_repeat::activate()
663663
{
664664
csb_flags |= csb_active;
665-
666-
if (subStream)
667-
csb_flags |= csb_sub_stream;
668665
}
669666

670667
inline void CompilerScratch::csb_repeat::deactivate()

src/jrd/optimizer/Optimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ RecordSource* Optimizer::applyLocalBoolean(RecordSource* rsb,
17291729
globalHolder.deactivate();
17301730

17311731
StreamStateHolder localHolder(csb, streams);
1732-
localHolder.activate(csb);
1732+
localHolder.activate();
17331733

17341734
return applyBoolean(rsb, iter);
17351735
}

src/jrd/optimizer/Optimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ class StreamStateHolder
119119
}
120120
}
121121

122-
void activate(bool subStream = false)
122+
void activate()
123123
{
124124
for (const auto stream : m_streams)
125-
m_csb->csb_rpt[stream].activate(subStream);
125+
m_csb->csb_rpt[stream].activate();
126126
}
127127

128128
void deactivate()

0 commit comments

Comments
 (0)