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

Function _ValidateMergeNode

src/ast/ast_validations.c:252–280  ·  view source on GitHub ↗

Verify that MERGE does not introduce labels or properties to bound nodes

Source from the content-addressed store, hash-verified

250
251// Verify that MERGE does not introduce labels or properties to bound nodes
252static AST_Validation _ValidateMergeNode
253(
254 const cypher_astnode_t *entity, // ast-node
255 rax *defined_aliases // bound variables
256) {
257 if(raxSize(defined_aliases) == 0) {
258 return AST_VALID;
259 }
260
261 const cypher_astnode_t *identifier = cypher_ast_node_pattern_get_identifier(entity);
262 if(!identifier) {
263 return AST_VALID;
264 }
265
266 const char *alias = cypher_ast_identifier_get_name(identifier);
267 // If the entity is unaliased or not previously bound, it cannot be redeclared
268 if(raxFind(defined_aliases, (unsigned char *)alias, strlen(alias)) == raxNotFound) {
269 return AST_VALID;
270 }
271
272 // If the entity is already bound, the MERGE pattern should not introduce labels or properties
273 if(cypher_ast_node_pattern_nlabels(entity) ||
274 cypher_ast_node_pattern_get_properties(entity)) {
275 ErrorCtx_SetError("The bound node '%s' can't be redeclared in a MERGE clause", alias);
276 return AST_INVALID;
277 }
278
279 return AST_VALID;
280}
281
282// Validate that the relation alias of an edge is not bound
283static AST_Validation _ValidateCreateRelation

Callers 1

_Validate_node_patternFunction · 0.85

Calls 1

ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected