Look for unused CTEs and issue a warning about its presence. Also, make DSQL pass of every found unused CTE to check all references and initialize input parameters. Note, when passing some unused CTE which refers to another unused (by the main query) CTE, "unused" flag of the second one is cleared. Therefore names is collected in separate step.
| 650 | // (by the main query) CTE, "unused" flag of the second one is cleared. Therefore |
| 651 | // names is collected in separate step. |
| 652 | void DsqlCompilerScratch::checkUnusedCTEs() |
| 653 | { |
| 654 | bool sqlWarn = false; |
| 655 | FB_SIZE_T i; |
| 656 | |
| 657 | for (i = 0; i < ctes.getCount(); ++i) |
| 658 | { |
| 659 | SelectExprNode* cte = ctes[i]; |
| 660 | |
| 661 | if (!(cte->dsqlFlags & RecordSourceNode::DFLAG_DT_CTE_USED)) |
| 662 | { |
| 663 | if (!sqlWarn) |
| 664 | { |
| 665 | ERRD_post_warning(Arg::Warning(isc_sqlwarn) << Arg::Num(-104)); |
| 666 | sqlWarn = true; |
| 667 | } |
| 668 | |
| 669 | ERRD_post_warning(Arg::Warning(isc_dsql_cte_not_used) << cte->alias); |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | for (i = 0; i < ctes.getCount(); ++i) |
| 674 | { |
| 675 | SelectExprNode* cte = ctes[i]; |
| 676 | |
| 677 | if (!(cte->dsqlFlags & RecordSourceNode::DFLAG_DT_CTE_USED)) |
| 678 | cte->dsqlPass(this); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | DeclareSubFuncNode* DsqlCompilerScratch::getSubFunction(const MetaName& name) |
| 683 | { |
no test coverage detected