MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / checkUnusedCTEs

Method checkUnusedCTEs

src/dsql/DsqlCompilerScratch.cpp:652–680  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

650// (by the main query) CTE, "unused" flag of the second one is cleared. Therefore
651// names is collected in separate step.
652void 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
682DeclareSubFuncNode* DsqlCompilerScratch::getSubFunction(const MetaName& name)
683{

Callers 1

pass1_rse_implFunction · 0.80

Calls 5

ERRD_post_warningFunction · 0.85
WarningClass · 0.85
NumClass · 0.85
getCountMethod · 0.45
dsqlPassMethod · 0.45

Tested by

no test coverage detected