MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / convert_expr_depth

Function convert_expr_depth

nodedb-sql/src/resolver/expr/convert.rs:45–55  ·  view source on GitHub ↗

Internal recursive helper that carries a depth counter to enforce `MAX_CONVERT_DEPTH` and prevent stack overflow on malformed ASTs.

(expr: &Expr, depth: &mut usize)

Source from the content-addressed store, hash-verified

43/// Internal recursive helper that carries a depth counter to enforce
44/// `MAX_CONVERT_DEPTH` and prevent stack overflow on malformed ASTs.
45pub(super) fn convert_expr_depth(expr: &Expr, depth: &mut usize) -> Result<SqlExpr> {
46 *depth += 1;
47 if *depth > MAX_CONVERT_DEPTH {
48 return Err(SqlError::Unsupported {
49 detail: format!("expression nesting depth exceeds maximum of {MAX_CONVERT_DEPTH}"),
50 });
51 }
52 let result = convert_expr_inner(expr, depth);
53 *depth -= 1;
54 result
55}
56
57fn convert_expr_inner(expr: &Expr, depth: &mut usize) -> Result<SqlExpr> {
58 match expr {

Callers 4

convert_function_depthFunction · 0.85
collect_function_argsFunction · 0.85
convert_exprFunction · 0.85
convert_expr_innerFunction · 0.85

Calls 1

convert_expr_innerFunction · 0.70

Tested by

no test coverage detected