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 | // this prefix for both invalid text representations and numeric overflows |
| 211 | // during casts (e.g. CAST(1000 AS TINYINT)); |
| 212 | func conversionErrorCode(msg string) string { |
| 213 | lower := strings.ToLower(msg) |
| 214 | switch { |
| 215 | case strings.Contains(lower, "out of range"), |
| 216 | strings.Contains(lower, "overflow"), |
| 217 | strings.Contains(lower, "would be out of range"): |
| 218 | return "22003" // numeric_value_out_of_range |
| 219 | } |
| 220 | return "22P02" // invalid_text_representation |
| 221 | } |
| 222 | |
| 223 | // constraintErrorCode narrows a "Constraint Error: …" message to one of the |
| 224 | // integrity_constraint_violation family codes. DuckDB's messages name the |