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

Function _ValidateDuplicateParameters

src/ast/ast_validations.c:2240–2262  ·  view source on GitHub ↗

Make sure no duplicated parameters are given in a statement expression

Source from the content-addressed store, hash-verified

2238
2239// Make sure no duplicated parameters are given in a statement expression
2240static AST_Validation _ValidateDuplicateParameters
2241(
2242 const cypher_astnode_t *statement // statement
2243) {
2244 rax *param_names = raxNew();
2245 uint noptions = cypher_ast_statement_noptions(statement);
2246 for(uint i = 0; i < noptions; i++) {
2247 const cypher_astnode_t *option = cypher_ast_statement_get_option(statement, i);
2248 uint nparams = cypher_ast_cypher_option_nparams(option);
2249 for(uint j = 0; j < nparams; j++) {
2250 const cypher_astnode_t *param = cypher_ast_cypher_option_get_param(option, j);
2251 const char *paramName = cypher_ast_string_get_value(cypher_ast_cypher_option_param_get_name(param));
2252 // If parameter already exists return an error.
2253 if(!raxInsert(param_names, (unsigned char *) paramName, strlen(paramName), NULL, NULL)) {
2254 ErrorCtx_SetError("Duplicated parameter: %s", paramName);
2255 raxFree(param_names);
2256 return AST_INVALID;
2257 }
2258 }
2259 }
2260 raxFree(param_names);
2261 return AST_VALID;
2262}
2263
2264// validate parameters of a query
2265AST_Validation AST_Validate_QueryParams

Callers 1

AST_Validate_QueryParamsFunction · 0.85

Calls 1

ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected