MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / planSet

Method planSet

src/jrd/RecordSourceNodes.cpp:3421–3634  ·  view source on GitHub ↗

Go through the streams in the plan, find the corresponding streams in the RseNode and store the plan for that stream. Do it once and only once to make sure there is a one-to-one correspondence between streams in the query and streams in the plan.

Source from the content-addressed store, hash-verified

3419// plan for that stream. Do it once and only once to make sure there is a one-to-one correspondence
3420// between streams in the query and streams in the plan.
3421void RseNode::planSet(CompilerScratch* csb, PlanNode* plan)
3422{
3423 if (plan->type == PlanNode::TYPE_JOIN)
3424 {
3425 for (auto planNode : plan->subNodes)
3426 planSet(csb, planNode);
3427 }
3428
3429 if (plan->type != PlanNode::TYPE_RETRIEVE)
3430 return;
3431
3432 // Find the tail for the relation/procedure specified in the plan
3433
3434 const auto stream = plan->recordSourceNode->getStream();
3435 auto tail = &csb->csb_rpt[stream];
3436
3437 string planAlias;
3438
3439 jrd_rel* planRelation = nullptr;
3440 if (const auto relationNode = nodeAs<RelationSourceNode>(plan->recordSourceNode))
3441 {
3442 planRelation = relationNode->relation;
3443 planAlias = relationNode->alias;
3444 }
3445
3446 jrd_prc* planProcedure = nullptr;
3447 if (const auto procedureNode = nodeAs<ProcedureSourceNode>(plan->recordSourceNode))
3448 {
3449 planProcedure = procedureNode->procedure;
3450 planAlias = procedureNode->alias;
3451 }
3452
3453 fb_assert(planRelation || planProcedure);
3454
3455 const auto name = planRelation ? planRelation->rel_name :
3456 planProcedure ? planProcedure->getName().toString() : "";
3457
3458 // If the plan references a view, find the real base relation
3459 // we are interested in by searching the view map
3460 StreamType* map = nullptr;
3461 jrd_rel* viewRelation = nullptr;
3462 jrd_prc* viewProcedure = nullptr;
3463
3464 if (tail->csb_map)
3465 {
3466 auto tailName = tail->csb_relation ? tail->csb_relation->rel_name :
3467 tail->csb_procedure ? tail->csb_procedure->getName().toString() : "";
3468
3469 // If the user has specified an alias, skip past it to find the alias
3470 // for the base table (if multiple aliases are specified)
3471
3472 auto tailAlias = tail->csb_alias ? *tail->csb_alias : "";
3473
3474 if (planAlias.hasData())
3475 {
3476 const auto spacePos = planAlias.find_first_of(' ');
3477 const auto subAlias = planAlias.substr(0, spacePos);
3478

Callers

nothing calls this directly

Calls 13

GdsClass · 0.85
StrClass · 0.85
ltrimMethod · 0.80
setStreamMethod · 0.80
ERR_postFunction · 0.70
getStreamMethod · 0.45
toStringMethod · 0.45
getNameMethod · 0.45
hasDataMethod · 0.45
find_first_ofMethod · 0.45
substrMethod · 0.45
getIdMethod · 0.45

Tested by

no test coverage detected