rewrites the subquery to contain the projections needed in case of an eager and returning execution-plan such that bound vars will remain in the record when passed to the CallSubquery op returns true if a rewrite was performed
| 503 | // remain in the record when passed to the CallSubquery op |
| 504 | // returns true if a rewrite was performed |
| 505 | static bool _rewrite_call_subquery_clauses |
| 506 | ( |
| 507 | cypher_astnode_t *wrapping_clause, // clause (query/call {}) |
| 508 | char ***outer_inter_names // internal names of bound vars in outer-scope ('@n', '@m', etc.) |
| 509 | ) { |
| 510 | ASSERT(cypher_astnode_type(wrapping_clause) == CYPHER_AST_QUERY); |
| 511 | |
| 512 | bool rewritten = false; |
| 513 | uint nclauses = cypher_ast_query_nclauses(wrapping_clause); |
| 514 | |
| 515 | // go over clauses. Upon finding a Call {} clause, rewrite it recursively |
| 516 | uint start_scope = 0; |
| 517 | int orig_len = array_len(*outer_inter_names); |
| 518 | |
| 519 | for(uint i = 0; i < nclauses; i++) { |
| 520 | cypher_astnode_t *clause = (cypher_astnode_t *) |
| 521 | cypher_ast_query_get_clause(wrapping_clause, i); |
| 522 | cypher_astnode_type_t type = cypher_astnode_type(clause); |
| 523 | if(type == CYPHER_AST_CALL_SUBQUERY) { |
| 524 | // if the subquery is returning & eager, rewrite its projections |
| 525 | rewritten |= _rewrite_call_subquery_clause(wrapping_clause, |
| 526 | i, start_scope, outer_inter_names); |
| 527 | |
| 528 | // `outer_inter_names` now contains the internal representation of |
| 529 | // the current context as well |
| 530 | |
| 531 | // recursively rewrite embedded Call {} clauses, taking the |
| 532 | // potentially updated query |
| 533 | rewritten |= _rewrite_call_subquery_clauses( |
| 534 | cypher_ast_call_subquery_get_query(clause), outer_inter_names); |
| 535 | |
| 536 | // restore `outer_inter_names` to its original state |
| 537 | _restore_outer_internal_names(outer_inter_names, orig_len); |
| 538 | } |
| 539 | |
| 540 | // update start_scope if needed |
| 541 | if(type == CYPHER_AST_WITH || type == CYPHER_AST_RETURN) { |
| 542 | start_scope = i; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | return rewritten; |
| 547 | } |
| 548 | |
| 549 | static void _add_star_projection |
| 550 | ( |
no test coverage detected