| 1797 | // |
| 1798 | |
| 1799 | void Optimizer::checkIndices() |
| 1800 | { |
| 1801 | for (const auto compileStream : compileStreams) |
| 1802 | { |
| 1803 | const auto tail = &csb->csb_rpt[compileStream]; |
| 1804 | |
| 1805 | const auto plan = tail->csb_plan; |
| 1806 | if (!plan) |
| 1807 | continue; |
| 1808 | |
| 1809 | if (plan->type != PlanNode::TYPE_RETRIEVE) |
| 1810 | continue; |
| 1811 | |
| 1812 | const auto relation = tail->csb_relation; |
| 1813 | if (!relation) |
| 1814 | return; |
| 1815 | |
| 1816 | // If there were no indices fetched at all but the user specified some, |
| 1817 | // error out using the first index specified |
| 1818 | |
| 1819 | const bool isGbak = tdbb->getAttachment()->isGbak(); |
| 1820 | |
| 1821 | if (!tail->csb_idx && plan->accessType) |
| 1822 | { |
| 1823 | // index %s cannot be used in the specified plan |
| 1824 | if (isGbak) |
| 1825 | ERR_post_warning(Arg::Warning(isc_index_unused) << plan->accessType->items[0].indexName); |
| 1826 | else |
| 1827 | ERR_post(Arg::Gds(isc_index_unused) << plan->accessType->items[0].indexName); |
| 1828 | } |
| 1829 | |
| 1830 | if (!tail->csb_idx) |
| 1831 | return; |
| 1832 | |
| 1833 | // Check to make sure that all indices are either used or marked not to be used, |
| 1834 | // and that there are no unused navigational indices |
| 1835 | MetaName index_name; |
| 1836 | |
| 1837 | for (const auto& idx : *tail->csb_idx) |
| 1838 | { |
| 1839 | if (!(idx.idx_runtime_flags & (idx_plan_dont_use | idx_used)) || |
| 1840 | ((idx.idx_runtime_flags & idx_plan_navigate) && !(idx.idx_runtime_flags & idx_navigate))) |
| 1841 | { |
| 1842 | if (relation) |
| 1843 | MET_lookup_index(tdbb, index_name, relation->rel_name, (USHORT) (idx.idx_id + 1)); |
| 1844 | else |
| 1845 | index_name = ""; |
| 1846 | |
| 1847 | // index %s cannot be used in the specified plan |
| 1848 | if (isGbak) |
| 1849 | ERR_post_warning(Arg::Warning(isc_index_unused) << Arg::Str(index_name)); |
| 1850 | else |
| 1851 | ERR_post(Arg::Gds(isc_index_unused) << Arg::Str(index_name)); |
| 1852 | } |
| 1853 | } |
| 1854 | } |
| 1855 | } |
| 1856 |
nothing calls this directly
no test coverage detected