Skip to content

Commit

Permalink
Fixed #7517: Successful compiling of procedure with wrong PLAN(s) use…
Browse files Browse the repository at this point in the history
…d by some of its statement(s)
  • Loading branch information
dyemanov committed Mar 28, 2023
1 parent 93a6057 commit b685e45
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/jrd/opt.cpp
Expand Up @@ -745,7 +745,9 @@ RecordSource* OPT_compile(thread_db* tdbb, CompilerScratch* csb, RseNode* rse,
csb->csb_rpt[*i].activate();
}

fb_assert(opt->compileStreams.getCount() != 1 || csb->csb_rpt[opt->compileStreams[0]].csb_relation != 0);
StreamList joinStreams(opt->compileStreams);

fb_assert(joinStreams.getCount() != 1 || csb->csb_rpt[joinStreams[0]].csb_relation != 0);

while (true)
{
Expand All @@ -755,7 +757,7 @@ RecordSource* OPT_compile(thread_db* tdbb, CompilerScratch* csb, RseNode* rse,
// currently active rivers. Where in the new cross river
// a stream depends (index) on the active rivers.
StreamList dependent_streams, free_streams;
find_index_relationship_streams(tdbb, opt, opt->compileStreams, dependent_streams, free_streams);
find_index_relationship_streams(tdbb, opt, joinStreams, dependent_streams, free_streams);

// If we have dependent and free streams then we can't rely on
// the sort node to be used for index navigation.
Expand All @@ -768,7 +770,7 @@ RecordSource* OPT_compile(thread_db* tdbb, CompilerScratch* csb, RseNode* rse,
if (dependent_streams.getCount())
{
// copy free streams
opt->compileStreams.assign(free_streams);
joinStreams.assign(free_streams);

// Make rivers from the dependent streams
gen_join(tdbb, opt, dependent_streams, rivers, &sort, rse->rse_plan);
Expand All @@ -794,7 +796,7 @@ RecordSource* OPT_compile(thread_db* tdbb, CompilerScratch* csb, RseNode* rse,
}

// attempt to form joins in decreasing order of desirability
gen_join(tdbb, opt, opt->compileStreams, rivers, &sort, rse->rse_plan);
gen_join(tdbb, opt, joinStreams, rivers, &sort, rse->rse_plan);

// If there are multiple rivers, try some hashing or sort/merging
while (gen_equi_join(tdbb, opt, rivers))
Expand Down

0 comments on commit b685e45

Please sign in to comment.