| 604 | } |
| 605 | |
| 606 | const char **AST_BuildCallColumnNames |
| 607 | ( |
| 608 | const cypher_astnode_t *call_clause |
| 609 | ) { |
| 610 | const char **proc_output_columns = NULL; |
| 611 | uint yield_count = cypher_ast_call_nprojections(call_clause); |
| 612 | if(yield_count > 0) { |
| 613 | proc_output_columns = array_new(const char *, yield_count); |
| 614 | for(uint i = 0; i < yield_count; i ++) { |
| 615 | const cypher_astnode_t *projection = cypher_ast_call_get_projection(call_clause, i); |
| 616 | const cypher_astnode_t *ast_exp = cypher_ast_projection_get_expression(projection); |
| 617 | |
| 618 | const char *identifier = NULL; |
| 619 | const cypher_astnode_t *alias_node = cypher_ast_projection_get_alias(projection); |
| 620 | if(alias_node) { |
| 621 | // The projection either has an alias (AS), is a function call, or is a property specification (e.name). |
| 622 | identifier = cypher_ast_identifier_get_name(alias_node); |
| 623 | } else { |
| 624 | // This expression did not have an alias, so it must be an identifier |
| 625 | ASSERT(cypher_astnode_type(ast_exp) == CYPHER_AST_IDENTIFIER); |
| 626 | // Retrieve "a" from "RETURN a" or "RETURN a AS e" (theoretically; the latter case is already handled) |
| 627 | identifier = cypher_ast_identifier_get_name(ast_exp); |
| 628 | } |
| 629 | array_append(proc_output_columns, identifier); |
| 630 | } |
| 631 | } else { |
| 632 | // If the procedure call is missing its yield part, include procedure outputs. |
| 633 | const char *proc_name = cypher_ast_proc_name_get_value(cypher_ast_call_get_proc_name(call_clause)); |
| 634 | ProcedureCtx *proc = Proc_Get(proc_name); |
| 635 | ASSERT(proc); |
| 636 | unsigned int output_count = Procedure_OutputCount(proc); |
| 637 | proc_output_columns = array_new(const char *, output_count); |
| 638 | for(uint i = 0; i < output_count; i++) { |
| 639 | array_append(proc_output_columns, Procedure_GetOutput(proc, i)); |
| 640 | } |
| 641 | Proc_Free(proc); |
| 642 | } |
| 643 | return proc_output_columns; |
| 644 | } |
| 645 | |
| 646 | const char *_AST_ExtractQueryString |
| 647 | ( |
no test coverage detected