conversionErrorCode narrows a "Conversion Error: …" message. DuckDB uses this prefix for both invalid text representations and numeric overflows during casts (e.g. CAST(1000 AS TINYINT));
(msg string)
| 210 | } |
| 211 | } |
| 212 | return msg |
| 213 | } |
| 214 | |
| 215 | // catalogErrorCode narrows a "Catalog Error: …" message to a specific SQLSTATE |
| 216 | func catalogErrorCode(msg string) string { |
| 217 | lower := strings.ToLower(msg) |
| 218 | switch { |
| 219 | case strings.Contains(lower, "schema") && strings.Contains(lower, "does not exist"): |
| 220 | return "3F000" // invalid_schema_name |
| 221 | case strings.Contains(lower, "table with name") && strings.Contains(lower, "does not exist"): |
| 222 | return "42P01" // undefined_table |
| 223 | case strings.Contains(lower, "view with name") && strings.Contains(lower, "does not exist"): |
| 224 | return "42P01" // undefined_table (views share the code) |