--------------------------------------------------------------------------- Internal result functions These return map[string]any so that handleAnalyzeSQL can fan-out concurrently and collect results without JSON round-trips. --------------------------------------------------------------------------
(sql, dialect string)
| 42 | // error return (tool-semantic failure, not a protocol error). |
| 43 | // A missing/empty sql argument returns a non-nil error (protocol error). |
| 44 | func validateSQLInternal(sql, dialect string) (map[string]any, error) { |
| 45 | if sql == "" { |
| 46 | return nil, fmt.Errorf("parameter 'sql' is required and must not be empty") |
| 47 | } |
| 48 | |
| 49 | if dialect != "" { |
| 50 | _, err := gosqlx.ParseWithDialect(sql, sqlkeywords.SQLDialect(dialect)) |
| 51 | if err != nil { |
| 52 | return map[string]any{ |
| 53 | "valid": false, |
| 54 | "dialect": dialect, |
| 55 | "error": err.Error(), |
| 56 | }, nil |
| 57 | } |
| 58 | return map[string]any{ |
| 59 | "valid": true, |
| 60 | "dialect": dialect, |
| 61 | }, nil |
| 62 | } |
| 63 | |
| 64 | err := gosqlx.Validate(sql) |
| 65 | if err != nil { |
| 66 | return map[string]any{ |
| 67 | "valid": false, |
| 68 | "error": err.Error(), |
| 69 | }, nil |
| 70 | } |
| 71 | return map[string]any{ |
| 72 | "valid": true, |
| 73 | }, nil |
| 74 | } |
| 75 | |
| 76 | // formatSQLInternal formats a SQL string using the provided options. |
| 77 | func formatSQLInternal(sql string, indentSize int, uppercaseKeywords, addSemicolon bool) (map[string]any, error) { |