DsqlCompilerScratch.cpp (Firebird-3.0.2.32703-0.tar.bz2) | : | DsqlCompilerScratch.cpp (Firebird-3.0.4.33054-0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 570 | skipping to change at line 570 | |||
return NULL; | return NULL; | |||
} | } | |||
void DsqlCompilerScratch::clearCTEs() | void DsqlCompilerScratch::clearCTEs() | |||
{ | { | |||
flags &= ~DsqlCompilerScratch::FLAG_RECURSIVE_CTE; | flags &= ~DsqlCompilerScratch::FLAG_RECURSIVE_CTE; | |||
ctes.clear(); | ctes.clear(); | |||
cteAliases.clear(); | cteAliases.clear(); | |||
} | } | |||
void DsqlCompilerScratch::checkUnusedCTEs() const | // 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. Therefor | ||||
e | ||||
// names is collected in separate step. | ||||
void DsqlCompilerScratch::checkUnusedCTEs() | ||||
{ | { | |||
for (FB_SIZE_T i = 0; i < ctes.getCount(); ++i) | bool sqlWarn = false; | |||
FB_SIZE_T i; | ||||
for (i = 0; i < ctes.getCount(); ++i) | ||||
{ | { | |||
const SelectExprNode* cte = ctes[i]; | SelectExprNode* cte = ctes[i]; | |||
if (!(cte->dsqlFlags & RecordSourceNode::DFLAG_DT_CTE_USED)) | if (!(cte->dsqlFlags & RecordSourceNode::DFLAG_DT_CTE_USED)) | |||
{ | { | |||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << | if (!sqlWarn) | |||
Arg::Gds(isc_dsql_cte_not_used) << cte- | { | |||
>alias); | ERRD_post_warning(Arg::Warning(isc_sqlwarn) << Ar | |||
g::Num(-104)); | ||||
sqlWarn = true; | ||||
} | ||||
ERRD_post_warning(Arg::Warning(isc_dsql_cte_not_used) << | ||||
cte->alias); | ||||
} | } | |||
} | } | |||
for (i = 0; i < ctes.getCount(); ++i) | ||||
{ | ||||
SelectExprNode* cte = ctes[i]; | ||||
if (!(cte->dsqlFlags & RecordSourceNode::DFLAG_DT_CTE_USED)) | ||||
cte->dsqlPass(this); | ||||
} | ||||
} | } | |||
// Process derived table which can be recursive CTE. | // Process derived table which can be recursive CTE. | |||
// If it is non-recursive return input node unchanged. | // If it is non-recursive return input node unchanged. | |||
// If it is recursive return new derived table which is an union of union of anc hor (non-recursive) | // If it is recursive return new derived table which is an union of union of anc hor (non-recursive) | |||
// queries and union of recursive queries. Check recursive queries to satisfy va rious criteria. | // queries and union of recursive queries. Check recursive queries to satisfy va rious criteria. | |||
// Note that our parser is right-to-left therefore nested list linked as first n ode in parent list | // Note that our parser is right-to-left therefore nested list linked as first n ode in parent list | |||
// and second node is always query spec. | // and second node is always query spec. | |||
// For example, if we have 4 CTE's where first two are non-recursive and last tw o are recursive: | // For example, if we have 4 CTE's where first two are non-recursive and last tw o are recursive: | |||
// | // | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 27 lines changed or added |