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

Function _ValidateMultiHopTraversal

src/ast/ast_validations.c:186–211  ·  view source on GitHub ↗

make sure multi-hop traversals has length greater than or equal to zero

Source from the content-addressed store, hash-verified

184
185// make sure multi-hop traversals has length greater than or equal to zero
186static AST_Validation _ValidateMultiHopTraversal
187(
188 const cypher_astnode_t *edge, // ast-node to validate
189 const cypher_astnode_t *range // varlength range
190) {
191 int start = 1;
192 int end = INT_MAX - 2;
193
194 const cypher_astnode_t *range_start = cypher_ast_range_get_start(range);
195 if(range_start) {
196 start = AST_ParseIntegerNode(range_start);
197 }
198
199 const cypher_astnode_t *range_end = cypher_ast_range_get_end(range);
200 if(range_end) {
201 end = AST_ParseIntegerNode(range_end);
202 }
203
204 // Validate specified range
205 if(start > end) {
206 ErrorCtx_SetError("Variable length path, maximum number of hops must be greater or equal to minimum number of hops.");
207 return AST_INVALID;
208 }
209
210 return AST_VALID;
211}
212
213// Verify that MERGE doesn't redeclare bound relations, that one reltype is specified for unbound relations,
214// and that the entity is not a variable length pattern

Callers 1

_Validate_rel_patternFunction · 0.85

Calls 2

AST_ParseIntegerNodeFunction · 0.85
ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected