Validate each entity referenced in a single path of a CREATE clause.
| 299 | |
| 300 | // Validate each entity referenced in a single path of a CREATE clause. |
| 301 | static 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 |
| 325 | static AST_Validation _Validate_referred_identifier |
no test coverage detected