8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 02:03:04 +01:00

Correction for the prior commit.

This commit is contained in:
dimitr 2014-12-21 19:30:06 +00:00
parent b9178d4df1
commit 64cfa741e7
3 changed files with 9 additions and 7 deletions

View File

@ -816,8 +816,9 @@ RecordSource* RelationSourceNode::compile(thread_db* tdbb, OptimizerBlk* opt, bo
// use an index to optimize them; retrieve the current format of
// all indices at this time so we can determine if it's possible
if (opt->opt_conjuncts.getCount() || opt->rse->rse_sorted || opt->rse->rse_aggregate)
OPT_compile_relation(tdbb, relation, opt->opt_csb, stream);
const bool needIndices =
opt->opt_conjuncts.getCount() || opt->rse->rse_sorted || opt->rse->rse_aggregate;
OPT_compile_relation(tdbb, relation, opt->opt_csb, stream, needIndices);
return NULL;
}

View File

@ -911,12 +911,13 @@ RecordSource* OPT_compile(thread_db* tdbb, CompilerScratch* csb, RseNode* rse,
// Prepare relation and its indices for optimization.
void OPT_compile_relation(thread_db* tdbb, jrd_rel* relation, CompilerScratch* csb, StreamType stream)
void OPT_compile_relation(thread_db* tdbb, jrd_rel* relation, CompilerScratch* csb,
StreamType stream, bool needIndices)
{
CompilerScratch::csb_repeat* const tail = &csb->csb_rpt[stream];
RelationPages* const relPages = relation->getPages(tdbb);
if (!relation->rel_file && !relation->isVirtual())
if (needIndices && !relation->rel_file && !relation->isVirtual())
{
csb->csb_rpt[stream].csb_indices = BTR_all(tdbb, relation, &tail->csb_idx, relPages);
@ -928,8 +929,8 @@ void OPT_compile_relation(thread_db* tdbb, jrd_rel* relation, CompilerScratch* c
else
csb->csb_rpt[stream].csb_indices = 0;
const Format* const format = CMP_format(tdbb, csb, stream);
csb->csb_rpt[stream].csb_cardinality = get_cardinality(tdbb, relation, format);
csb->csb_rpt[stream].csb_cardinality =
get_cardinality(tdbb, relation, CMP_format(tdbb, csb, stream));
}
// Add node (ValueExprNode) to stack unless node is already on stack.

View File

@ -45,7 +45,7 @@ Firebird::string OPT_get_plan(Jrd::thread_db* tdbb, const Jrd::jrd_req* request,
Jrd::RecordSource* OPT_compile(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb,
Jrd::RseNode* rse, Jrd::BoolExprNodeStack* parent_stack);
void OPT_compile_relation(Jrd::thread_db* tdbb, Jrd::jrd_rel* relation, Jrd::CompilerScratch* csb,
StreamType stream);
StreamType stream, bool needIndices);
void OPT_gen_aggregate_distincts(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb, Jrd::MapNode* map);
Jrd::SortedStream* OPT_gen_sort(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb, const Jrd::StreamList& streams,
const Jrd::StreamList* dbkey_streams, Jrd::RecordSource* prior_rsb, Jrd::SortNode* sort, bool project_flag);