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

Function _Validate_CREATE_Entities

src/ast/ast_validations.c:301–322  ·  view source on GitHub ↗

Validate each entity referenced in a single path of a CREATE clause.

Source from the content-addressed store, hash-verified

299
300// Validate each entity referenced in a single path of a CREATE clause.
301static AST_Validation _Validate_CREATE_Entities
302(
303 const cypher_astnode_t *path, // ast-node (pattern-path)
304 rax *defined_aliases // bound vars
305) {
306 uint nelems = cypher_ast_pattern_path_nelements(path);
307 // Redeclaration of a node is not allowed only when the path is of length 0, as in: MATCH (a) CREATE (a).
308 // Otherwise, using a defined alias of a node is allowed, as in: MATCH (a) CREATE (a)-[:E]->(:B)
309 if(nelems == 1) {
310 const cypher_astnode_t *node = cypher_ast_pattern_path_get_element(path, 0);
311 const cypher_astnode_t *identifier = cypher_ast_node_pattern_get_identifier(node);
312 if(identifier) {
313 const char *alias = cypher_ast_identifier_get_name(identifier);
314 if(raxFind(defined_aliases, (unsigned char *)alias, strlen(alias)) != raxNotFound) {
315 ErrorCtx_SetError("The bound variable '%s' can't be redeclared in a CREATE clause", alias);
316 return AST_INVALID;
317 }
318 }
319 }
320
321 return AST_VALID;
322}
323
324// make sure an identifier is bound
325static AST_Validation _Validate_referred_identifier

Callers 1

_Validate_pattern_pathFunction · 0.85

Calls 1

ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected