Try to expand the given stream. If it's a view reference, collect its base streams (the ones directly residing in the FROM clause) and recurse.
| 94 | // Try to expand the given stream. If it's a view reference, collect its base streams |
| 95 | // (the ones directly residing in the FROM clause) and recurse. |
| 96 | void expandViewStreams(CompilerScratch* csb, StreamType baseStream, SortedStreamList& streams) |
| 97 | { |
| 98 | const auto csb_tail = &csb->csb_rpt[baseStream]; |
| 99 | |
| 100 | const RseNode* const rse = |
| 101 | csb_tail->csb_relation ? csb_tail->csb_relation->rel_view_rse : NULL; |
| 102 | |
| 103 | // If we have a view, collect its base streams and remap/expand them |
| 104 | |
| 105 | if (rse) |
| 106 | { |
| 107 | const auto map = csb_tail->csb_map; |
| 108 | fb_assert(map); |
| 109 | |
| 110 | StreamList viewStreams; |
| 111 | rse->computeRseStreams(viewStreams); |
| 112 | |
| 113 | for (auto stream : viewStreams) |
| 114 | { |
| 115 | // Remap stream and expand it recursively |
| 116 | expandViewStreams(csb, map[stream], streams); |
| 117 | } |
| 118 | |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | // Otherwise, just add the current stream to the list |
| 123 | |
| 124 | if (!streams.exist(baseStream)) |
| 125 | streams.add(baseStream); |
| 126 | } |
| 127 | |
| 128 | // Expand DBKEY for view |
| 129 | void expandViewNodes(CompilerScratch* csb, StreamType baseStream, |
no test coverage detected