collect aliases from a CALL {} clause
| 347 | |
| 348 | // collect aliases from a CALL {} clause |
| 349 | static void _collect_call_subquery_projections |
| 350 | ( |
| 351 | const cypher_astnode_t *clause, |
| 352 | rax *identifiers |
| 353 | ) { |
| 354 | // collect returned aliases from the subquery, if there are any |
| 355 | const cypher_astnode_t *query = |
| 356 | cypher_ast_call_subquery_get_query(clause); |
| 357 | uint nclauses = cypher_ast_query_nclauses(query); |
| 358 | const cypher_astnode_t *last_clause = |
| 359 | cypher_ast_query_get_clause(query, nclauses - 1); |
| 360 | bool is_returning = (cypher_astnode_type(last_clause) == CYPHER_AST_RETURN); |
| 361 | if(!is_returning) { |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | // collect aliases from the RETURN clause |
| 366 | uint projection_count = cypher_ast_return_nprojections(last_clause); |
| 367 | for(uint i = 0; i < projection_count; i ++) { |
| 368 | const cypher_astnode_t *projection = |
| 369 | cypher_ast_return_get_projection(last_clause, i); |
| 370 | const cypher_astnode_t *identifier_node = |
| 371 | cypher_ast_projection_get_alias(projection); |
| 372 | if(identifier_node == NULL) { |
| 373 | // the projection was not aliased |
| 374 | // so the projection itself must be an identifier |
| 375 | identifier_node = cypher_ast_projection_get_expression(projection); |
| 376 | ASSERT(cypher_astnode_type(identifier_node) == CYPHER_AST_IDENTIFIER); |
| 377 | } else { |
| 378 | // do not include empty projections, which may have been made to |
| 379 | // handle the MATCH () WITH * case |
| 380 | if(!strcmp(cypher_ast_identifier_get_name(identifier_node), "")) continue; |
| 381 | } |
| 382 | const char *identifier = cypher_ast_identifier_get_name(identifier_node); |
| 383 | raxTryInsert(identifiers, (unsigned char *)identifier, |
| 384 | strlen(identifier), (void *)identifier_node, NULL); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // collect aliases defined in a scope bounded by scope_start and scope_end |
| 389 | void collect_aliases_in_scope |
no outgoing calls
no test coverage detected