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

Function _AST_GetProcCallAliases

src/ast/ast_validations.c:156–183  ·  view source on GitHub ↗

Extract identifiers / aliases from a procedure call.

Source from the content-addressed store, hash-verified

154
155// Extract identifiers / aliases from a procedure call.
156static void _AST_GetProcCallAliases
157(
158 const cypher_astnode_t *node, // ast-node to validate
159 rax *identifiers // rax to extract identifiers to
160) {
161 // CALL db.labels() yield label
162 // CALL db.labels() yield label as l
163 ASSERT(node && identifiers);
164 ASSERT(cypher_astnode_type(node) == CYPHER_AST_CALL);
165
166 // traverse projections, collecting the identifiers and expressions
167 uint projection_count = cypher_ast_call_nprojections(node);
168 for(uint i = 0; i < projection_count; i++) {
169 const char *identifier = NULL;
170 const cypher_astnode_t *proj_node = cypher_ast_call_get_projection(node, i);
171 const cypher_astnode_t *alias_node = cypher_ast_projection_get_alias(proj_node);
172 if(alias_node) {
173 // Alias is given: YIELD label AS l.
174 identifier = cypher_ast_identifier_get_name(alias_node);
175 raxInsert(identifiers, (unsigned char *)identifier, strlen(identifier), NULL, NULL);
176 }
177 // Introduce expression-identifier as well
178 // Example: YIELD label --> label is introduced (removed outside of scope)
179 const cypher_astnode_t *exp_node = cypher_ast_projection_get_expression(proj_node);
180 identifier = cypher_ast_identifier_get_name(exp_node);
181 raxInsert(identifiers, (unsigned char *)identifier, strlen(identifier), NULL, NULL);
182 }
183}
184
185// make sure multi-hop traversals has length greater than or equal to zero
186static AST_Validation _ValidateMultiHopTraversal

Callers 1

_Validate_CALL_ClauseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected