MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_error_code

Function parse_error_code

src/adapter/src/error.rs:314–325  ·  view source on GitHub ↗

Maps a parse/cast [`ParseError`] to the appropriate `DATA_EXCEPTION` (class 22) SQLSTATE. Out-of-range values map to overflow codes and malformed input maps to invalid-representation codes, in both cases distinguishing datetime types from everything else, matching PostgreSQL.

(err: &ParseError)

Source from the content-addressed store, hash-verified

312/// maps to invalid-representation codes, in both cases distinguishing datetime
313/// types from everything else, matching PostgreSQL.
314fn parse_error_code(err: &ParseError) -> SqlState {
315 let is_datetime = matches!(
316 &*err.type_name,
317 "date" | "time" | "timestamp" | "timestamp with time zone" | "interval"
318 );
319 match (err.kind, is_datetime) {
320 (ParseErrorKind::OutOfRange, true) => SqlState::DATETIME_FIELD_OVERFLOW,
321 (ParseErrorKind::OutOfRange, false) => SqlState::NUMERIC_VALUE_OUT_OF_RANGE,
322 (ParseErrorKind::InvalidInputSyntax, true) => SqlState::INVALID_DATETIME_FORMAT,
323 (ParseErrorKind::InvalidInputSyntax, false) => SqlState::INVALID_TEXT_REPRESENTATION,
324 }
325}
326
327/// Maps an [`EvalError`] to the appropriate SQLSTATE.
328///

Callers 1

eval_error_codeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected