analyzeFunctionCall analyzes function calls
(fn *ast.FunctionCall)
| 265 | |
| 266 | // analyzeFunctionCall analyzes function calls |
| 267 | func (a *SQLAnalyzer) analyzeFunctionCall(fn *ast.FunctionCall) { |
| 268 | a.functionCount++ |
| 269 | |
| 270 | // Check for potentially expensive functions |
| 271 | expensiveFunctions := map[string]bool{ |
| 272 | "SUBSTRING": true, "UPPER": true, "LOWER": true, |
| 273 | "CONCAT": true, "REGEXP": true, "MD5": true, |
| 274 | } |
| 275 | |
| 276 | if expensiveFunctions[strings.ToUpper(fn.Name)] { |
| 277 | a.addPerformanceIssue("EXPENSIVE_FUNCTION", "LOW", |
| 278 | fmt.Sprintf("Function %s may be expensive in large result sets", fn.Name), |
| 279 | "performance", "Consider precalculating values or using indexes") |
| 280 | } |
| 281 | |
| 282 | // Analyze window functions |
| 283 | if fn.Over != nil { |
| 284 | a.addPerformanceIssue("WINDOW_FUNCTION", "LOW", |
| 285 | "Window functions can be resource intensive", |
| 286 | "performance", "Ensure proper indexing for window function performance") |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | // analyzeIdentifier analyzes identifiers |
| 291 | func (a *SQLAnalyzer) analyzeIdentifier(id *ast.Identifier) { |
no test coverage detected