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

Function _Validate_node_pattern

src/ast/ast_validations.c:828–863  ·  view source on GitHub ↗

validate a node-pattern expression

Source from the content-addressed store, hash-verified

826
827// validate a node-pattern expression
828static VISITOR_STRATEGY _Validate_node_pattern
829(
830 const cypher_astnode_t *n, // ast-node (node-pattern)
831 bool start, // first traversal
832 ast_visitor *visitor // visitor
833) {
834 validations_ctx *vctx = AST_Visitor_GetContext(visitor);
835 if(!start) {
836 return VISITOR_CONTINUE;
837 }
838
839 if(_ValidateInlinedProperties(cypher_ast_node_pattern_get_properties(n)) == AST_INVALID) {
840 return VISITOR_BREAK;
841 }
842
843 const cypher_astnode_t *alias_node = cypher_ast_node_pattern_get_identifier(n);
844 if(!alias_node) {
845 return VISITOR_RECURSE;
846 }
847
848 const char *alias = cypher_ast_identifier_get_name(alias_node);
849 if(vctx->clause == CYPHER_AST_MERGE) {
850 if(_ValidateMergeNode(n, vctx->defined_identifiers) == AST_INVALID) {
851 return VISITOR_BREAK;
852 }
853 } else {
854 void *alias_type = raxFind(vctx->defined_identifiers, (unsigned char *)alias, strlen(alias));
855 if(alias_type != raxNotFound && alias_type != NULL && alias_type != (void *)T_NODE) {
856 ErrorCtx_SetError("The alias '%s' was specified for both a node and a relationship.", alias);
857 return VISITOR_BREAK;
858 }
859 }
860 raxInsert(vctx->defined_identifiers, (unsigned char *)alias, strlen(alias), (void *)T_NODE, NULL);
861
862 return VISITOR_RECURSE;
863}
864
865// validate a shortest-path expression
866static VISITOR_STRATEGY _Validate_shortest_path

Callers

nothing calls this directly

Calls 4

AST_Visitor_GetContextFunction · 0.85
_ValidateMergeNodeFunction · 0.85
ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected