Generate blr for an access plan expression.
| 435 | |
| 436 | // Generate blr for an access plan expression. |
| 437 | static void gen_plan(DsqlCompilerScratch* dsqlScratch, const PlanNode* planNode) |
| 438 | { |
| 439 | // stuff the join type |
| 440 | |
| 441 | const Array<NestConst<PlanNode> >& list = planNode->subNodes; |
| 442 | |
| 443 | if (list.getCount() > 1) |
| 444 | { |
| 445 | dsqlScratch->appendUChar(blr_join); |
| 446 | dsqlScratch->appendUChar(list.getCount()); |
| 447 | } |
| 448 | |
| 449 | // stuff one or more plan items |
| 450 | |
| 451 | for (const NestConst<PlanNode>* ptr = list.begin(); ptr != list.end(); ++ptr) |
| 452 | { |
| 453 | const PlanNode* node = *ptr; |
| 454 | |
| 455 | if (node->subNodes.hasData()) |
| 456 | { |
| 457 | gen_plan(dsqlScratch, node); |
| 458 | continue; |
| 459 | } |
| 460 | |
| 461 | // if we're here, it must be a nod_plan_item |
| 462 | |
| 463 | dsqlScratch->appendUChar(blr_retrieve); |
| 464 | |
| 465 | // stuff the relation -- the relation id itself is redundant except |
| 466 | // when there is a need to differentiate the base tables of views |
| 467 | |
| 468 | // ASF: node->recordSourceNode may be NULL, and then a BLR error will happen. |
| 469 | // Example command: select * from (select * from t1) a plan (a natural); |
| 470 | if (node->recordSourceNode) |
| 471 | node->recordSourceNode->genBlr(dsqlScratch); |
| 472 | |
| 473 | // now stuff the access method for this stream |
| 474 | |
| 475 | ObjectsArray<PlanNode::AccessItem>::const_iterator idx_iter = |
| 476 | node->accessType->items.begin(); |
| 477 | FB_SIZE_T idx_count = node->accessType->items.getCount(); |
| 478 | |
| 479 | switch (node->accessType->type) |
| 480 | { |
| 481 | case PlanNode::AccessType::TYPE_SEQUENTIAL: |
| 482 | dsqlScratch->appendUChar(blr_sequential); |
| 483 | break; |
| 484 | |
| 485 | case PlanNode::AccessType::TYPE_NAVIGATIONAL: |
| 486 | dsqlScratch->appendUChar(blr_navigational); |
| 487 | dsqlScratch->appendNullString(idx_iter->indexName.c_str()); |
| 488 | if (idx_count == 1) |
| 489 | break; |
| 490 | // dimitr: FALL INTO, if the plan item is ORDER ... INDEX (...) |
| 491 | // ASF: The first item of a TYPE_NAVIGATIONAL is not for blr_indices. |
| 492 | ++idx_iter; |
| 493 | --idx_count; |
| 494 |
no test coverage detected