MCPcopy Create free account
hub / github.com/PostHog/duckgres / constraintErrorCode

Function constraintErrorCode

server/conn_errors.go:226–239  ·  view source on GitHub ↗

constraintErrorCode narrows a "Constraint Error: …" message to one of the integrity_constraint_violation family codes. DuckDB's messages name the violated constraint explicitly, so substring matching is reliable.

(msg string)

Source from the content-addressed store, hash-verified

224 return "42P01" // undefined_table (views share the code)
225 case strings.Contains(lower, "function") && (strings.Contains(lower, "does not exist") || strings.Contains(lower, "with these arguments")):
226 return "42883" // undefined_function
227 case strings.Contains(lower, "no function matches"):
228 return "42883" // undefined_function — DuckDB's overload-resolution failure
229 case strings.Contains(lower, "type") && strings.Contains(lower, "does not exist"):
230 return "42704" // undefined_object
231 case strings.Contains(lower, "does not exist"):
232 return "42704" // undefined_object (generic fallback)
233 case strings.Contains(lower, "already exists"):
234 if strings.Contains(lower, "function") {
235 return "42723" // duplicate_function
236 }
237 if strings.Contains(lower, "schema") {
238 return "42P06" // duplicate_schema
239 }
240 return "42P07" // duplicate_table
241 }
242 return "42000"

Callers 1

classifyErrorCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected