Compile a record selection expression. The input node may either be a "select_expression" or a "list" (an implicit union) or a "query specification".
| 1794 | // Compile a record selection expression. The input node may either be a "select_expression" |
| 1795 | // or a "list" (an implicit union) or a "query specification". |
| 1796 | static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* input, |
| 1797 | ValueListNode* order, RowsClause* rows, bool updateLock, bool skipLocked, USHORT flags) |
| 1798 | { |
| 1799 | DEV_BLKCHK(dsqlScratch, dsql_type_req); |
| 1800 | |
| 1801 | thread_db* tdbb = JRD_get_thread_data(); |
| 1802 | MemoryPool& pool = *tdbb->getDefaultPool(); |
| 1803 | |
| 1804 | if (auto selNode = nodeAs<SelectExprNode>(input)) |
| 1805 | { |
| 1806 | WithClause* withClause = selNode->withClause; |
| 1807 | try |
| 1808 | { |
| 1809 | if (withClause) |
| 1810 | dsqlScratch->addCTEs(withClause); |
| 1811 | |
| 1812 | RseNode* ret = pass1_rse(dsqlScratch, selNode->querySpec, selNode->orderClause, |
| 1813 | selNode->rowsClause, updateLock, skipLocked, selNode->dsqlFlags); |
| 1814 | |
| 1815 | if (withClause) |
| 1816 | { |
| 1817 | dsqlScratch->checkUnusedCTEs(); |
| 1818 | dsqlScratch->clearCTEs(); |
| 1819 | } |
| 1820 | |
| 1821 | return ret; |
| 1822 | } |
| 1823 | catch (const Exception&) |
| 1824 | { |
| 1825 | if (withClause) |
| 1826 | dsqlScratch->clearCTEs(); |
| 1827 | throw; |
| 1828 | } |
| 1829 | } |
| 1830 | else if (auto unionNode = nodeAs<UnionSourceNode>(input)) |
| 1831 | { |
| 1832 | fb_assert(unionNode->dsqlClauses->items.hasData()); |
| 1833 | return pass1_union(dsqlScratch, unionNode, order, rows, updateLock, skipLocked, flags); |
| 1834 | } |
| 1835 | |
| 1836 | RseNode* inputRse = nodeAs<RseNode>(input); |
| 1837 | fb_assert(inputRse); |
| 1838 | |
| 1839 | // Save the original base of the context stack and process relations |
| 1840 | |
| 1841 | RseNode* targetRse = FB_NEW_POOL(pool) RseNode(pool); |
| 1842 | RseNode* rse = targetRse; |
| 1843 | |
| 1844 | if (updateLock) |
| 1845 | rse->flags |= RseNode::FLAG_WRITELOCK; |
| 1846 | |
| 1847 | if (skipLocked) |
| 1848 | rse->flags |= RseNode::FLAG_SKIP_LOCKED; |
| 1849 | |
| 1850 | rse->dsqlStreams = Node::doDsqlPass(dsqlScratch, inputRse->dsqlFrom, false); |
| 1851 | RecSourceListNode* streamList = rse->dsqlStreams; |
| 1852 | |
| 1853 | { // scope block |
no test coverage detected