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 the subquery was rewritten
| 453 | // remain in the record when passed to the CallSubquery op |
| 454 | // returns true if the subquery was rewritten |
| 455 | static bool _rewrite_call_subquery_clause |
| 456 | ( |
| 457 | cypher_astnode_t *wrapping_clause, // outer-context clause (query/call {}) |
| 458 | uint clause_idx, // index of the call {} clause in query |
| 459 | uint start, // start ind from which to collect bound vars |
| 460 | char ***inter_names // internal representation of bound vars |
| 461 | ) { |
| 462 | ASSERT(cypher_astnode_type(wrapping_clause) == CYPHER_AST_QUERY); |
| 463 | |
| 464 | cypher_astnode_t *clause = (cypher_astnode_t *) |
| 465 | cypher_ast_query_get_clause(wrapping_clause, clause_idx); |
| 466 | ASSERT(cypher_astnode_type(clause) == CYPHER_AST_CALL_SUBQUERY); |
| 467 | |
| 468 | cypher_astnode_t *subquery = cypher_ast_call_subquery_get_query(clause); |
| 469 | uint subclauses_count = cypher_ast_query_nclauses(subquery); |
| 470 | |
| 471 | // check if the subquery will result in an eager and returning |
| 472 | // execution-plan |
| 473 | const cypher_astnode_t *last_clause = |
| 474 | cypher_ast_query_get_clause(subquery, subclauses_count - 1); |
| 475 | bool is_returning = cypher_astnode_type(last_clause) == CYPHER_AST_RETURN; |
| 476 | |
| 477 | bool is_eager = AST_IsEager(subquery); |
| 478 | |
| 479 | if(is_eager && is_returning) { |
| 480 | _rewrite_projections(wrapping_clause, clause_idx, start, inter_names); |
| 481 | return true; |
| 482 | } |
| 483 | |
| 484 | return false; |
| 485 | } |
| 486 | |
| 487 | // restores `outer_names` to its original size by freeing the added components |
| 488 | static void _restore_outer_internal_names |
no test coverage detected