class CQL::Postgres::ServerError

Overview

An ErrorResponse from the server. The server's own wording (#server_message) and #detail can quote bound values (a unique violation names the duplicate key, "invalid input syntax" quotes the offending text, a $1::regclass cast quotes its argument). message therefore uses the server's wording only for SQLSTATE classes known to be value-free and a fixed title otherwise; the raw fields stay available for callers who accept that risk.

Direct Known Subclasses

Defined in:

postgres/errors.cr:70
postgres/errors.cr:175

Constant Summary

BY_CLASS = {"23" => IntegrityViolation, "28" => InvalidAuthorization, "40" => TransactionRollback, "42" => SyntaxOrAccessError} of String => ServerError.class
BY_SQLSTATE = {"23505" => UniqueViolation, "23503" => ForeignKeyViolation, "23502" => NotNullViolation, "23514" => CheckViolation, "40001" => SerializationFailure, "40P01" => DeadlockDetected, "42P01" => UndefinedTable, "42703" => UndefinedColumn, "57014" => QueryCanceled} of String => ServerError.class
TITLES = {"42P01" => "undefined table", "42703" => "undefined column", "42601" => "syntax error", "42501" => "insufficient privilege", "22P02" => "invalid text representation", "40001" => "serialization failure", "40P01" => "deadlock detected", "40" => "transaction rollback", "42P05" => "prepared statement already exists (behind a transaction-mode pooler? set statement_cache_size=0)", "26000" => "prepared statement does not exist (behind a transaction-mode pooler? set statement_cache_size=0)", "22" => "data exception", "42" => "syntax error or access rule violation", "P0" => "PL/pgSQL error"}
VALUE_FREE_CLASSES = {"08", "0A", "23", "25", "28", "3D", "53", "54", "55", "57", "58"}

Constructors

Instance Method Summary

Constructor Detail

def self.from(fields : Hash(Char, String)) : ServerError #

Subclass per SQLSTATE where one exists, else per SQLSTATE class.


[View source]
def self.new(fields : Hash(Char, String)) #

[View source]

Instance Method Detail

def column : String | Nil #

[View source]
def constraint : String | Nil #

[View source]
def detail : String | Nil #

[View source]
def hint : String | Nil #

[View source]
def position : Int32 | Nil #

[View source]
def routine : String | Nil #

[View source]
def schema : String | Nil #

[View source]
def server_message : String #

[View source]
def severity : String #

[View source]
def sqlstate : String #

[View source]
def stale_plan? : Bool #

The server's cached plan became invalid after a schema change; preparing the statement again fixes it. PostgreSQL names the routine; CockroachDB only sends the same message text.


[View source]
def table : String | Nil #

[View source]