binderErrorCode narrows a "Binder Error: …" message. The binder raises on semantic problems discovered after parsing, most commonly missing columns.
(msg string)
| 190 | // binderErrorCode narrows a "Binder Error: …" message. The binder raises on |
| 191 | // semantic problems discovered after parsing, most commonly missing columns. |
| 192 | func binderErrorCode(msg string) string { |
| 193 | lower := strings.ToLower(msg) |
| 194 | switch { |
| 195 | case strings.Contains(lower, "referenced column") && strings.Contains(lower, "not found"): |
| 196 | return "42703" // undefined_column |
| 197 | case strings.Contains(lower, "column") && strings.Contains(lower, "does not exist"): |
| 198 | return "42703" |
| 199 | case strings.Contains(lower, "ambiguous"): |
| 200 | return "42702" // ambiguous_column |
| 201 | case strings.Contains(lower, "referenced table") && strings.Contains(lower, "not found"): |
| 202 | return "42P01" // undefined_table — DuckDB raises this for unknown aliases |
| 203 | case strings.Contains(lower, "no function matches"): |
| 204 | return "42883" // undefined_function — overload-resolution failure |
| 205 | } |
| 206 | return "42601" // syntax_error — binder failures without a narrower match |
| 207 | } |
| 208 | |
| 209 | // conversionErrorCode narrows a "Conversion Error: …" message. DuckDB uses |
| 210 | // this prefix for both invalid text representations and numeric overflows |