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

Function _ValidateQuerySequence

src/ast/ast_validations.c:1899–1924  ·  view source on GitHub ↗

Perform validations not constrained to a specific scope

Source from the content-addressed store, hash-verified

1897
1898// Perform validations not constrained to a specific scope
1899static AST_Validation _ValidateQuerySequence
1900(
1901 const AST *ast
1902) {
1903 // Validate the final clause
1904 if(_ValidateQueryTermination(ast) != AST_VALID) {
1905 return AST_INVALID;
1906 }
1907
1908 // The query cannot begin with a "WITH *" projection.
1909 const cypher_astnode_t *start_clause = cypher_ast_query_get_clause(ast->root, 0);
1910 if(cypher_astnode_type(start_clause) == CYPHER_AST_WITH &&
1911 cypher_ast_with_has_include_existing(start_clause)) {
1912 ErrorCtx_SetError("Query cannot begin with 'WITH *'.");
1913 return AST_INVALID;
1914 }
1915
1916 // The query cannot begin with a "RETURN *" projection.
1917 if(cypher_astnode_type(start_clause) == CYPHER_AST_RETURN &&
1918 cypher_ast_return_has_include_existing(start_clause)) {
1919 ErrorCtx_SetError("Query cannot begin with 'RETURN *'.");
1920 return AST_INVALID;
1921 }
1922
1923 return AST_VALID;
1924}
1925
1926/* In any given query scope, reading clauses (MATCH, UNWIND, and InQueryCall)
1927 * cannot follow updating clauses (CREATE, MERGE, DELETE, SET, REMOVE, FOREACH).

Callers 1

AST_Validate_QueryFunction · 0.85

Calls 2

ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected