Validate CALL statement
(
call_stmt: &CallStatement,
ctx: &mut ValidationContext,
errors: &mut Vec<ValidationError>,
)
| 2176 | |
| 2177 | /// Validate CALL statement |
| 2178 | fn validate_call_statement( |
| 2179 | call_stmt: &CallStatement, |
| 2180 | ctx: &mut ValidationContext, |
| 2181 | errors: &mut Vec<ValidationError>, |
| 2182 | ) { |
| 2183 | // Validate procedure name (should be valid system procedure) |
| 2184 | if !crate::catalog::system_procedures::is_system_procedure(&call_stmt.procedure_name) { |
| 2185 | errors.push(ValidationError { |
| 2186 | message: format!("Unknown system procedure: {}", call_stmt.procedure_name), |
| 2187 | location: Some(call_stmt.location.clone()), |
| 2188 | error_type: ValidationErrorType::Semantic, |
| 2189 | }); |
| 2190 | } |
| 2191 | |
| 2192 | // Validate arguments |
| 2193 | for arg in &call_stmt.arguments { |
| 2194 | validate_expression(arg, ctx, errors); |
| 2195 | } |
| 2196 | |
| 2197 | // Validate YIELD clause if present |
| 2198 | if let Some(yield_clause) = &call_stmt.yield_clause { |
| 2199 | validate_yield_clause(yield_clause, errors); |
| 2200 | } |
| 2201 | |
| 2202 | // Validate WHERE clause if present |
| 2203 | if let Some(where_clause) = &call_stmt.where_clause { |
| 2204 | // WHERE clause can only be used with YIELD clause |
| 2205 | if call_stmt.yield_clause.is_none() { |
| 2206 | errors.push(ValidationError { |
| 2207 | message: "WHERE clause can only be used with YIELD clause in CALL statements" |
| 2208 | .to_string(), |
| 2209 | location: Some(where_clause.location.clone()), |
| 2210 | error_type: ValidationErrorType::Semantic, |
| 2211 | }); |
| 2212 | } else { |
| 2213 | // For CALL statements, we only validate WHERE structure and that it references YIELD columns |
| 2214 | // We skip general variable existence validation since procedure results are runtime-dependent |
| 2215 | |
| 2216 | // Additional validation: WHERE should reference columns from YIELD |
| 2217 | // This is a semantic check to ensure WHERE only uses yielded columns |
| 2218 | if let Some(yield_clause) = &call_stmt.yield_clause { |
| 2219 | validate_where_references_yield_columns(where_clause, yield_clause, errors); |
| 2220 | } |
| 2221 | |
| 2222 | // Note: We deliberately skip validate_expression() here for CALL WHERE clauses |
| 2223 | // because CALL procedure results are only known at runtime. The WHERE clause |
| 2224 | // validation happens during execution when the actual column names are available. |
| 2225 | } |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | /// Validate that WHERE clause only references columns from YIELD clause |
| 2230 | fn validate_where_references_yield_columns( |
no test coverage detected