validate parameters of a query
| 2263 | |
| 2264 | // validate parameters of a query |
| 2265 | AST_Validation AST_Validate_QueryParams |
| 2266 | ( |
| 2267 | const cypher_parse_result_t *result // parse-result to validate |
| 2268 | ) { |
| 2269 | int index; |
| 2270 | if(AST_Validate_ParseResultRoot(result, &index) != AST_VALID) { |
| 2271 | return AST_INVALID; |
| 2272 | } |
| 2273 | |
| 2274 | const cypher_astnode_t *root = cypher_parse_result_get_root(result, index); |
| 2275 | |
| 2276 | // in case of no parameters |
| 2277 | if(cypher_ast_statement_noptions(root) == 0) { |
| 2278 | return AST_VALID; |
| 2279 | } |
| 2280 | |
| 2281 | if(_ValidateParamsOnly(root) != AST_VALID) { |
| 2282 | return AST_INVALID; |
| 2283 | } |
| 2284 | if(_ValidateDuplicateParameters(root) != AST_VALID) { |
| 2285 | return AST_INVALID; |
| 2286 | } |
| 2287 | |
| 2288 | // create a context for the traversal |
| 2289 | validations_ctx ctx = { |
| 2290 | .union_all = NOT_DEFINED, |
| 2291 | .defined_identifiers = raxNew(), |
| 2292 | .ignore_identifiers = false |
| 2293 | }; |
| 2294 | |
| 2295 | // create a visitor |
| 2296 | ast_visitor visitor = {&ctx, validations_mapping}; |
| 2297 | |
| 2298 | // visit (traverse) the ast |
| 2299 | AST_Visitor_visit(root, &visitor); |
| 2300 | |
| 2301 | // cleanup |
| 2302 | raxFree(ctx.defined_identifiers); |
| 2303 | |
| 2304 | return !ErrorCtx_EncounteredError() ? AST_VALID : AST_INVALID; |
| 2305 | } |
| 2306 | |
| 2307 | // report encountered errors by libcypher-parser |
| 2308 | void AST_ReportErrors |
no test coverage detected