Skip to content

Commit 5dee439

Browse files
committed
Fix the csb_sub_stream litetime accidentally broken by my refactoring
1 parent 0cc77c8 commit 5dee439

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

src/jrd/RecordSourceNodes.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,39 @@ static void genDeliverUnmapped(CompilerScratch* csb, const BoolExprNodeStack& pa
5252
static ValueExprNode* resolveUsingField(DsqlCompilerScratch* dsqlScratch, const MetaName& name,
5353
ValueListNode* list, const FieldNode* flawedNode, const TEXT* side, dsql_ctx*& ctx);
5454

55+
namespace
56+
{
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+
}
5588

5689
//--------------------
5790

@@ -3559,10 +3592,7 @@ bool RseNode::computable(CompilerScratch* csb, StreamType stream,
35593592
return false;
35603593

35613594
// Set sub-streams of rse active
3562-
StreamList streams;
3563-
computeRseStreams(streams);
3564-
StreamStateHolder streamHolder(csb, streams);
3565-
streamHolder.activate(true);
3595+
AutoActivateResetStreams activator(csb, this);
35663596

35673597
// Check sub-stream
35683598
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
@@ -608,7 +608,7 @@ class CompilerScratch : public pool_alloc<type_csb>
608608
// We must zero-initialize this one
609609
csb_repeat();
610610

611-
void activate(bool subStream = false);
611+
void activate();
612612
void deactivate();
613613

614614
std::optional<USHORT> csb_cursor_number; // Cursor number for this stream
@@ -658,12 +658,9 @@ inline CompilerScratch::csb_repeat::csb_repeat()
658658
{
659659
}
660660

661-
inline void CompilerScratch::csb_repeat::activate(bool subStream)
661+
inline void CompilerScratch::csb_repeat::activate()
662662
{
663663
csb_flags |= csb_active;
664-
665-
if (subStream)
666-
csb_flags |= csb_sub_stream;
667664
}
668665

669666
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
@@ -2748,7 +2748,7 @@ RecordSource* Optimizer::applyLocalBoolean(RecordSource* rsb,
27482748
globalHolder.deactivate();
27492749

27502750
StreamStateHolder localHolder(csb, streams);
2751-
localHolder.activate(csb);
2751+
localHolder.activate();
27522752

27532753
double selectivity = MAXIMUM_SELECTIVITY;
27542754
if (const auto boolean = composeBoolean(iter, &selectivity))

src/jrd/optimizer/Optimizer.h

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

123-
void activate(bool subStream = false)
123+
void activate()
124124
{
125125
for (const auto stream : m_streams)
126-
m_csb->csb_rpt[stream].activate(subStream);
126+
m_csb->csb_rpt[stream].activate();
127127
}
128128

129129
void deactivate()

0 commit comments

Comments
 (0)