Parse a local table reference.
| 612 | |
| 613 | // Parse a local table reference. |
| 614 | LocalTableSourceNode* LocalTableSourceNode::parse(thread_db* tdbb, CompilerScratch* csb, |
| 615 | const SSHORT blrOp, bool parseContext) |
| 616 | { |
| 617 | const USHORT tableNumber = csb->csb_blr_reader.getWord(); |
| 618 | |
| 619 | if (tableNumber >= csb->csb_localTables.getCount()) |
| 620 | PAR_error(csb, Arg::Gds(isc_bad_loctab_num) << Arg::Num(tableNumber)); |
| 621 | |
| 622 | // Make a relation reference node |
| 623 | |
| 624 | const auto node = FB_NEW_POOL(*tdbb->getDefaultPool()) LocalTableSourceNode( |
| 625 | *tdbb->getDefaultPool()); |
| 626 | |
| 627 | node->tableNumber = tableNumber; |
| 628 | |
| 629 | AutoPtr<string> aliasString(FB_NEW_POOL(csb->csb_pool) string(csb->csb_pool)); |
| 630 | csb->csb_blr_reader.getString(*aliasString); |
| 631 | |
| 632 | if (aliasString->hasData()) |
| 633 | node->alias = *aliasString; |
| 634 | else |
| 635 | aliasString.reset(); |
| 636 | |
| 637 | // generate a stream for the relation reference, assuming it is a real reference |
| 638 | |
| 639 | if (parseContext) |
| 640 | { |
| 641 | node->stream = PAR_context(csb, &node->context); |
| 642 | |
| 643 | if (tableNumber >= csb->csb_localTables.getCount() || !csb->csb_localTables[tableNumber]) |
| 644 | PAR_error(csb, Arg::Gds(isc_bad_loctab_num) << Arg::Num(tableNumber)); |
| 645 | |
| 646 | csb->csb_rpt[node->stream].csb_format = csb->csb_localTables[tableNumber]->format; |
| 647 | csb->csb_rpt[node->stream].csb_alias = aliasString.release(); |
| 648 | } |
| 649 | |
| 650 | return node; |
| 651 | } |
| 652 | |
| 653 | string LocalTableSourceNode::internalPrint(NodePrinter& printer) const |
| 654 | { |
no test coverage detected