MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _add_star_projection

Function _add_star_projection

src/ast/ast_rewrite_call_subquery.c:549–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549static void _add_star_projection
550(
551 cypher_astnode_t *node, // node to add the projection to
552 uint idx // index in which to plant the projection
553) {
554 cypher_astnode_type_t type = cypher_astnode_type(node);
555
556 cypher_astnode_t *query;
557 if(type == CYPHER_AST_STATEMENT) {
558 query = (cypher_astnode_t *)cypher_ast_statement_get_body(node);
559 } else {
560 // node is a call {} clause
561 ASSERT(type == CYPHER_AST_CALL_SUBQUERY);
562
563 query = cypher_ast_call_subquery_get_query(node);
564 }
565
566 uint nclauses = cypher_ast_query_nclauses(query);
567
568 // create a star projection
569 struct cypher_input_range range = {0};
570 cypher_astnode_t *star_projection = cypher_ast_with(false, true, NULL, 0,
571 NULL, NULL, NULL, NULL, NULL, 0, range);
572
573 cypher_astnode_t *clauses[nclauses + 1];
574 for(uint i = 0; i < idx; i++) {
575 clauses[i] = cypher_ast_clone(cypher_ast_query_get_clause(query, i));
576 }
577 clauses[idx] = star_projection;
578 for(uint i = idx; i < nclauses; i++) {
579 clauses[i + 1] = cypher_ast_clone(cypher_ast_query_get_clause(query, i));
580 }
581
582 cypher_astnode_t *new_query = cypher_ast_query(NULL, 0, clauses,
583 nclauses + 1, clauses, nclauses + 1, range);
584
585 if(type == CYPHER_AST_STATEMENT) {
586 cypher_ast_statement_replace_body(node, new_query);
587 } else {
588 cypher_ast_call_subquery_replace_query(node, new_query);
589 }
590}
591
592static bool _add_star_projections
593(

Callers 1

_add_star_projectionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected