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

Function transformErrorSQLState

server/conn_errors.go:125–131  ·  view source on GitHub ↗

transformErrorSQLState returns the SQLSTATE for a transpiler-detected error. A transform may attach an explicit code (e.g. 0A000 for an unsupported feature via transform.CodedError); otherwise it defaults to 42704 (undefined_object), matching the historical behavior for unrecognized config parameter

(err error)

Source from the content-addressed store, hash-verified

123// only signal the Go driver exposes today, so we parse the message string.
124func classifyErrorCode(err error) string {
125 // Wire-side SQLSTATE: 57014 is correct for any cancellation regardless of
126 // whether the caller drove it. Use isQueryCancelled here, not the
127 // clientConn-aware variant — classifyErrorCode is called from contexts
128 // that don't have a *clientConn (e.g., direct test fixtures).
129 if isQueryCancelled(err) {
130 return "57014"
131 }
132 if isDuckLakeTransactionConflict(err) {
133 return "40001" // serialization_failure — client should retry
134 }

Callers 3

handleParseMethod · 0.85
handleQueryMethod · 0.85

Calls 1

SQLStateMethod · 0.65

Tested by

no test coverage detected