| 233 | } |
| 234 | |
| 235 | bool AggNode::dsqlInvalidReferenceFinder(InvalidReferenceFinder& visitor) |
| 236 | { |
| 237 | bool invalid = false; |
| 238 | |
| 239 | if (!visitor.insideOwnMap) |
| 240 | { |
| 241 | // We are not in an aggregate from the same scope_level so |
| 242 | // check for valid fields inside this aggregate |
| 243 | invalid |= ExprNode::dsqlInvalidReferenceFinder(visitor); |
| 244 | } |
| 245 | |
| 246 | if (!visitor.insideHigherMap) |
| 247 | { |
| 248 | NodeRefsHolder holder(visitor.dsqlScratch->getPool()); |
| 249 | getChildren(holder, true); |
| 250 | |
| 251 | for (auto i : holder.refs) |
| 252 | { |
| 253 | // If there's another aggregate with the same scope_level or |
| 254 | // an higher one then it's a invalid aggregate, because |
| 255 | // aggregate-functions from the same context can't |
| 256 | // be part of each other. |
| 257 | if (Aggregate2Finder::find(visitor.dsqlScratch->getPool(), visitor.context->ctx_scope_level, |
| 258 | FIELD_MATCH_TYPE_EQUAL, false, *i)) |
| 259 | { |
| 260 | // Nested aggregate functions are not allowed |
| 261 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << |
| 262 | Arg::Gds(isc_dsql_agg_nested_err)); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | return invalid; |
| 268 | } |
| 269 | |
| 270 | bool AggNode::dsqlSubSelectFinder(SubSelectFinder& /*visitor*/) |
| 271 | { |