if the subquery will result in an eager and returning execution-plan rewrites it to contain the projections needed: 1. "n" -> "@n" in the initial WITH clause if exists. Otherwise, creates it. 2. "@n" -> "@n" in the intermediate WITH clauses. 3. "@n" -> "n" in the final RETURN clause. if the subquery will not result in an eager & returning execution-plan, does nothing
| 637 | // if the subquery will not result in an eager & returning execution-plan, does |
| 638 | // nothing |
| 639 | bool AST_RewriteCallSubquery |
| 640 | ( |
| 641 | const cypher_astnode_t *root // root of AST |
| 642 | ) { |
| 643 | if(cypher_astnode_type(root) != CYPHER_AST_STATEMENT) { |
| 644 | return false; |
| 645 | } |
| 646 | |
| 647 | // retrieve the root's body |
| 648 | cypher_astnode_t *query = |
| 649 | (cypher_astnode_t *)cypher_ast_statement_get_body(root); |
| 650 | |
| 651 | if(cypher_astnode_type(query) != CYPHER_AST_QUERY) { |
| 652 | return false; |
| 653 | } |
| 654 | |
| 655 | char **inter_names = array_new(char *, 0); |
| 656 | bool rewritten = _rewrite_call_subquery_clauses(query, &inter_names); |
| 657 | uint n_inter_names = array_len(inter_names); |
| 658 | array_free_cb(inter_names, rm_free); |
| 659 | |
| 660 | // add a `WITH *` clause before every call {} clause |
| 661 | // this is an optimization that decreases the mapping size of the plan up to |
| 662 | // the CallSubquery operation |
| 663 | rewritten |= _add_star_projections((cypher_astnode_t *)root); |
| 664 | |
| 665 | return rewritten; |
| 666 | } |
no test coverage detected