diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 1438057b..2d870a24 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -7,3 +7,4 @@ authors = ["Steven Fackler "] phf_codegen = "=0.7.21" regex = "0.1" marksman_escape = "0.1" +linked-hash-map = "0.4" diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 7ca96fe9..4ba5681b 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,6 +1,7 @@ extern crate phf_codegen; extern crate regex; extern crate marksman_escape; +extern crate linked_hash_map; use std::ascii::AsciiExt; use std::path::Path; diff --git a/codegen/src/sqlstate.rs b/codegen/src/sqlstate.rs index 4e4bde17..a609e5ca 100644 --- a/codegen/src/sqlstate.rs +++ b/codegen/src/sqlstate.rs @@ -2,29 +2,22 @@ use std::fs::File; use std::io::{Write, BufWriter}; use std::path::Path; use phf_codegen; - -use snake_to_camel; +use linked_hash_map::LinkedHashMap; const ERRCODES_TXT: &'static str = include_str!("errcodes.txt"); -struct Code { - code: String, - variant: String, -} - pub fn build(path: &Path) { let mut file = BufWriter::new(File::create(path.join("error/sqlstate.rs")).unwrap()); let codes = parse_codes(); - make_header(&mut file); - make_enum(&codes, &mut file); + make_type(&mut file); + make_consts(&codes, &mut file); make_map(&codes, &mut file); - make_impl(&codes, &mut file); } -fn parse_codes() -> Vec { - let mut codes = vec![]; +fn parse_codes() -> LinkedHashMap> { + let mut codes = LinkedHashMap::new(); for line in ERRCODES_TXT.lines() { if line.starts_with("#") || line.starts_with("Section") || line.trim().is_empty() { @@ -34,131 +27,70 @@ fn parse_codes() -> Vec { let mut it = line.split_whitespace(); let code = it.next().unwrap().to_owned(); it.next(); - it.next(); - // for 2202E - let name = match it.next() { - Some(name) => name, - None => continue, - }; - let variant = match variant_name(&code) { - Some(variant) => variant, - None => snake_to_camel(&name), - }; + let name = it.next().unwrap().replace("ERRCODE_", ""); - codes.push(Code { - code: code, - variant: variant, - }); + codes.entry(code).or_insert_with(Vec::new).push(name); } codes } -fn variant_name(code: &str) -> Option { - match code { - "01004" => Some("WarningStringDataRightTruncation".to_owned()), - "22001" => Some("DataStringDataRightTruncation".to_owned()), - "2F002" => Some("SqlRoutineModifyingSqlDataNotPermitted".to_owned()), - "38002" => Some("ForeignRoutineModifyingSqlDataNotPermitted".to_owned()), - "2F003" => Some("SqlRoutineProhibitedSqlStatementAttempted".to_owned()), - "38003" => Some("ForeignRoutineProhibitedSqlStatementAttempted".to_owned()), - "2F004" => Some("SqlRoutineReadingSqlDataNotPermitted".to_owned()), - "38004" => Some("ForeignRoutineReadingSqlDataNotPermitted".to_owned()), - "22004" => Some("DataNullValueNotAllowed".to_owned()), - "39004" => Some("ExternalRoutineInvocationNullValueNotAllowed".to_owned()), - _ => None, - } -} - -fn make_header(file: &mut BufWriter) { +fn make_type(file: &mut BufWriter) { write!( file, "// Autogenerated file - DO NOT EDIT use phf; +use std::borrow::Cow; -" - ).unwrap(); -} - -fn make_enum(codes: &[Code], file: &mut BufWriter) { - write!( - file, - r#"/// SQLSTATE error codes +/// A SQLSTATE error code #[derive(PartialEq, Eq, Clone, Debug)] -#[allow(enum_variant_names)] -pub enum SqlState {{ -"# - ).unwrap(); +pub struct SqlState(Cow<'static, str>); - for code in codes { - write!( - file, - " /// `{}` - {},\n", - code.code, - code.variant - ).unwrap(); - } - - write!( - file, - " /// An unknown code - Other(String), -}} - -" - ).unwrap(); -} - -fn make_map(codes: &[Code], file: &mut BufWriter) { - write!( - file, - "#[cfg_attr(rustfmt, rustfmt_skip)] -static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = " - ).unwrap(); - let mut builder = phf_codegen::Map::new(); - for code in codes { - builder.entry(&*code.code, &format!("SqlState::{}", code.variant)); - } - builder.build(file).unwrap(); - write!(file, ";\n").unwrap(); -} - -fn make_impl(codes: &[Code], file: &mut BufWriter) { - write!( - file, - r#" impl SqlState {{ /// Creates a `SqlState` from its error code. pub fn from_code(s: &str) -> SqlState {{ match SQLSTATE_MAP.get(s) {{ Some(state) => state.clone(), - None => SqlState::Other(s.to_owned()), + None => SqlState(Cow::Owned(s.to_string())), }} }} /// Returns the error code corresponding to the `SqlState`. pub fn code(&self) -> &str {{ - match *self {{"# - ).unwrap(); - - for code in codes { - write!( - file, - r#" - SqlState::{} => "{}","#, - code.variant, - code.code - ).unwrap(); - } - - write!( - file, - r#" - SqlState::Other(ref s) => s, - }} + &self.0 }} }} -"# +" ).unwrap(); } + +fn make_consts(codes: &LinkedHashMap>, file: &mut BufWriter) { + for (code, names) in codes { + for name in names { + write!( + file, + r#" +/// {code} +pub const {name}: SqlState = SqlState(Cow::Borrowed("{code}")); +"#, + name = name, + code = code, + ).unwrap(); + } + } +} + +fn make_map(codes: &LinkedHashMap>, file: &mut BufWriter) { + write!( + file, + " +#[cfg_attr(rustfmt, rustfmt_skip)] +static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = " + ).unwrap(); + let mut builder = phf_codegen::Map::new(); + for (code, names) in codes { + builder.entry(&**code, &names[0]); + } + builder.build(file).unwrap(); + write!(file, ";\n").unwrap(); +} diff --git a/postgres-shared/src/error/mod.rs b/postgres-shared/src/error/mod.rs index b6e6526e..8d07b95f 100644 --- a/postgres-shared/src/error/mod.rs +++ b/postgres-shared/src/error/mod.rs @@ -5,7 +5,7 @@ use std::convert::From; use std::fmt; use std::io; -pub use self::sqlstate::SqlState; +pub use self::sqlstate::*; mod sqlstate; diff --git a/postgres-shared/src/error/sqlstate.rs b/postgres-shared/src/error/sqlstate.rs index 168a08cc..6d5916eb 100644 --- a/postgres-shared/src/error/sqlstate.rs +++ b/postgres-shared/src/error/sqlstate.rs @@ -1,496 +1,767 @@ // Autogenerated file - DO NOT EDIT use phf; +use std::borrow::Cow; -/// SQLSTATE error codes +/// A SQLSTATE error code #[derive(PartialEq, Eq, Clone, Debug)] -#[allow(enum_variant_names)] -pub enum SqlState { - /// `00000` - SuccessfulCompletion, - /// `01000` - Warning, - /// `0100C` - DynamicResultSetsReturned, - /// `01008` - ImplicitZeroBitPadding, - /// `01003` - NullValueEliminatedInSetFunction, - /// `01007` - PrivilegeNotGranted, - /// `01006` - PrivilegeNotRevoked, - /// `01004` - WarningStringDataRightTruncation, - /// `01P01` - DeprecatedFeature, - /// `02000` - NoData, - /// `02001` - NoAdditionalDynamicResultSetsReturned, - /// `03000` - SqlStatementNotYetComplete, - /// `08000` - ConnectionException, - /// `08003` - ConnectionDoesNotExist, - /// `08006` - ConnectionFailure, - /// `08001` - SqlclientUnableToEstablishSqlconnection, - /// `08004` - SqlserverRejectedEstablishmentOfSqlconnection, - /// `08007` - TransactionResolutionUnknown, - /// `08P01` - ProtocolViolation, - /// `09000` - TriggeredActionException, - /// `0A000` - FeatureNotSupported, - /// `0B000` - InvalidTransactionInitiation, - /// `0F000` - LocatorException, - /// `0F001` - InvalidLocatorSpecification, - /// `0L000` - InvalidGrantor, - /// `0LP01` - InvalidGrantOperation, - /// `0P000` - InvalidRoleSpecification, - /// `0Z000` - DiagnosticsException, - /// `0Z002` - StackedDiagnosticsAccessedWithoutActiveHandler, - /// `20000` - CaseNotFound, - /// `21000` - CardinalityViolation, - /// `22000` - DataException, - /// `2202E` - ArraySubscriptError, - /// `22021` - CharacterNotInRepertoire, - /// `22008` - DatetimeFieldOverflow, - /// `22012` - DivisionByZero, - /// `22005` - ErrorInAssignment, - /// `2200B` - EscapeCharacterConflict, - /// `22022` - IndicatorOverflow, - /// `22015` - IntervalFieldOverflow, - /// `2201E` - InvalidArgumentForLogarithm, - /// `22014` - InvalidArgumentForNtileFunction, - /// `22016` - InvalidArgumentForNthValueFunction, - /// `2201F` - InvalidArgumentForPowerFunction, - /// `2201G` - InvalidArgumentForWidthBucketFunction, - /// `22018` - InvalidCharacterValueForCast, - /// `22007` - InvalidDatetimeFormat, - /// `22019` - InvalidEscapeCharacter, - /// `2200D` - InvalidEscapeOctet, - /// `22025` - InvalidEscapeSequence, - /// `22P06` - NonstandardUseOfEscapeCharacter, - /// `22010` - InvalidIndicatorParameterValue, - /// `22023` - InvalidParameterValue, - /// `2201B` - InvalidRegularExpression, - /// `2201W` - InvalidRowCountInLimitClause, - /// `2201X` - InvalidRowCountInResultOffsetClause, - /// `2202H` - InvalidTablesampleArgument, - /// `2202G` - InvalidTablesampleRepeat, - /// `22009` - InvalidTimeZoneDisplacementValue, - /// `2200C` - InvalidUseOfEscapeCharacter, - /// `2200G` - MostSpecificTypeMismatch, - /// `22004` - DataNullValueNotAllowed, - /// `22002` - NullValueNoIndicatorParameter, - /// `22003` - NumericValueOutOfRange, - /// `2200H` - SequenceGeneratorLimitExceeded, - /// `22026` - StringDataLengthMismatch, - /// `22001` - DataStringDataRightTruncation, - /// `22011` - SubstringError, - /// `22027` - TrimError, - /// `22024` - UnterminatedCString, - /// `2200F` - ZeroLengthCharacterString, - /// `22P01` - FloatingPointException, - /// `22P02` - InvalidTextRepresentation, - /// `22P03` - InvalidBinaryRepresentation, - /// `22P04` - BadCopyFileFormat, - /// `22P05` - UntranslatableCharacter, - /// `2200L` - NotAnXmlDocument, - /// `2200M` - InvalidXmlDocument, - /// `2200N` - InvalidXmlContent, - /// `2200S` - InvalidXmlComment, - /// `2200T` - InvalidXmlProcessingInstruction, - /// `23000` - IntegrityConstraintViolation, - /// `23001` - RestrictViolation, - /// `23502` - NotNullViolation, - /// `23503` - ForeignKeyViolation, - /// `23505` - UniqueViolation, - /// `23514` - CheckViolation, - /// `23P01` - ExclusionViolation, - /// `24000` - InvalidCursorState, - /// `25000` - InvalidTransactionState, - /// `25001` - ActiveSqlTransaction, - /// `25002` - BranchTransactionAlreadyActive, - /// `25008` - HeldCursorRequiresSameIsolationLevel, - /// `25003` - InappropriateAccessModeForBranchTransaction, - /// `25004` - InappropriateIsolationLevelForBranchTransaction, - /// `25005` - NoActiveSqlTransactionForBranchTransaction, - /// `25006` - ReadOnlySqlTransaction, - /// `25007` - SchemaAndDataStatementMixingNotSupported, - /// `25P01` - NoActiveSqlTransaction, - /// `25P02` - InFailedSqlTransaction, - /// `25P03` - IdleInTransactionSessionTimeout, - /// `26000` - InvalidSqlStatementName, - /// `27000` - TriggeredDataChangeViolation, - /// `28000` - InvalidAuthorizationSpecification, - /// `28P01` - InvalidPassword, - /// `2B000` - DependentPrivilegeDescriptorsStillExist, - /// `2BP01` - DependentObjectsStillExist, - /// `2D000` - InvalidTransactionTermination, - /// `2F000` - SqlRoutineException, - /// `2F005` - FunctionExecutedNoReturnStatement, - /// `2F002` - SqlRoutineModifyingSqlDataNotPermitted, - /// `2F003` - SqlRoutineProhibitedSqlStatementAttempted, - /// `2F004` - SqlRoutineReadingSqlDataNotPermitted, - /// `34000` - InvalidCursorName, - /// `38000` - ExternalRoutineException, - /// `38001` - ContainingSqlNotPermitted, - /// `38002` - ForeignRoutineModifyingSqlDataNotPermitted, - /// `38003` - ForeignRoutineProhibitedSqlStatementAttempted, - /// `38004` - ForeignRoutineReadingSqlDataNotPermitted, - /// `39000` - ExternalRoutineInvocationException, - /// `39001` - InvalidSqlstateReturned, - /// `39004` - ExternalRoutineInvocationNullValueNotAllowed, - /// `39P01` - TriggerProtocolViolated, - /// `39P02` - SrfProtocolViolated, - /// `39P03` - EventTriggerProtocolViolated, - /// `3B000` - SavepointException, - /// `3B001` - InvalidSavepointSpecification, - /// `3D000` - InvalidCatalogName, - /// `3F000` - InvalidSchemaName, - /// `40000` - TransactionRollback, - /// `40002` - TransactionIntegrityConstraintViolation, - /// `40001` - SerializationFailure, - /// `40003` - StatementCompletionUnknown, - /// `40P01` - DeadlockDetected, - /// `42000` - SyntaxErrorOrAccessRuleViolation, - /// `42601` - SyntaxError, - /// `42501` - InsufficientPrivilege, - /// `42846` - CannotCoerce, - /// `42803` - GroupingError, - /// `42P20` - WindowingError, - /// `42P19` - InvalidRecursion, - /// `42830` - InvalidForeignKey, - /// `42602` - InvalidName, - /// `42622` - NameTooLong, - /// `42939` - ReservedName, - /// `42804` - DatatypeMismatch, - /// `42P18` - IndeterminateDatatype, - /// `42P21` - CollationMismatch, - /// `42P22` - IndeterminateCollation, - /// `42809` - WrongObjectType, - /// `428C9` - GeneratedAlways, - /// `42703` - UndefinedColumn, - /// `42883` - UndefinedFunction, - /// `42P01` - UndefinedTable, - /// `42P02` - UndefinedParameter, - /// `42704` - UndefinedObject, - /// `42701` - DuplicateColumn, - /// `42P03` - DuplicateCursor, - /// `42P04` - DuplicateDatabase, - /// `42723` - DuplicateFunction, - /// `42P05` - DuplicatePreparedStatement, - /// `42P06` - DuplicateSchema, - /// `42P07` - DuplicateTable, - /// `42712` - DuplicateAlias, - /// `42710` - DuplicateObject, - /// `42702` - AmbiguousColumn, - /// `42725` - AmbiguousFunction, - /// `42P08` - AmbiguousParameter, - /// `42P09` - AmbiguousAlias, - /// `42P10` - InvalidColumnReference, - /// `42611` - InvalidColumnDefinition, - /// `42P11` - InvalidCursorDefinition, - /// `42P12` - InvalidDatabaseDefinition, - /// `42P13` - InvalidFunctionDefinition, - /// `42P14` - InvalidPreparedStatementDefinition, - /// `42P15` - InvalidSchemaDefinition, - /// `42P16` - InvalidTableDefinition, - /// `42P17` - InvalidObjectDefinition, - /// `44000` - WithCheckOptionViolation, - /// `53000` - InsufficientResources, - /// `53100` - DiskFull, - /// `53200` - OutOfMemory, - /// `53300` - TooManyConnections, - /// `53400` - ConfigurationLimitExceeded, - /// `54000` - ProgramLimitExceeded, - /// `54001` - StatementTooComplex, - /// `54011` - TooManyColumns, - /// `54023` - TooManyArguments, - /// `55000` - ObjectNotInPrerequisiteState, - /// `55006` - ObjectInUse, - /// `55P02` - CantChangeRuntimeParam, - /// `55P03` - LockNotAvailable, - /// `55P04` - UnsafeNewEnumValueUsage, - /// `57000` - OperatorIntervention, - /// `57014` - QueryCanceled, - /// `57P01` - AdminShutdown, - /// `57P02` - CrashShutdown, - /// `57P03` - CannotConnectNow, - /// `57P04` - DatabaseDropped, - /// `58000` - SystemError, - /// `58030` - IoError, - /// `58P01` - UndefinedFile, - /// `58P02` - DuplicateFile, - /// `72000` - SnapshotTooOld, - /// `F0000` - ConfigFileError, - /// `F0001` - LockFileExists, - /// `HV000` - FdwError, - /// `HV005` - FdwColumnNameNotFound, - /// `HV002` - FdwDynamicParameterValueNeeded, - /// `HV010` - FdwFunctionSequenceError, - /// `HV021` - FdwInconsistentDescriptorInformation, - /// `HV024` - FdwInvalidAttributeValue, - /// `HV007` - FdwInvalidColumnName, - /// `HV008` - FdwInvalidColumnNumber, - /// `HV004` - FdwInvalidDataType, - /// `HV006` - FdwInvalidDataTypeDescriptors, - /// `HV091` - FdwInvalidDescriptorFieldIdentifier, - /// `HV00B` - FdwInvalidHandle, - /// `HV00C` - FdwInvalidOptionIndex, - /// `HV00D` - FdwInvalidOptionName, - /// `HV090` - FdwInvalidStringLengthOrBufferLength, - /// `HV00A` - FdwInvalidStringFormat, - /// `HV009` - FdwInvalidUseOfNullPointer, - /// `HV014` - FdwTooManyHandles, - /// `HV001` - FdwOutOfMemory, - /// `HV00P` - FdwNoSchemas, - /// `HV00J` - FdwOptionNameNotFound, - /// `HV00K` - FdwReplyHandle, - /// `HV00Q` - FdwSchemaNotFound, - /// `HV00R` - FdwTableNotFound, - /// `HV00L` - FdwUnableToCreateExecution, - /// `HV00M` - FdwUnableToCreateReply, - /// `HV00N` - FdwUnableToEstablishConnection, - /// `P0000` - PlpgsqlError, - /// `P0001` - RaiseException, - /// `P0002` - NoDataFound, - /// `P0003` - TooManyRows, - /// `P0004` - AssertFailure, - /// `XX000` - InternalError, - /// `XX001` - DataCorrupted, - /// `XX002` - IndexCorrupted, - /// An unknown code - Other(String), +pub struct SqlState(Cow<'static, str>); + +impl SqlState { + /// Creates a `SqlState` from its error code. + pub fn from_code(s: &str) -> SqlState { + match SQLSTATE_MAP.get(s) { + Some(state) => state.clone(), + None => SqlState(Cow::Owned(s.to_string())), + } + } + + /// Returns the error code corresponding to the `SqlState`. + pub fn code(&self) -> &str { + &self.0 + } } +/// 00000 +pub const SUCCESSFUL_COMPLETION: SqlState = SqlState(Cow::Borrowed("00000")); + +/// 01000 +pub const WARNING: SqlState = SqlState(Cow::Borrowed("01000")); + +/// 0100C +pub const WARNING_DYNAMIC_RESULT_SETS_RETURNED: SqlState = SqlState(Cow::Borrowed("0100C")); + +/// 01008 +pub const WARNING_IMPLICIT_ZERO_BIT_PADDING: SqlState = SqlState(Cow::Borrowed("01008")); + +/// 01003 +pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = SqlState(Cow::Borrowed("01003")); + +/// 01007 +pub const WARNING_PRIVILEGE_NOT_GRANTED: SqlState = SqlState(Cow::Borrowed("01007")); + +/// 01006 +pub const WARNING_PRIVILEGE_NOT_REVOKED: SqlState = SqlState(Cow::Borrowed("01006")); + +/// 01004 +pub const WARNING_STRING_DATA_RIGHT_TRUNCATION: SqlState = SqlState(Cow::Borrowed("01004")); + +/// 01P01 +pub const WARNING_DEPRECATED_FEATURE: SqlState = SqlState(Cow::Borrowed("01P01")); + +/// 02000 +pub const NO_DATA: SqlState = SqlState(Cow::Borrowed("02000")); + +/// 02001 +pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = SqlState(Cow::Borrowed("02001")); + +/// 03000 +pub const SQL_STATEMENT_NOT_YET_COMPLETE: SqlState = SqlState(Cow::Borrowed("03000")); + +/// 08000 +pub const CONNECTION_EXCEPTION: SqlState = SqlState(Cow::Borrowed("08000")); + +/// 08003 +pub const CONNECTION_DOES_NOT_EXIST: SqlState = SqlState(Cow::Borrowed("08003")); + +/// 08006 +pub const CONNECTION_FAILURE: SqlState = SqlState(Cow::Borrowed("08006")); + +/// 08001 +pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08001")); + +/// 08004 +pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08004")); + +/// 08007 +pub const TRANSACTION_RESOLUTION_UNKNOWN: SqlState = SqlState(Cow::Borrowed("08007")); + +/// 08P01 +pub const PROTOCOL_VIOLATION: SqlState = SqlState(Cow::Borrowed("08P01")); + +/// 09000 +pub const TRIGGERED_ACTION_EXCEPTION: SqlState = SqlState(Cow::Borrowed("09000")); + +/// 0A000 +pub const FEATURE_NOT_SUPPORTED: SqlState = SqlState(Cow::Borrowed("0A000")); + +/// 0B000 +pub const INVALID_TRANSACTION_INITIATION: SqlState = SqlState(Cow::Borrowed("0B000")); + +/// 0F000 +pub const LOCATOR_EXCEPTION: SqlState = SqlState(Cow::Borrowed("0F000")); + +/// 0F001 +pub const L_E_INVALID_SPECIFICATION: SqlState = SqlState(Cow::Borrowed("0F001")); + +/// 0L000 +pub const INVALID_GRANTOR: SqlState = SqlState(Cow::Borrowed("0L000")); + +/// 0LP01 +pub const INVALID_GRANT_OPERATION: SqlState = SqlState(Cow::Borrowed("0LP01")); + +/// 0P000 +pub const INVALID_ROLE_SPECIFICATION: SqlState = SqlState(Cow::Borrowed("0P000")); + +/// 0Z000 +pub const DIAGNOSTICS_EXCEPTION: SqlState = SqlState(Cow::Borrowed("0Z000")); + +/// 0Z002 +pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = SqlState(Cow::Borrowed("0Z002")); + +/// 20000 +pub const CASE_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("20000")); + +/// 21000 +pub const CARDINALITY_VIOLATION: SqlState = SqlState(Cow::Borrowed("21000")); + +/// 22000 +pub const DATA_EXCEPTION: SqlState = SqlState(Cow::Borrowed("22000")); + +/// 2202E +pub const ARRAY_ELEMENT_ERROR: SqlState = SqlState(Cow::Borrowed("2202E")); + +/// 2202E +pub const ARRAY_SUBSCRIPT_ERROR: SqlState = SqlState(Cow::Borrowed("2202E")); + +/// 22021 +pub const CHARACTER_NOT_IN_REPERTOIRE: SqlState = SqlState(Cow::Borrowed("22021")); + +/// 22008 +pub const DATETIME_FIELD_OVERFLOW: SqlState = SqlState(Cow::Borrowed("22008")); + +/// 22008 +pub const DATETIME_VALUE_OUT_OF_RANGE: SqlState = SqlState(Cow::Borrowed("22008")); + +/// 22012 +pub const DIVISION_BY_ZERO: SqlState = SqlState(Cow::Borrowed("22012")); + +/// 22005 +pub const ERROR_IN_ASSIGNMENT: SqlState = SqlState(Cow::Borrowed("22005")); + +/// 2200B +pub const ESCAPE_CHARACTER_CONFLICT: SqlState = SqlState(Cow::Borrowed("2200B")); + +/// 22022 +pub const INDICATOR_OVERFLOW: SqlState = SqlState(Cow::Borrowed("22022")); + +/// 22015 +pub const INTERVAL_FIELD_OVERFLOW: SqlState = SqlState(Cow::Borrowed("22015")); + +/// 2201E +pub const INVALID_ARGUMENT_FOR_LOG: SqlState = SqlState(Cow::Borrowed("2201E")); + +/// 22014 +pub const INVALID_ARGUMENT_FOR_NTILE: SqlState = SqlState(Cow::Borrowed("22014")); + +/// 22016 +pub const INVALID_ARGUMENT_FOR_NTH_VALUE: SqlState = SqlState(Cow::Borrowed("22016")); + +/// 2201F +pub const INVALID_ARGUMENT_FOR_POWER_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201F")); + +/// 2201G +pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201G")); + +/// 22018 +pub const INVALID_CHARACTER_VALUE_FOR_CAST: SqlState = SqlState(Cow::Borrowed("22018")); + +/// 22007 +pub const INVALID_DATETIME_FORMAT: SqlState = SqlState(Cow::Borrowed("22007")); + +/// 22019 +pub const INVALID_ESCAPE_CHARACTER: SqlState = SqlState(Cow::Borrowed("22019")); + +/// 2200D +pub const INVALID_ESCAPE_OCTET: SqlState = SqlState(Cow::Borrowed("2200D")); + +/// 22025 +pub const INVALID_ESCAPE_SEQUENCE: SqlState = SqlState(Cow::Borrowed("22025")); + +/// 22P06 +pub const NONSTANDARD_USE_OF_ESCAPE_CHARACTER: SqlState = SqlState(Cow::Borrowed("22P06")); + +/// 22010 +pub const INVALID_INDICATOR_PARAMETER_VALUE: SqlState = SqlState(Cow::Borrowed("22010")); + +/// 22023 +pub const INVALID_PARAMETER_VALUE: SqlState = SqlState(Cow::Borrowed("22023")); + +/// 2201B +pub const INVALID_REGULAR_EXPRESSION: SqlState = SqlState(Cow::Borrowed("2201B")); + +/// 2201W +pub const INVALID_ROW_COUNT_IN_LIMIT_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201W")); + +/// 2201X +pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201X")); + +/// 2202H +pub const INVALID_TABLESAMPLE_ARGUMENT: SqlState = SqlState(Cow::Borrowed("2202H")); + +/// 2202G +pub const INVALID_TABLESAMPLE_REPEAT: SqlState = SqlState(Cow::Borrowed("2202G")); + +/// 22009 +pub const INVALID_TIME_ZONE_DISPLACEMENT_VALUE: SqlState = SqlState(Cow::Borrowed("22009")); + +/// 2200C +pub const INVALID_USE_OF_ESCAPE_CHARACTER: SqlState = SqlState(Cow::Borrowed("2200C")); + +/// 2200G +pub const MOST_SPECIFIC_TYPE_MISMATCH: SqlState = SqlState(Cow::Borrowed("2200G")); + +/// 22004 +pub const NULL_VALUE_NOT_ALLOWED: SqlState = SqlState(Cow::Borrowed("22004")); + +/// 22002 +pub const NULL_VALUE_NO_INDICATOR_PARAMETER: SqlState = SqlState(Cow::Borrowed("22002")); + +/// 22003 +pub const NUMERIC_VALUE_OUT_OF_RANGE: SqlState = SqlState(Cow::Borrowed("22003")); + +/// 2200H +pub const SEQUENCE_GENERATOR_LIMIT_EXCEEDED: SqlState = SqlState(Cow::Borrowed("2200H")); + +/// 22026 +pub const STRING_DATA_LENGTH_MISMATCH: SqlState = SqlState(Cow::Borrowed("22026")); + +/// 22001 +pub const STRING_DATA_RIGHT_TRUNCATION: SqlState = SqlState(Cow::Borrowed("22001")); + +/// 22011 +pub const SUBSTRING_ERROR: SqlState = SqlState(Cow::Borrowed("22011")); + +/// 22027 +pub const TRIM_ERROR: SqlState = SqlState(Cow::Borrowed("22027")); + +/// 22024 +pub const UNTERMINATED_C_STRING: SqlState = SqlState(Cow::Borrowed("22024")); + +/// 2200F +pub const ZERO_LENGTH_CHARACTER_STRING: SqlState = SqlState(Cow::Borrowed("2200F")); + +/// 22P01 +pub const FLOATING_POINT_EXCEPTION: SqlState = SqlState(Cow::Borrowed("22P01")); + +/// 22P02 +pub const INVALID_TEXT_REPRESENTATION: SqlState = SqlState(Cow::Borrowed("22P02")); + +/// 22P03 +pub const INVALID_BINARY_REPRESENTATION: SqlState = SqlState(Cow::Borrowed("22P03")); + +/// 22P04 +pub const BAD_COPY_FILE_FORMAT: SqlState = SqlState(Cow::Borrowed("22P04")); + +/// 22P05 +pub const UNTRANSLATABLE_CHARACTER: SqlState = SqlState(Cow::Borrowed("22P05")); + +/// 2200L +pub const NOT_AN_XML_DOCUMENT: SqlState = SqlState(Cow::Borrowed("2200L")); + +/// 2200M +pub const INVALID_XML_DOCUMENT: SqlState = SqlState(Cow::Borrowed("2200M")); + +/// 2200N +pub const INVALID_XML_CONTENT: SqlState = SqlState(Cow::Borrowed("2200N")); + +/// 2200S +pub const INVALID_XML_COMMENT: SqlState = SqlState(Cow::Borrowed("2200S")); + +/// 2200T +pub const INVALID_XML_PROCESSING_INSTRUCTION: SqlState = SqlState(Cow::Borrowed("2200T")); + +/// 23000 +pub const INTEGRITY_CONSTRAINT_VIOLATION: SqlState = SqlState(Cow::Borrowed("23000")); + +/// 23001 +pub const RESTRICT_VIOLATION: SqlState = SqlState(Cow::Borrowed("23001")); + +/// 23502 +pub const NOT_NULL_VIOLATION: SqlState = SqlState(Cow::Borrowed("23502")); + +/// 23503 +pub const FOREIGN_KEY_VIOLATION: SqlState = SqlState(Cow::Borrowed("23503")); + +/// 23505 +pub const UNIQUE_VIOLATION: SqlState = SqlState(Cow::Borrowed("23505")); + +/// 23514 +pub const CHECK_VIOLATION: SqlState = SqlState(Cow::Borrowed("23514")); + +/// 23P01 +pub const EXCLUSION_VIOLATION: SqlState = SqlState(Cow::Borrowed("23P01")); + +/// 24000 +pub const INVALID_CURSOR_STATE: SqlState = SqlState(Cow::Borrowed("24000")); + +/// 25000 +pub const INVALID_TRANSACTION_STATE: SqlState = SqlState(Cow::Borrowed("25000")); + +/// 25001 +pub const ACTIVE_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25001")); + +/// 25002 +pub const BRANCH_TRANSACTION_ALREADY_ACTIVE: SqlState = SqlState(Cow::Borrowed("25002")); + +/// 25008 +pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = SqlState(Cow::Borrowed("25008")); + +/// 25003 +pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25003")); + +/// 25004 +pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25004")); + +/// 25005 +pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25005")); + +/// 25006 +pub const READ_ONLY_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25006")); + +/// 25007 +pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = SqlState(Cow::Borrowed("25007")); + +/// 25P01 +pub const NO_ACTIVE_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25P01")); + +/// 25P02 +pub const IN_FAILED_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25P02")); + +/// 25P03 +pub const IDLE_IN_TRANSACTION_SESSION_TIMEOUT: SqlState = SqlState(Cow::Borrowed("25P03")); + +/// 26000 +pub const INVALID_SQL_STATEMENT_NAME: SqlState = SqlState(Cow::Borrowed("26000")); + +/// 26000 +pub const UNDEFINED_PSTATEMENT: SqlState = SqlState(Cow::Borrowed("26000")); + +/// 27000 +pub const TRIGGERED_DATA_CHANGE_VIOLATION: SqlState = SqlState(Cow::Borrowed("27000")); + +/// 28000 +pub const INVALID_AUTHORIZATION_SPECIFICATION: SqlState = SqlState(Cow::Borrowed("28000")); + +/// 28P01 +pub const INVALID_PASSWORD: SqlState = SqlState(Cow::Borrowed("28P01")); + +/// 2B000 +pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2B000")); + +/// 2BP01 +pub const DEPENDENT_OBJECTS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2BP01")); + +/// 2D000 +pub const INVALID_TRANSACTION_TERMINATION: SqlState = SqlState(Cow::Borrowed("2D000")); + +/// 2F000 +pub const SQL_ROUTINE_EXCEPTION: SqlState = SqlState(Cow::Borrowed("2F000")); + +/// 2F005 +pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = SqlState(Cow::Borrowed("2F005")); + +/// 2F002 +pub const S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("2F002")); + +/// 2F003 +pub const S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED: SqlState = SqlState(Cow::Borrowed("2F003")); + +/// 2F004 +pub const S_R_E_READING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("2F004")); + +/// 34000 +pub const INVALID_CURSOR_NAME: SqlState = SqlState(Cow::Borrowed("34000")); + +/// 34000 +pub const UNDEFINED_CURSOR: SqlState = SqlState(Cow::Borrowed("34000")); + +/// 38000 +pub const EXTERNAL_ROUTINE_EXCEPTION: SqlState = SqlState(Cow::Borrowed("38000")); + +/// 38001 +pub const E_R_E_CONTAINING_SQL_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("38001")); + +/// 38002 +pub const E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("38002")); + +/// 38003 +pub const E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED: SqlState = SqlState(Cow::Borrowed("38003")); + +/// 38004 +pub const E_R_E_READING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("38004")); + +/// 39000 +pub const EXTERNAL_ROUTINE_INVOCATION_EXCEPTION: SqlState = SqlState(Cow::Borrowed("39000")); + +/// 39001 +pub const E_R_I_E_INVALID_SQLSTATE_RETURNED: SqlState = SqlState(Cow::Borrowed("39001")); + +/// 39004 +pub const E_R_I_E_NULL_VALUE_NOT_ALLOWED: SqlState = SqlState(Cow::Borrowed("39004")); + +/// 39P01 +pub const E_R_I_E_TRIGGER_PROTOCOL_VIOLATED: SqlState = SqlState(Cow::Borrowed("39P01")); + +/// 39P02 +pub const E_R_I_E_SRF_PROTOCOL_VIOLATED: SqlState = SqlState(Cow::Borrowed("39P02")); + +/// 39P03 +pub const E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED: SqlState = SqlState(Cow::Borrowed("39P03")); + +/// 3B000 +pub const SAVEPOINT_EXCEPTION: SqlState = SqlState(Cow::Borrowed("3B000")); + +/// 3B001 +pub const S_E_INVALID_SPECIFICATION: SqlState = SqlState(Cow::Borrowed("3B001")); + +/// 3D000 +pub const INVALID_CATALOG_NAME: SqlState = SqlState(Cow::Borrowed("3D000")); + +/// 3D000 +pub const UNDEFINED_DATABASE: SqlState = SqlState(Cow::Borrowed("3D000")); + +/// 3F000 +pub const INVALID_SCHEMA_NAME: SqlState = SqlState(Cow::Borrowed("3F000")); + +/// 3F000 +pub const UNDEFINED_SCHEMA: SqlState = SqlState(Cow::Borrowed("3F000")); + +/// 40000 +pub const TRANSACTION_ROLLBACK: SqlState = SqlState(Cow::Borrowed("40000")); + +/// 40002 +pub const T_R_INTEGRITY_CONSTRAINT_VIOLATION: SqlState = SqlState(Cow::Borrowed("40002")); + +/// 40001 +pub const T_R_SERIALIZATION_FAILURE: SqlState = SqlState(Cow::Borrowed("40001")); + +/// 40003 +pub const T_R_STATEMENT_COMPLETION_UNKNOWN: SqlState = SqlState(Cow::Borrowed("40003")); + +/// 40P01 +pub const T_R_DEADLOCK_DETECTED: SqlState = SqlState(Cow::Borrowed("40P01")); + +/// 42000 +pub const SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION: SqlState = SqlState(Cow::Borrowed("42000")); + +/// 42601 +pub const SYNTAX_ERROR: SqlState = SqlState(Cow::Borrowed("42601")); + +/// 42501 +pub const INSUFFICIENT_PRIVILEGE: SqlState = SqlState(Cow::Borrowed("42501")); + +/// 42846 +pub const CANNOT_COERCE: SqlState = SqlState(Cow::Borrowed("42846")); + +/// 42803 +pub const GROUPING_ERROR: SqlState = SqlState(Cow::Borrowed("42803")); + +/// 42P20 +pub const WINDOWING_ERROR: SqlState = SqlState(Cow::Borrowed("42P20")); + +/// 42P19 +pub const INVALID_RECURSION: SqlState = SqlState(Cow::Borrowed("42P19")); + +/// 42830 +pub const INVALID_FOREIGN_KEY: SqlState = SqlState(Cow::Borrowed("42830")); + +/// 42602 +pub const INVALID_NAME: SqlState = SqlState(Cow::Borrowed("42602")); + +/// 42622 +pub const NAME_TOO_LONG: SqlState = SqlState(Cow::Borrowed("42622")); + +/// 42939 +pub const RESERVED_NAME: SqlState = SqlState(Cow::Borrowed("42939")); + +/// 42804 +pub const DATATYPE_MISMATCH: SqlState = SqlState(Cow::Borrowed("42804")); + +/// 42P18 +pub const INDETERMINATE_DATATYPE: SqlState = SqlState(Cow::Borrowed("42P18")); + +/// 42P21 +pub const COLLATION_MISMATCH: SqlState = SqlState(Cow::Borrowed("42P21")); + +/// 42P22 +pub const INDETERMINATE_COLLATION: SqlState = SqlState(Cow::Borrowed("42P22")); + +/// 42809 +pub const WRONG_OBJECT_TYPE: SqlState = SqlState(Cow::Borrowed("42809")); + +/// 428C9 +pub const GENERATED_ALWAYS: SqlState = SqlState(Cow::Borrowed("428C9")); + +/// 42703 +pub const UNDEFINED_COLUMN: SqlState = SqlState(Cow::Borrowed("42703")); + +/// 42883 +pub const UNDEFINED_FUNCTION: SqlState = SqlState(Cow::Borrowed("42883")); + +/// 42P01 +pub const UNDEFINED_TABLE: SqlState = SqlState(Cow::Borrowed("42P01")); + +/// 42P02 +pub const UNDEFINED_PARAMETER: SqlState = SqlState(Cow::Borrowed("42P02")); + +/// 42704 +pub const UNDEFINED_OBJECT: SqlState = SqlState(Cow::Borrowed("42704")); + +/// 42701 +pub const DUPLICATE_COLUMN: SqlState = SqlState(Cow::Borrowed("42701")); + +/// 42P03 +pub const DUPLICATE_CURSOR: SqlState = SqlState(Cow::Borrowed("42P03")); + +/// 42P04 +pub const DUPLICATE_DATABASE: SqlState = SqlState(Cow::Borrowed("42P04")); + +/// 42723 +pub const DUPLICATE_FUNCTION: SqlState = SqlState(Cow::Borrowed("42723")); + +/// 42P05 +pub const DUPLICATE_PSTATEMENT: SqlState = SqlState(Cow::Borrowed("42P05")); + +/// 42P06 +pub const DUPLICATE_SCHEMA: SqlState = SqlState(Cow::Borrowed("42P06")); + +/// 42P07 +pub const DUPLICATE_TABLE: SqlState = SqlState(Cow::Borrowed("42P07")); + +/// 42712 +pub const DUPLICATE_ALIAS: SqlState = SqlState(Cow::Borrowed("42712")); + +/// 42710 +pub const DUPLICATE_OBJECT: SqlState = SqlState(Cow::Borrowed("42710")); + +/// 42702 +pub const AMBIGUOUS_COLUMN: SqlState = SqlState(Cow::Borrowed("42702")); + +/// 42725 +pub const AMBIGUOUS_FUNCTION: SqlState = SqlState(Cow::Borrowed("42725")); + +/// 42P08 +pub const AMBIGUOUS_PARAMETER: SqlState = SqlState(Cow::Borrowed("42P08")); + +/// 42P09 +pub const AMBIGUOUS_ALIAS: SqlState = SqlState(Cow::Borrowed("42P09")); + +/// 42P10 +pub const INVALID_COLUMN_REFERENCE: SqlState = SqlState(Cow::Borrowed("42P10")); + +/// 42611 +pub const INVALID_COLUMN_DEFINITION: SqlState = SqlState(Cow::Borrowed("42611")); + +/// 42P11 +pub const INVALID_CURSOR_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P11")); + +/// 42P12 +pub const INVALID_DATABASE_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P12")); + +/// 42P13 +pub const INVALID_FUNCTION_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P13")); + +/// 42P14 +pub const INVALID_PSTATEMENT_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P14")); + +/// 42P15 +pub const INVALID_SCHEMA_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P15")); + +/// 42P16 +pub const INVALID_TABLE_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P16")); + +/// 42P17 +pub const INVALID_OBJECT_DEFINITION: SqlState = SqlState(Cow::Borrowed("42P17")); + +/// 44000 +pub const WITH_CHECK_OPTION_VIOLATION: SqlState = SqlState(Cow::Borrowed("44000")); + +/// 53000 +pub const INSUFFICIENT_RESOURCES: SqlState = SqlState(Cow::Borrowed("53000")); + +/// 53100 +pub const DISK_FULL: SqlState = SqlState(Cow::Borrowed("53100")); + +/// 53200 +pub const OUT_OF_MEMORY: SqlState = SqlState(Cow::Borrowed("53200")); + +/// 53300 +pub const TOO_MANY_CONNECTIONS: SqlState = SqlState(Cow::Borrowed("53300")); + +/// 53400 +pub const CONFIGURATION_LIMIT_EXCEEDED: SqlState = SqlState(Cow::Borrowed("53400")); + +/// 54000 +pub const PROGRAM_LIMIT_EXCEEDED: SqlState = SqlState(Cow::Borrowed("54000")); + +/// 54001 +pub const STATEMENT_TOO_COMPLEX: SqlState = SqlState(Cow::Borrowed("54001")); + +/// 54011 +pub const TOO_MANY_COLUMNS: SqlState = SqlState(Cow::Borrowed("54011")); + +/// 54023 +pub const TOO_MANY_ARGUMENTS: SqlState = SqlState(Cow::Borrowed("54023")); + +/// 55000 +pub const OBJECT_NOT_IN_PREREQUISITE_STATE: SqlState = SqlState(Cow::Borrowed("55000")); + +/// 55006 +pub const OBJECT_IN_USE: SqlState = SqlState(Cow::Borrowed("55006")); + +/// 55P02 +pub const CANT_CHANGE_RUNTIME_PARAM: SqlState = SqlState(Cow::Borrowed("55P02")); + +/// 55P03 +pub const LOCK_NOT_AVAILABLE: SqlState = SqlState(Cow::Borrowed("55P03")); + +/// 55P04 +pub const UNSAFE_NEW_ENUM_VALUE_USAGE: SqlState = SqlState(Cow::Borrowed("55P04")); + +/// 57000 +pub const OPERATOR_INTERVENTION: SqlState = SqlState(Cow::Borrowed("57000")); + +/// 57014 +pub const QUERY_CANCELED: SqlState = SqlState(Cow::Borrowed("57014")); + +/// 57P01 +pub const ADMIN_SHUTDOWN: SqlState = SqlState(Cow::Borrowed("57P01")); + +/// 57P02 +pub const CRASH_SHUTDOWN: SqlState = SqlState(Cow::Borrowed("57P02")); + +/// 57P03 +pub const CANNOT_CONNECT_NOW: SqlState = SqlState(Cow::Borrowed("57P03")); + +/// 57P04 +pub const DATABASE_DROPPED: SqlState = SqlState(Cow::Borrowed("57P04")); + +/// 58000 +pub const SYSTEM_ERROR: SqlState = SqlState(Cow::Borrowed("58000")); + +/// 58030 +pub const IO_ERROR: SqlState = SqlState(Cow::Borrowed("58030")); + +/// 58P01 +pub const UNDEFINED_FILE: SqlState = SqlState(Cow::Borrowed("58P01")); + +/// 58P02 +pub const DUPLICATE_FILE: SqlState = SqlState(Cow::Borrowed("58P02")); + +/// 72000 +pub const SNAPSHOT_TOO_OLD: SqlState = SqlState(Cow::Borrowed("72000")); + +/// F0000 +pub const CONFIG_FILE_ERROR: SqlState = SqlState(Cow::Borrowed("F0000")); + +/// F0001 +pub const LOCK_FILE_EXISTS: SqlState = SqlState(Cow::Borrowed("F0001")); + +/// HV000 +pub const FDW_ERROR: SqlState = SqlState(Cow::Borrowed("HV000")); + +/// HV005 +pub const FDW_COLUMN_NAME_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("HV005")); + +/// HV002 +pub const FDW_DYNAMIC_PARAMETER_VALUE_NEEDED: SqlState = SqlState(Cow::Borrowed("HV002")); + +/// HV010 +pub const FDW_FUNCTION_SEQUENCE_ERROR: SqlState = SqlState(Cow::Borrowed("HV010")); + +/// HV021 +pub const FDW_INCONSISTENT_DESCRIPTOR_INFORMATION: SqlState = SqlState(Cow::Borrowed("HV021")); + +/// HV024 +pub const FDW_INVALID_ATTRIBUTE_VALUE: SqlState = SqlState(Cow::Borrowed("HV024")); + +/// HV007 +pub const FDW_INVALID_COLUMN_NAME: SqlState = SqlState(Cow::Borrowed("HV007")); + +/// HV008 +pub const FDW_INVALID_COLUMN_NUMBER: SqlState = SqlState(Cow::Borrowed("HV008")); + +/// HV004 +pub const FDW_INVALID_DATA_TYPE: SqlState = SqlState(Cow::Borrowed("HV004")); + +/// HV006 +pub const FDW_INVALID_DATA_TYPE_DESCRIPTORS: SqlState = SqlState(Cow::Borrowed("HV006")); + +/// HV091 +pub const FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER: SqlState = SqlState(Cow::Borrowed("HV091")); + +/// HV00B +pub const FDW_INVALID_HANDLE: SqlState = SqlState(Cow::Borrowed("HV00B")); + +/// HV00C +pub const FDW_INVALID_OPTION_INDEX: SqlState = SqlState(Cow::Borrowed("HV00C")); + +/// HV00D +pub const FDW_INVALID_OPTION_NAME: SqlState = SqlState(Cow::Borrowed("HV00D")); + +/// HV090 +pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = SqlState(Cow::Borrowed("HV090")); + +/// HV00A +pub const FDW_INVALID_STRING_FORMAT: SqlState = SqlState(Cow::Borrowed("HV00A")); + +/// HV009 +pub const FDW_INVALID_USE_OF_NULL_POINTER: SqlState = SqlState(Cow::Borrowed("HV009")); + +/// HV014 +pub const FDW_TOO_MANY_HANDLES: SqlState = SqlState(Cow::Borrowed("HV014")); + +/// HV001 +pub const FDW_OUT_OF_MEMORY: SqlState = SqlState(Cow::Borrowed("HV001")); + +/// HV00P +pub const FDW_NO_SCHEMAS: SqlState = SqlState(Cow::Borrowed("HV00P")); + +/// HV00J +pub const FDW_OPTION_NAME_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("HV00J")); + +/// HV00K +pub const FDW_REPLY_HANDLE: SqlState = SqlState(Cow::Borrowed("HV00K")); + +/// HV00Q +pub const FDW_SCHEMA_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("HV00Q")); + +/// HV00R +pub const FDW_TABLE_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("HV00R")); + +/// HV00L +pub const FDW_UNABLE_TO_CREATE_EXECUTION: SqlState = SqlState(Cow::Borrowed("HV00L")); + +/// HV00M +pub const FDW_UNABLE_TO_CREATE_REPLY: SqlState = SqlState(Cow::Borrowed("HV00M")); + +/// HV00N +pub const FDW_UNABLE_TO_ESTABLISH_CONNECTION: SqlState = SqlState(Cow::Borrowed("HV00N")); + +/// P0000 +pub const PLPGSQL_ERROR: SqlState = SqlState(Cow::Borrowed("P0000")); + +/// P0001 +pub const RAISE_EXCEPTION: SqlState = SqlState(Cow::Borrowed("P0001")); + +/// P0002 +pub const NO_DATA_FOUND: SqlState = SqlState(Cow::Borrowed("P0002")); + +/// P0003 +pub const TOO_MANY_ROWS: SqlState = SqlState(Cow::Borrowed("P0003")); + +/// P0004 +pub const ASSERT_FAILURE: SqlState = SqlState(Cow::Borrowed("P0004")); + +/// XX000 +pub const INTERNAL_ERROR: SqlState = SqlState(Cow::Borrowed("XX000")); + +/// XX001 +pub const DATA_CORRUPTED: SqlState = SqlState(Cow::Borrowed("XX001")); + +/// XX002 +pub const INDEX_CORRUPTED: SqlState = SqlState(Cow::Borrowed("XX002")); + #[cfg_attr(rustfmt, rustfmt_skip)] static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map { key: 1897749892740154578, @@ -546,504 +817,246 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map { (1, 94), ]), entries: ::phf::Slice::Static(&[ - ("23001", SqlState::RestrictViolation), - ("42830", SqlState::InvalidForeignKey), - ("P0000", SqlState::PlpgsqlError), - ("58000", SqlState::SystemError), - ("57P01", SqlState::AdminShutdown), - ("22P04", SqlState::BadCopyFileFormat), - ("42P05", SqlState::DuplicatePreparedStatement), - ("28000", SqlState::InvalidAuthorizationSpecification), - ("2202E", SqlState::ArraySubscriptError), - ("2F005", SqlState::FunctionExecutedNoReturnStatement), - ("53400", SqlState::ConfigurationLimitExceeded), - ("20000", SqlState::CaseNotFound), - ("25004", SqlState::InappropriateIsolationLevelForBranchTransaction), - ("09000", SqlState::TriggeredActionException), - ("42P10", SqlState::InvalidColumnReference), - ("39P03", SqlState::EventTriggerProtocolViolated), - ("08000", SqlState::ConnectionException), - ("08006", SqlState::ConnectionFailure), - ("2201W", SqlState::InvalidRowCountInLimitClause), - ("03000", SqlState::SqlStatementNotYetComplete), - ("22014", SqlState::InvalidArgumentForNtileFunction), - ("42611", SqlState::InvalidColumnDefinition), - ("42P11", SqlState::InvalidCursorDefinition), - ("2200N", SqlState::InvalidXmlContent), - ("57014", SqlState::QueryCanceled), - ("01003", SqlState::NullValueEliminatedInSetFunction), - ("01000", SqlState::Warning), - ("55P04", SqlState::UnsafeNewEnumValueUsage), - ("25003", SqlState::InappropriateAccessModeForBranchTransaction), - ("2200L", SqlState::NotAnXmlDocument), - ("42846", SqlState::CannotCoerce), - ("55P03", SqlState::LockNotAvailable), - ("08007", SqlState::TransactionResolutionUnknown), - ("XX000", SqlState::InternalError), - ("22005", SqlState::ErrorInAssignment), - ("22P03", SqlState::InvalidBinaryRepresentation), - ("2201X", SqlState::InvalidRowCountInResultOffsetClause), - ("54011", SqlState::TooManyColumns), - ("HV008", SqlState::FdwInvalidColumnNumber), - ("HV009", SqlState::FdwInvalidUseOfNullPointer), - ("0LP01", SqlState::InvalidGrantOperation), - ("42704", SqlState::UndefinedObject), - ("25005", SqlState::NoActiveSqlTransactionForBranchTransaction), - ("25P03", SqlState::IdleInTransactionSessionTimeout), - ("44000", SqlState::WithCheckOptionViolation), - ("22024", SqlState::UnterminatedCString), - ("0L000", SqlState::InvalidGrantor), - ("40000", SqlState::TransactionRollback), - ("42P08", SqlState::AmbiguousParameter), - ("38000", SqlState::ExternalRoutineException), - ("42939", SqlState::ReservedName), - ("40001", SqlState::SerializationFailure), - ("HV00K", SqlState::FdwReplyHandle), - ("2F002", SqlState::SqlRoutineModifyingSqlDataNotPermitted), - ("HV001", SqlState::FdwOutOfMemory), - ("42P19", SqlState::InvalidRecursion), - ("HV002", SqlState::FdwDynamicParameterValueNeeded), - ("0A000", SqlState::FeatureNotSupported), - ("58P02", SqlState::DuplicateFile), - ("25006", SqlState::ReadOnlySqlTransaction), - ("22009", SqlState::InvalidTimeZoneDisplacementValue), - ("0F001", SqlState::InvalidLocatorSpecification), - ("P0002", SqlState::NoDataFound), - ("2F000", SqlState::SqlRoutineException), - ("01006", SqlState::PrivilegeNotRevoked), - ("22025", SqlState::InvalidEscapeSequence), - ("22027", SqlState::TrimError), - ("54001", SqlState::StatementTooComplex), - ("42602", SqlState::InvalidName), - ("54023", SqlState::TooManyArguments), - ("2200T", SqlState::InvalidXmlProcessingInstruction), - ("01007", SqlState::PrivilegeNotGranted), - ("22000", SqlState::DataException), - ("28P01", SqlState::InvalidPassword), - ("23514", SqlState::CheckViolation), - ("39P02", SqlState::SrfProtocolViolated), - ("57P02", SqlState::CrashShutdown), - ("42P03", SqlState::DuplicateCursor), - ("22021", SqlState::CharacterNotInRepertoire), - ("HV00P", SqlState::FdwNoSchemas), - ("42701", SqlState::DuplicateColumn), - ("42P15", SqlState::InvalidSchemaDefinition), - ("HV00B", SqlState::FdwInvalidHandle), - ("34000", SqlState::InvalidCursorName), - ("22P06", SqlState::NonstandardUseOfEscapeCharacter), - ("P0001", SqlState::RaiseException), - ("08P01", SqlState::ProtocolViolation), - ("42723", SqlState::DuplicateFunction), - ("08001", SqlState::SqlclientUnableToEstablishSqlconnection), - ("HV006", SqlState::FdwInvalidDataTypeDescriptors), - ("23000", SqlState::IntegrityConstraintViolation), - ("42712", SqlState::DuplicateAlias), - ("2201G", SqlState::InvalidArgumentForWidthBucketFunction), - ("2200F", SqlState::ZeroLengthCharacterString), - ("XX002", SqlState::IndexCorrupted), - ("53300", SqlState::TooManyConnections), - ("38002", SqlState::ForeignRoutineModifyingSqlDataNotPermitted), - ("22015", SqlState::IntervalFieldOverflow), - ("22P01", SqlState::FloatingPointException), - ("22012", SqlState::DivisionByZero), - ("XX001", SqlState::DataCorrupted), - ("0100C", SqlState::DynamicResultSetsReturned), - ("42P01", SqlState::UndefinedTable), - ("25002", SqlState::BranchTransactionAlreadyActive), - ("2D000", SqlState::InvalidTransactionTermination), - ("P0004", SqlState::AssertFailure), - ("2200C", SqlState::InvalidUseOfEscapeCharacter), - ("HV00R", SqlState::FdwTableNotFound), - ("22016", SqlState::InvalidArgumentForNthValueFunction), - ("01P01", SqlState::DeprecatedFeature), - ("F0000", SqlState::ConfigFileError), - ("0Z000", SqlState::DiagnosticsException), - ("42P02", SqlState::UndefinedParameter), - ("2200S", SqlState::InvalidXmlComment), - ("2200H", SqlState::SequenceGeneratorLimitExceeded), - ("HV00C", SqlState::FdwInvalidOptionIndex), - ("38004", SqlState::ForeignRoutineReadingSqlDataNotPermitted), - ("42703", SqlState::UndefinedColumn), - ("23503", SqlState::ForeignKeyViolation), - ("42000", SqlState::SyntaxErrorOrAccessRuleViolation), - ("22004", SqlState::DataNullValueNotAllowed), - ("25008", SqlState::HeldCursorRequiresSameIsolationLevel), - ("22018", SqlState::InvalidCharacterValueForCast), - ("22023", SqlState::InvalidParameterValue), - ("22011", SqlState::SubstringError), - ("40002", SqlState::TransactionIntegrityConstraintViolation), - ("42803", SqlState::GroupingError), - ("72000", SqlState::SnapshotTooOld), - ("HV010", SqlState::FdwFunctionSequenceError), - ("42809", SqlState::WrongObjectType), - ("42P16", SqlState::InvalidTableDefinition), - ("HV00D", SqlState::FdwInvalidOptionName), - ("39000", SqlState::ExternalRoutineInvocationException), - ("2202G", SqlState::InvalidTablesampleRepeat), - ("42601", SqlState::SyntaxError), - ("42622", SqlState::NameTooLong), - ("HV00L", SqlState::FdwUnableToCreateExecution), - ("25000", SqlState::InvalidTransactionState), - ("3B000", SqlState::SavepointException), - ("42P21", SqlState::CollationMismatch), - ("23505", SqlState::UniqueViolation), - ("22001", SqlState::DataStringDataRightTruncation), - ("02001", SqlState::NoAdditionalDynamicResultSetsReturned), - ("21000", SqlState::CardinalityViolation), - ("58P01", SqlState::UndefinedFile), - ("HV091", SqlState::FdwInvalidDescriptorFieldIdentifier), - ("25P01", SqlState::NoActiveSqlTransaction), - ("40P01", SqlState::DeadlockDetected), - ("HV021", SqlState::FdwInconsistentDescriptorInformation), - ("42P09", SqlState::AmbiguousAlias), - ("25007", SqlState::SchemaAndDataStatementMixingNotSupported), - ("23P01", SqlState::ExclusionViolation), - ("HV00J", SqlState::FdwOptionNameNotFound), - ("58030", SqlState::IoError), - ("HV004", SqlState::FdwInvalidDataType), - ("42710", SqlState::DuplicateObject), - ("HV090", SqlState::FdwInvalidStringLengthOrBufferLength), - ("42P18", SqlState::IndeterminateDatatype), - ("HV00M", SqlState::FdwUnableToCreateReply), - ("42804", SqlState::DatatypeMismatch), - ("24000", SqlState::InvalidCursorState), - ("HV007", SqlState::FdwInvalidColumnName), - ("2201E", SqlState::InvalidArgumentForLogarithm), - ("42P22", SqlState::IndeterminateCollation), - ("22P05", SqlState::UntranslatableCharacter), - ("42P07", SqlState::DuplicateTable), - ("2F004", SqlState::SqlRoutineReadingSqlDataNotPermitted), - ("23502", SqlState::NotNullViolation), - ("57000", SqlState::OperatorIntervention), - ("HV000", SqlState::FdwError), - ("42883", SqlState::UndefinedFunction), - ("2201B", SqlState::InvalidRegularExpression), - ("2200D", SqlState::InvalidEscapeOctet), - ("42P06", SqlState::DuplicateSchema), - ("38003", SqlState::ForeignRoutineProhibitedSqlStatementAttempted), - ("22026", SqlState::StringDataLengthMismatch), - ("P0003", SqlState::TooManyRows), - ("3D000", SqlState::InvalidCatalogName), - ("0B000", SqlState::InvalidTransactionInitiation), - ("55006", SqlState::ObjectInUse), - ("53200", SqlState::OutOfMemory), - ("3F000", SqlState::InvalidSchemaName), - ("53100", SqlState::DiskFull), - ("2F003", SqlState::SqlRoutineProhibitedSqlStatementAttempted), - ("55P02", SqlState::CantChangeRuntimeParam), - ("01004", SqlState::WarningStringDataRightTruncation), - ("3B001", SqlState::InvalidSavepointSpecification), - ("2200G", SqlState::MostSpecificTypeMismatch), - ("428C9", SqlState::GeneratedAlways), - ("HV005", SqlState::FdwColumnNameNotFound), - ("2201F", SqlState::InvalidArgumentForPowerFunction), - ("22022", SqlState::IndicatorOverflow), - ("HV00Q", SqlState::FdwSchemaNotFound), - ("0F000", SqlState::LocatorException), - ("22002", SqlState::NullValueNoIndicatorParameter), - ("02000", SqlState::NoData), - ("2202H", SqlState::InvalidTablesampleArgument), - ("27000", SqlState::TriggeredDataChangeViolation), - ("2BP01", SqlState::DependentObjectsStillExist), - ("55000", SqlState::ObjectNotInPrerequisiteState), - ("39001", SqlState::InvalidSqlstateReturned), - ("08004", SqlState::SqlserverRejectedEstablishmentOfSqlconnection), - ("42P13", SqlState::InvalidFunctionDefinition), - ("HV024", SqlState::FdwInvalidAttributeValue), - ("22019", SqlState::InvalidEscapeCharacter), - ("54000", SqlState::ProgramLimitExceeded), - ("42501", SqlState::InsufficientPrivilege), - ("HV00A", SqlState::FdwInvalidStringFormat), - ("42702", SqlState::AmbiguousColumn), - ("53000", SqlState::InsufficientResources), - ("25P02", SqlState::InFailedSqlTransaction), - ("22010", SqlState::InvalidIndicatorParameterValue), - ("01008", SqlState::ImplicitZeroBitPadding), - ("HV014", SqlState::FdwTooManyHandles), - ("42P20", SqlState::WindowingError), - ("42725", SqlState::AmbiguousFunction), - ("F0001", SqlState::LockFileExists), - ("08003", SqlState::ConnectionDoesNotExist), - ("2200M", SqlState::InvalidXmlDocument), - ("22003", SqlState::NumericValueOutOfRange), - ("39004", SqlState::ExternalRoutineInvocationNullValueNotAllowed), - ("2200B", SqlState::EscapeCharacterConflict), - ("0P000", SqlState::InvalidRoleSpecification), - ("00000", SqlState::SuccessfulCompletion), - ("22P02", SqlState::InvalidTextRepresentation), - ("25001", SqlState::ActiveSqlTransaction), - ("HV00N", SqlState::FdwUnableToEstablishConnection), - ("39P01", SqlState::TriggerProtocolViolated), - ("2B000", SqlState::DependentPrivilegeDescriptorsStillExist), - ("22008", SqlState::DatetimeFieldOverflow), - ("42P14", SqlState::InvalidPreparedStatementDefinition), - ("57P04", SqlState::DatabaseDropped), - ("26000", SqlState::InvalidSqlStatementName), - ("42P17", SqlState::InvalidObjectDefinition), - ("42P04", SqlState::DuplicateDatabase), - ("38001", SqlState::ContainingSqlNotPermitted), - ("0Z002", SqlState::StackedDiagnosticsAccessedWithoutActiveHandler), - ("22007", SqlState::InvalidDatetimeFormat), - ("40003", SqlState::StatementCompletionUnknown), - ("42P12", SqlState::InvalidDatabaseDefinition), - ("57P03", SqlState::CannotConnectNow), + ("23001", RESTRICT_VIOLATION), + ("42830", INVALID_FOREIGN_KEY), + ("P0000", PLPGSQL_ERROR), + ("58000", SYSTEM_ERROR), + ("57P01", ADMIN_SHUTDOWN), + ("22P04", BAD_COPY_FILE_FORMAT), + ("42P05", DUPLICATE_PSTATEMENT), + ("28000", INVALID_AUTHORIZATION_SPECIFICATION), + ("2202E", ARRAY_ELEMENT_ERROR), + ("2F005", S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), + ("53400", CONFIGURATION_LIMIT_EXCEEDED), + ("20000", CASE_NOT_FOUND), + ("25004", INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION), + ("09000", TRIGGERED_ACTION_EXCEPTION), + ("42P10", INVALID_COLUMN_REFERENCE), + ("39P03", E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED), + ("08000", CONNECTION_EXCEPTION), + ("08006", CONNECTION_FAILURE), + ("2201W", INVALID_ROW_COUNT_IN_LIMIT_CLAUSE), + ("03000", SQL_STATEMENT_NOT_YET_COMPLETE), + ("22014", INVALID_ARGUMENT_FOR_NTILE), + ("42611", INVALID_COLUMN_DEFINITION), + ("42P11", INVALID_CURSOR_DEFINITION), + ("2200N", INVALID_XML_CONTENT), + ("57014", QUERY_CANCELED), + ("01003", WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION), + ("01000", WARNING), + ("55P04", UNSAFE_NEW_ENUM_VALUE_USAGE), + ("25003", INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION), + ("2200L", NOT_AN_XML_DOCUMENT), + ("42846", CANNOT_COERCE), + ("55P03", LOCK_NOT_AVAILABLE), + ("08007", TRANSACTION_RESOLUTION_UNKNOWN), + ("XX000", INTERNAL_ERROR), + ("22005", ERROR_IN_ASSIGNMENT), + ("22P03", INVALID_BINARY_REPRESENTATION), + ("2201X", INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE), + ("54011", TOO_MANY_COLUMNS), + ("HV008", FDW_INVALID_COLUMN_NUMBER), + ("HV009", FDW_INVALID_USE_OF_NULL_POINTER), + ("0LP01", INVALID_GRANT_OPERATION), + ("42704", UNDEFINED_OBJECT), + ("25005", NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION), + ("25P03", IDLE_IN_TRANSACTION_SESSION_TIMEOUT), + ("44000", WITH_CHECK_OPTION_VIOLATION), + ("22024", UNTERMINATED_C_STRING), + ("0L000", INVALID_GRANTOR), + ("40000", TRANSACTION_ROLLBACK), + ("42P08", AMBIGUOUS_PARAMETER), + ("38000", EXTERNAL_ROUTINE_EXCEPTION), + ("42939", RESERVED_NAME), + ("40001", T_R_SERIALIZATION_FAILURE), + ("HV00K", FDW_REPLY_HANDLE), + ("2F002", S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), + ("HV001", FDW_OUT_OF_MEMORY), + ("42P19", INVALID_RECURSION), + ("HV002", FDW_DYNAMIC_PARAMETER_VALUE_NEEDED), + ("0A000", FEATURE_NOT_SUPPORTED), + ("58P02", DUPLICATE_FILE), + ("25006", READ_ONLY_SQL_TRANSACTION), + ("22009", INVALID_TIME_ZONE_DISPLACEMENT_VALUE), + ("0F001", L_E_INVALID_SPECIFICATION), + ("P0002", NO_DATA_FOUND), + ("2F000", SQL_ROUTINE_EXCEPTION), + ("01006", WARNING_PRIVILEGE_NOT_REVOKED), + ("22025", INVALID_ESCAPE_SEQUENCE), + ("22027", TRIM_ERROR), + ("54001", STATEMENT_TOO_COMPLEX), + ("42602", INVALID_NAME), + ("54023", TOO_MANY_ARGUMENTS), + ("2200T", INVALID_XML_PROCESSING_INSTRUCTION), + ("01007", WARNING_PRIVILEGE_NOT_GRANTED), + ("22000", DATA_EXCEPTION), + ("28P01", INVALID_PASSWORD), + ("23514", CHECK_VIOLATION), + ("39P02", E_R_I_E_SRF_PROTOCOL_VIOLATED), + ("57P02", CRASH_SHUTDOWN), + ("42P03", DUPLICATE_CURSOR), + ("22021", CHARACTER_NOT_IN_REPERTOIRE), + ("HV00P", FDW_NO_SCHEMAS), + ("42701", DUPLICATE_COLUMN), + ("42P15", INVALID_SCHEMA_DEFINITION), + ("HV00B", FDW_INVALID_HANDLE), + ("34000", INVALID_CURSOR_NAME), + ("22P06", NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + ("P0001", RAISE_EXCEPTION), + ("08P01", PROTOCOL_VIOLATION), + ("42723", DUPLICATE_FUNCTION), + ("08001", SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), + ("HV006", FDW_INVALID_DATA_TYPE_DESCRIPTORS), + ("23000", INTEGRITY_CONSTRAINT_VIOLATION), + ("42712", DUPLICATE_ALIAS), + ("2201G", INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), + ("2200F", ZERO_LENGTH_CHARACTER_STRING), + ("XX002", INDEX_CORRUPTED), + ("53300", TOO_MANY_CONNECTIONS), + ("38002", E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), + ("22015", INTERVAL_FIELD_OVERFLOW), + ("22P01", FLOATING_POINT_EXCEPTION), + ("22012", DIVISION_BY_ZERO), + ("XX001", DATA_CORRUPTED), + ("0100C", WARNING_DYNAMIC_RESULT_SETS_RETURNED), + ("42P01", UNDEFINED_TABLE), + ("25002", BRANCH_TRANSACTION_ALREADY_ACTIVE), + ("2D000", INVALID_TRANSACTION_TERMINATION), + ("P0004", ASSERT_FAILURE), + ("2200C", INVALID_USE_OF_ESCAPE_CHARACTER), + ("HV00R", FDW_TABLE_NOT_FOUND), + ("22016", INVALID_ARGUMENT_FOR_NTH_VALUE), + ("01P01", WARNING_DEPRECATED_FEATURE), + ("F0000", CONFIG_FILE_ERROR), + ("0Z000", DIAGNOSTICS_EXCEPTION), + ("42P02", UNDEFINED_PARAMETER), + ("2200S", INVALID_XML_COMMENT), + ("2200H", SEQUENCE_GENERATOR_LIMIT_EXCEEDED), + ("HV00C", FDW_INVALID_OPTION_INDEX), + ("38004", E_R_E_READING_SQL_DATA_NOT_PERMITTED), + ("42703", UNDEFINED_COLUMN), + ("23503", FOREIGN_KEY_VIOLATION), + ("42000", SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION), + ("22004", NULL_VALUE_NOT_ALLOWED), + ("25008", HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL), + ("22018", INVALID_CHARACTER_VALUE_FOR_CAST), + ("22023", INVALID_PARAMETER_VALUE), + ("22011", SUBSTRING_ERROR), + ("40002", T_R_INTEGRITY_CONSTRAINT_VIOLATION), + ("42803", GROUPING_ERROR), + ("72000", SNAPSHOT_TOO_OLD), + ("HV010", FDW_FUNCTION_SEQUENCE_ERROR), + ("42809", WRONG_OBJECT_TYPE), + ("42P16", INVALID_TABLE_DEFINITION), + ("HV00D", FDW_INVALID_OPTION_NAME), + ("39000", EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + ("2202G", INVALID_TABLESAMPLE_REPEAT), + ("42601", SYNTAX_ERROR), + ("42622", NAME_TOO_LONG), + ("HV00L", FDW_UNABLE_TO_CREATE_EXECUTION), + ("25000", INVALID_TRANSACTION_STATE), + ("3B000", SAVEPOINT_EXCEPTION), + ("42P21", COLLATION_MISMATCH), + ("23505", UNIQUE_VIOLATION), + ("22001", STRING_DATA_RIGHT_TRUNCATION), + ("02001", NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED), + ("21000", CARDINALITY_VIOLATION), + ("58P01", UNDEFINED_FILE), + ("HV091", FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER), + ("25P01", NO_ACTIVE_SQL_TRANSACTION), + ("40P01", T_R_DEADLOCK_DETECTED), + ("HV021", FDW_INCONSISTENT_DESCRIPTOR_INFORMATION), + ("42P09", AMBIGUOUS_ALIAS), + ("25007", SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED), + ("23P01", EXCLUSION_VIOLATION), + ("HV00J", FDW_OPTION_NAME_NOT_FOUND), + ("58030", IO_ERROR), + ("HV004", FDW_INVALID_DATA_TYPE), + ("42710", DUPLICATE_OBJECT), + ("HV090", FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH), + ("42P18", INDETERMINATE_DATATYPE), + ("HV00M", FDW_UNABLE_TO_CREATE_REPLY), + ("42804", DATATYPE_MISMATCH), + ("24000", INVALID_CURSOR_STATE), + ("HV007", FDW_INVALID_COLUMN_NAME), + ("2201E", INVALID_ARGUMENT_FOR_LOG), + ("42P22", INDETERMINATE_COLLATION), + ("22P05", UNTRANSLATABLE_CHARACTER), + ("42P07", DUPLICATE_TABLE), + ("2F004", S_R_E_READING_SQL_DATA_NOT_PERMITTED), + ("23502", NOT_NULL_VIOLATION), + ("57000", OPERATOR_INTERVENTION), + ("HV000", FDW_ERROR), + ("42883", UNDEFINED_FUNCTION), + ("2201B", INVALID_REGULAR_EXPRESSION), + ("2200D", INVALID_ESCAPE_OCTET), + ("42P06", DUPLICATE_SCHEMA), + ("38003", E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), + ("22026", STRING_DATA_LENGTH_MISMATCH), + ("P0003", TOO_MANY_ROWS), + ("3D000", INVALID_CATALOG_NAME), + ("0B000", INVALID_TRANSACTION_INITIATION), + ("55006", OBJECT_IN_USE), + ("53200", OUT_OF_MEMORY), + ("3F000", INVALID_SCHEMA_NAME), + ("53100", DISK_FULL), + ("2F003", S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), + ("55P02", CANT_CHANGE_RUNTIME_PARAM), + ("01004", WARNING_STRING_DATA_RIGHT_TRUNCATION), + ("3B001", S_E_INVALID_SPECIFICATION), + ("2200G", MOST_SPECIFIC_TYPE_MISMATCH), + ("428C9", GENERATED_ALWAYS), + ("HV005", FDW_COLUMN_NAME_NOT_FOUND), + ("2201F", INVALID_ARGUMENT_FOR_POWER_FUNCTION), + ("22022", INDICATOR_OVERFLOW), + ("HV00Q", FDW_SCHEMA_NOT_FOUND), + ("0F000", LOCATOR_EXCEPTION), + ("22002", NULL_VALUE_NO_INDICATOR_PARAMETER), + ("02000", NO_DATA), + ("2202H", INVALID_TABLESAMPLE_ARGUMENT), + ("27000", TRIGGERED_DATA_CHANGE_VIOLATION), + ("2BP01", DEPENDENT_OBJECTS_STILL_EXIST), + ("55000", OBJECT_NOT_IN_PREREQUISITE_STATE), + ("39001", E_R_I_E_INVALID_SQLSTATE_RETURNED), + ("08004", SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION), + ("42P13", INVALID_FUNCTION_DEFINITION), + ("HV024", FDW_INVALID_ATTRIBUTE_VALUE), + ("22019", INVALID_ESCAPE_CHARACTER), + ("54000", PROGRAM_LIMIT_EXCEEDED), + ("42501", INSUFFICIENT_PRIVILEGE), + ("HV00A", FDW_INVALID_STRING_FORMAT), + ("42702", AMBIGUOUS_COLUMN), + ("53000", INSUFFICIENT_RESOURCES), + ("25P02", IN_FAILED_SQL_TRANSACTION), + ("22010", INVALID_INDICATOR_PARAMETER_VALUE), + ("01008", WARNING_IMPLICIT_ZERO_BIT_PADDING), + ("HV014", FDW_TOO_MANY_HANDLES), + ("42P20", WINDOWING_ERROR), + ("42725", AMBIGUOUS_FUNCTION), + ("F0001", LOCK_FILE_EXISTS), + ("08003", CONNECTION_DOES_NOT_EXIST), + ("2200M", INVALID_XML_DOCUMENT), + ("22003", NUMERIC_VALUE_OUT_OF_RANGE), + ("39004", E_R_I_E_NULL_VALUE_NOT_ALLOWED), + ("2200B", ESCAPE_CHARACTER_CONFLICT), + ("0P000", INVALID_ROLE_SPECIFICATION), + ("00000", SUCCESSFUL_COMPLETION), + ("22P02", INVALID_TEXT_REPRESENTATION), + ("25001", ACTIVE_SQL_TRANSACTION), + ("HV00N", FDW_UNABLE_TO_ESTABLISH_CONNECTION), + ("39P01", E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), + ("2B000", DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST), + ("22008", DATETIME_FIELD_OVERFLOW), + ("42P14", INVALID_PSTATEMENT_DEFINITION), + ("57P04", DATABASE_DROPPED), + ("26000", INVALID_SQL_STATEMENT_NAME), + ("42P17", INVALID_OBJECT_DEFINITION), + ("42P04", DUPLICATE_DATABASE), + ("38001", E_R_E_CONTAINING_SQL_NOT_PERMITTED), + ("0Z002", STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), + ("22007", INVALID_DATETIME_FORMAT), + ("40003", T_R_STATEMENT_COMPLETION_UNKNOWN), + ("42P12", INVALID_DATABASE_DEFINITION), + ("57P03", CANNOT_CONNECT_NOW), ]), }; - -impl SqlState { - /// Creates a `SqlState` from its error code. - pub fn from_code(s: &str) -> SqlState { - match SQLSTATE_MAP.get(s) { - Some(state) => state.clone(), - None => SqlState::Other(s.to_owned()), - } - } - - /// Returns the error code corresponding to the `SqlState`. - pub fn code(&self) -> &str { - match *self { - SqlState::SuccessfulCompletion => "00000", - SqlState::Warning => "01000", - SqlState::DynamicResultSetsReturned => "0100C", - SqlState::ImplicitZeroBitPadding => "01008", - SqlState::NullValueEliminatedInSetFunction => "01003", - SqlState::PrivilegeNotGranted => "01007", - SqlState::PrivilegeNotRevoked => "01006", - SqlState::WarningStringDataRightTruncation => "01004", - SqlState::DeprecatedFeature => "01P01", - SqlState::NoData => "02000", - SqlState::NoAdditionalDynamicResultSetsReturned => "02001", - SqlState::SqlStatementNotYetComplete => "03000", - SqlState::ConnectionException => "08000", - SqlState::ConnectionDoesNotExist => "08003", - SqlState::ConnectionFailure => "08006", - SqlState::SqlclientUnableToEstablishSqlconnection => "08001", - SqlState::SqlserverRejectedEstablishmentOfSqlconnection => "08004", - SqlState::TransactionResolutionUnknown => "08007", - SqlState::ProtocolViolation => "08P01", - SqlState::TriggeredActionException => "09000", - SqlState::FeatureNotSupported => "0A000", - SqlState::InvalidTransactionInitiation => "0B000", - SqlState::LocatorException => "0F000", - SqlState::InvalidLocatorSpecification => "0F001", - SqlState::InvalidGrantor => "0L000", - SqlState::InvalidGrantOperation => "0LP01", - SqlState::InvalidRoleSpecification => "0P000", - SqlState::DiagnosticsException => "0Z000", - SqlState::StackedDiagnosticsAccessedWithoutActiveHandler => "0Z002", - SqlState::CaseNotFound => "20000", - SqlState::CardinalityViolation => "21000", - SqlState::DataException => "22000", - SqlState::ArraySubscriptError => "2202E", - SqlState::CharacterNotInRepertoire => "22021", - SqlState::DatetimeFieldOverflow => "22008", - SqlState::DivisionByZero => "22012", - SqlState::ErrorInAssignment => "22005", - SqlState::EscapeCharacterConflict => "2200B", - SqlState::IndicatorOverflow => "22022", - SqlState::IntervalFieldOverflow => "22015", - SqlState::InvalidArgumentForLogarithm => "2201E", - SqlState::InvalidArgumentForNtileFunction => "22014", - SqlState::InvalidArgumentForNthValueFunction => "22016", - SqlState::InvalidArgumentForPowerFunction => "2201F", - SqlState::InvalidArgumentForWidthBucketFunction => "2201G", - SqlState::InvalidCharacterValueForCast => "22018", - SqlState::InvalidDatetimeFormat => "22007", - SqlState::InvalidEscapeCharacter => "22019", - SqlState::InvalidEscapeOctet => "2200D", - SqlState::InvalidEscapeSequence => "22025", - SqlState::NonstandardUseOfEscapeCharacter => "22P06", - SqlState::InvalidIndicatorParameterValue => "22010", - SqlState::InvalidParameterValue => "22023", - SqlState::InvalidRegularExpression => "2201B", - SqlState::InvalidRowCountInLimitClause => "2201W", - SqlState::InvalidRowCountInResultOffsetClause => "2201X", - SqlState::InvalidTablesampleArgument => "2202H", - SqlState::InvalidTablesampleRepeat => "2202G", - SqlState::InvalidTimeZoneDisplacementValue => "22009", - SqlState::InvalidUseOfEscapeCharacter => "2200C", - SqlState::MostSpecificTypeMismatch => "2200G", - SqlState::DataNullValueNotAllowed => "22004", - SqlState::NullValueNoIndicatorParameter => "22002", - SqlState::NumericValueOutOfRange => "22003", - SqlState::SequenceGeneratorLimitExceeded => "2200H", - SqlState::StringDataLengthMismatch => "22026", - SqlState::DataStringDataRightTruncation => "22001", - SqlState::SubstringError => "22011", - SqlState::TrimError => "22027", - SqlState::UnterminatedCString => "22024", - SqlState::ZeroLengthCharacterString => "2200F", - SqlState::FloatingPointException => "22P01", - SqlState::InvalidTextRepresentation => "22P02", - SqlState::InvalidBinaryRepresentation => "22P03", - SqlState::BadCopyFileFormat => "22P04", - SqlState::UntranslatableCharacter => "22P05", - SqlState::NotAnXmlDocument => "2200L", - SqlState::InvalidXmlDocument => "2200M", - SqlState::InvalidXmlContent => "2200N", - SqlState::InvalidXmlComment => "2200S", - SqlState::InvalidXmlProcessingInstruction => "2200T", - SqlState::IntegrityConstraintViolation => "23000", - SqlState::RestrictViolation => "23001", - SqlState::NotNullViolation => "23502", - SqlState::ForeignKeyViolation => "23503", - SqlState::UniqueViolation => "23505", - SqlState::CheckViolation => "23514", - SqlState::ExclusionViolation => "23P01", - SqlState::InvalidCursorState => "24000", - SqlState::InvalidTransactionState => "25000", - SqlState::ActiveSqlTransaction => "25001", - SqlState::BranchTransactionAlreadyActive => "25002", - SqlState::HeldCursorRequiresSameIsolationLevel => "25008", - SqlState::InappropriateAccessModeForBranchTransaction => "25003", - SqlState::InappropriateIsolationLevelForBranchTransaction => "25004", - SqlState::NoActiveSqlTransactionForBranchTransaction => "25005", - SqlState::ReadOnlySqlTransaction => "25006", - SqlState::SchemaAndDataStatementMixingNotSupported => "25007", - SqlState::NoActiveSqlTransaction => "25P01", - SqlState::InFailedSqlTransaction => "25P02", - SqlState::IdleInTransactionSessionTimeout => "25P03", - SqlState::InvalidSqlStatementName => "26000", - SqlState::TriggeredDataChangeViolation => "27000", - SqlState::InvalidAuthorizationSpecification => "28000", - SqlState::InvalidPassword => "28P01", - SqlState::DependentPrivilegeDescriptorsStillExist => "2B000", - SqlState::DependentObjectsStillExist => "2BP01", - SqlState::InvalidTransactionTermination => "2D000", - SqlState::SqlRoutineException => "2F000", - SqlState::FunctionExecutedNoReturnStatement => "2F005", - SqlState::SqlRoutineModifyingSqlDataNotPermitted => "2F002", - SqlState::SqlRoutineProhibitedSqlStatementAttempted => "2F003", - SqlState::SqlRoutineReadingSqlDataNotPermitted => "2F004", - SqlState::InvalidCursorName => "34000", - SqlState::ExternalRoutineException => "38000", - SqlState::ContainingSqlNotPermitted => "38001", - SqlState::ForeignRoutineModifyingSqlDataNotPermitted => "38002", - SqlState::ForeignRoutineProhibitedSqlStatementAttempted => "38003", - SqlState::ForeignRoutineReadingSqlDataNotPermitted => "38004", - SqlState::ExternalRoutineInvocationException => "39000", - SqlState::InvalidSqlstateReturned => "39001", - SqlState::ExternalRoutineInvocationNullValueNotAllowed => "39004", - SqlState::TriggerProtocolViolated => "39P01", - SqlState::SrfProtocolViolated => "39P02", - SqlState::EventTriggerProtocolViolated => "39P03", - SqlState::SavepointException => "3B000", - SqlState::InvalidSavepointSpecification => "3B001", - SqlState::InvalidCatalogName => "3D000", - SqlState::InvalidSchemaName => "3F000", - SqlState::TransactionRollback => "40000", - SqlState::TransactionIntegrityConstraintViolation => "40002", - SqlState::SerializationFailure => "40001", - SqlState::StatementCompletionUnknown => "40003", - SqlState::DeadlockDetected => "40P01", - SqlState::SyntaxErrorOrAccessRuleViolation => "42000", - SqlState::SyntaxError => "42601", - SqlState::InsufficientPrivilege => "42501", - SqlState::CannotCoerce => "42846", - SqlState::GroupingError => "42803", - SqlState::WindowingError => "42P20", - SqlState::InvalidRecursion => "42P19", - SqlState::InvalidForeignKey => "42830", - SqlState::InvalidName => "42602", - SqlState::NameTooLong => "42622", - SqlState::ReservedName => "42939", - SqlState::DatatypeMismatch => "42804", - SqlState::IndeterminateDatatype => "42P18", - SqlState::CollationMismatch => "42P21", - SqlState::IndeterminateCollation => "42P22", - SqlState::WrongObjectType => "42809", - SqlState::GeneratedAlways => "428C9", - SqlState::UndefinedColumn => "42703", - SqlState::UndefinedFunction => "42883", - SqlState::UndefinedTable => "42P01", - SqlState::UndefinedParameter => "42P02", - SqlState::UndefinedObject => "42704", - SqlState::DuplicateColumn => "42701", - SqlState::DuplicateCursor => "42P03", - SqlState::DuplicateDatabase => "42P04", - SqlState::DuplicateFunction => "42723", - SqlState::DuplicatePreparedStatement => "42P05", - SqlState::DuplicateSchema => "42P06", - SqlState::DuplicateTable => "42P07", - SqlState::DuplicateAlias => "42712", - SqlState::DuplicateObject => "42710", - SqlState::AmbiguousColumn => "42702", - SqlState::AmbiguousFunction => "42725", - SqlState::AmbiguousParameter => "42P08", - SqlState::AmbiguousAlias => "42P09", - SqlState::InvalidColumnReference => "42P10", - SqlState::InvalidColumnDefinition => "42611", - SqlState::InvalidCursorDefinition => "42P11", - SqlState::InvalidDatabaseDefinition => "42P12", - SqlState::InvalidFunctionDefinition => "42P13", - SqlState::InvalidPreparedStatementDefinition => "42P14", - SqlState::InvalidSchemaDefinition => "42P15", - SqlState::InvalidTableDefinition => "42P16", - SqlState::InvalidObjectDefinition => "42P17", - SqlState::WithCheckOptionViolation => "44000", - SqlState::InsufficientResources => "53000", - SqlState::DiskFull => "53100", - SqlState::OutOfMemory => "53200", - SqlState::TooManyConnections => "53300", - SqlState::ConfigurationLimitExceeded => "53400", - SqlState::ProgramLimitExceeded => "54000", - SqlState::StatementTooComplex => "54001", - SqlState::TooManyColumns => "54011", - SqlState::TooManyArguments => "54023", - SqlState::ObjectNotInPrerequisiteState => "55000", - SqlState::ObjectInUse => "55006", - SqlState::CantChangeRuntimeParam => "55P02", - SqlState::LockNotAvailable => "55P03", - SqlState::UnsafeNewEnumValueUsage => "55P04", - SqlState::OperatorIntervention => "57000", - SqlState::QueryCanceled => "57014", - SqlState::AdminShutdown => "57P01", - SqlState::CrashShutdown => "57P02", - SqlState::CannotConnectNow => "57P03", - SqlState::DatabaseDropped => "57P04", - SqlState::SystemError => "58000", - SqlState::IoError => "58030", - SqlState::UndefinedFile => "58P01", - SqlState::DuplicateFile => "58P02", - SqlState::SnapshotTooOld => "72000", - SqlState::ConfigFileError => "F0000", - SqlState::LockFileExists => "F0001", - SqlState::FdwError => "HV000", - SqlState::FdwColumnNameNotFound => "HV005", - SqlState::FdwDynamicParameterValueNeeded => "HV002", - SqlState::FdwFunctionSequenceError => "HV010", - SqlState::FdwInconsistentDescriptorInformation => "HV021", - SqlState::FdwInvalidAttributeValue => "HV024", - SqlState::FdwInvalidColumnName => "HV007", - SqlState::FdwInvalidColumnNumber => "HV008", - SqlState::FdwInvalidDataType => "HV004", - SqlState::FdwInvalidDataTypeDescriptors => "HV006", - SqlState::FdwInvalidDescriptorFieldIdentifier => "HV091", - SqlState::FdwInvalidHandle => "HV00B", - SqlState::FdwInvalidOptionIndex => "HV00C", - SqlState::FdwInvalidOptionName => "HV00D", - SqlState::FdwInvalidStringLengthOrBufferLength => "HV090", - SqlState::FdwInvalidStringFormat => "HV00A", - SqlState::FdwInvalidUseOfNullPointer => "HV009", - SqlState::FdwTooManyHandles => "HV014", - SqlState::FdwOutOfMemory => "HV001", - SqlState::FdwNoSchemas => "HV00P", - SqlState::FdwOptionNameNotFound => "HV00J", - SqlState::FdwReplyHandle => "HV00K", - SqlState::FdwSchemaNotFound => "HV00Q", - SqlState::FdwTableNotFound => "HV00R", - SqlState::FdwUnableToCreateExecution => "HV00L", - SqlState::FdwUnableToCreateReply => "HV00M", - SqlState::FdwUnableToEstablishConnection => "HV00N", - SqlState::PlpgsqlError => "P0000", - SqlState::RaiseException => "P0001", - SqlState::NoDataFound => "P0002", - SqlState::TooManyRows => "P0003", - SqlState::AssertFailure => "P0004", - SqlState::InternalError => "XX000", - SqlState::DataCorrupted => "XX001", - SqlState::IndexCorrupted => "XX002", - SqlState::Other(ref s) => s, - } - } -} diff --git a/postgres/src/error.rs b/postgres/src/error.rs index 8fbdd7c1..27e036d5 100644 --- a/postgres/src/error.rs +++ b/postgres/src/error.rs @@ -4,7 +4,8 @@ use std::io; use std::error; #[doc(inline)] -pub use postgres_shared::error::{DbError, ConnectError, ErrorPosition, Severity, SqlState}; +// FIXME +pub use postgres_shared::error::*; /// An error encountered when communicating with the Postgres server. #[derive(Debug)] diff --git a/postgres/src/lib.rs b/postgres/src/lib.rs index 0cbd13e9..e36e94c3 100644 --- a/postgres/src/lib.rs +++ b/postgres/src/lib.rs @@ -93,7 +93,7 @@ use postgres_protocol::message::backend::{self, ErrorFields}; use postgres_protocol::message::frontend; use postgres_shared::rows::RowData; -use error::{Error, ConnectError, SqlState, DbError}; +use error::{Error, ConnectError, DbError, UNDEFINED_COLUMN, UNDEFINED_TABLE}; use tls::TlsHandshake; use notification::{Notifications, Notification}; use params::{IntoConnectParams, User}; @@ -771,7 +771,7 @@ impl InnerConnection { ) { Ok(..) => {} // Range types weren't added until Postgres 9.2, so pg_range may not exist - Err(Error::Db(ref e)) if e.code == SqlState::UndefinedTable => { + Err(Error::Db(ref e)) if e.code == UNDEFINED_TABLE => { self.raw_prepare( TYPEINFO_QUERY, "SELECT t.typname, t.typtype, t.typelem, NULL::OID, \ @@ -862,7 +862,7 @@ impl InnerConnection { ) { Ok(..) => {} // Postgres 9.0 doesn't have enumsortorder - Err(Error::Db(ref e)) if e.code == SqlState::UndefinedColumn => { + Err(Error::Db(ref e)) if e.code == UNDEFINED_COLUMN => { self.raw_prepare( TYPEINFO_ENUM_QUERY, "SELECT enumlabel \ diff --git a/postgres/tests/test.rs b/postgres/tests/test.rs index ac654375..9647b387 100644 --- a/postgres/tests/test.rs +++ b/postgres/tests/test.rs @@ -12,10 +12,9 @@ extern crate native_tls; use fallible_iterator::FallibleIterator; use postgres::{HandleNotice, Connection, GenericConnection, TlsMode}; use postgres::transaction::{self, IsolationLevel}; -use postgres::error::{Error, ConnectError, DbError}; +use postgres::error::{Error, ConnectError, DbError, SYNTAX_ERROR, QUERY_CANCELED, UNDEFINED_TABLE, + INVALID_CATALOG_NAME, INVALID_PASSWORD, CARDINALITY_VIOLATION}; use postgres::types::{Oid, Type, Kind, WrongType}; -use postgres::error::SqlState::{SyntaxError, QueryCanceled, UndefinedTable, InvalidCatalogName, - InvalidPassword, CardinalityViolation}; use postgres::error::ErrorPosition::Normal; use postgres::rows::RowIndex; use postgres::notification::Notification; @@ -59,7 +58,7 @@ fn test_prepare_err() { )); let stmt = conn.prepare("invalid sql database"); match stmt { - Err(Error::Db(ref e)) if e.code == SyntaxError && e.position == Some(Normal(1)) => {} + Err(Error::Db(ref e)) if e.code == SYNTAX_ERROR && e.position == Some(Normal(1)) => {} Err(e) => panic!("Unexpected result {:?}", e), _ => panic!("Unexpected result"), } @@ -68,7 +67,7 @@ fn test_prepare_err() { #[test] fn test_unknown_database() { match Connection::connect("postgres://postgres@localhost:5433/asdf", TlsMode::None) { - Err(ConnectError::Db(ref e)) if e.code == InvalidCatalogName => {} + Err(ConnectError::Db(ref e)) if e.code == INVALID_CATALOG_NAME => {} Err(resp) => panic!("Unexpected result {:?}", resp), _ => panic!("Unexpected result"), } @@ -455,7 +454,7 @@ fn test_batch_execute_error() { let stmt = conn.prepare("SELECT * FROM foo ORDER BY id"); match stmt { - Err(Error::Db(ref e)) if e.code == UndefinedTable => {} + Err(Error::Db(ref e)) if e.code == UNDEFINED_TABLE => {} Err(e) => panic!("unexpected error {:?}", e), _ => panic!("unexpected success"), } @@ -520,7 +519,7 @@ FROM (SELECT gs.i LIMIT 2) ss", )); match stmt.query(&[]) { - Err(Error::Db(ref e)) if e.code == CardinalityViolation => {} + Err(Error::Db(ref e)) if e.code == CARDINALITY_VIOLATION => {} Err(err) => panic!("Unexpected error {:?}", err), Ok(_) => panic!("Expected failure"), }; @@ -917,13 +916,16 @@ fn test_cancel_query() { let t = thread::spawn(move || { thread::sleep(Duration::from_millis(500)); assert!( - postgres::cancel_query("postgres://postgres@localhost:5433", TlsMode::None, &cancel_data) - .is_ok() + postgres::cancel_query( + "postgres://postgres@localhost:5433", + TlsMode::None, + &cancel_data, + ).is_ok() ); }); match conn.execute("SELECT pg_sleep(10)", &[]) { - Err(Error::Db(ref e)) if e.code == QueryCanceled => {} + Err(Error::Db(ref e)) if e.code == QUERY_CANCELED => {} Err(res) => panic!("Unexpected result {:?}", res), _ => panic!("Unexpected result"), } @@ -1011,7 +1013,10 @@ fn test_plaintext_pass() { #[test] fn test_plaintext_pass_no_pass() { - let ret = Connection::connect("postgres://pass_user@localhost:5433/postgres", TlsMode::None); + let ret = Connection::connect( + "postgres://pass_user@localhost:5433/postgres", + TlsMode::None, + ); match ret { Err(ConnectError::ConnectParams(..)) => (), Err(err) => panic!("Unexpected error {:?}", err), @@ -1026,7 +1031,7 @@ fn test_plaintext_pass_wrong_pass() { TlsMode::None, ); match ret { - Err(ConnectError::Db(ref e)) if e.code == InvalidPassword => {} + Err(ConnectError::Db(ref e)) if e.code == INVALID_PASSWORD => {} Err(err) => panic!("Unexpected error {:?}", err), _ => panic!("Expected error"), } @@ -1052,9 +1057,12 @@ fn test_md5_pass_no_pass() { #[test] fn test_md5_pass_wrong_pass() { - let ret = Connection::connect("postgres://md5_user:asdf@localhost:5433/postgres", TlsMode::None); + let ret = Connection::connect( + "postgres://md5_user:asdf@localhost:5433/postgres", + TlsMode::None, + ); match ret { - Err(ConnectError::Db(ref e)) if e.code == InvalidPassword => {} + Err(ConnectError::Db(ref e)) if e.code == INVALID_PASSWORD => {} Err(err) => panic!("Unexpected error {:?}", err), _ => panic!("Expected error"), } @@ -1070,7 +1078,10 @@ fn test_scram_pass() { #[test] fn test_scram_pass_no_pass() { - let ret = Connection::connect("postgres://scram_user@localhost:5433/postgres", TlsMode::None); + let ret = Connection::connect( + "postgres://scram_user@localhost:5433/postgres", + TlsMode::None, + ); match ret { Err(ConnectError::ConnectParams(..)) => (), Err(err) => panic!("Unexpected error {:?}", err), @@ -1080,9 +1091,12 @@ fn test_scram_pass_no_pass() { #[test] fn test_scram_pass_wrong_pass() { - let ret = Connection::connect("postgres://scram_user:asdf@localhost:5433/postgres", TlsMode::None); + let ret = Connection::connect( + "postgres://scram_user:asdf@localhost:5433/postgres", + TlsMode::None, + ); match ret { - Err(ConnectError::Db(ref e)) if e.code == InvalidPassword => {} + Err(ConnectError::Db(ref e)) if e.code == INVALID_PASSWORD => {} Err(err) => panic!("Unexpected error {:?}", err), _ => panic!("Expected error"), } diff --git a/tokio-postgres/src/error.rs b/tokio-postgres/src/error.rs index af4e064b..c0adbcdc 100644 --- a/tokio-postgres/src/error.rs +++ b/tokio-postgres/src/error.rs @@ -7,7 +7,8 @@ use std::fmt; use Connection; #[doc(inline)] -pub use postgres_shared::error::{DbError, ConnectError, ErrorPosition, Severity, SqlState}; +// FIXME +pub use postgres_shared::error::*; /// A runtime error. #[derive(Debug)] diff --git a/tokio-postgres/src/lib.rs b/tokio-postgres/src/lib.rs index 4e8b17b8..55d0bb9b 100644 --- a/tokio-postgres/src/lib.rs +++ b/tokio-postgres/src/lib.rs @@ -89,7 +89,7 @@ use tokio_core::reactor::Handle; #[doc(inline)] pub use postgres_shared::{params, CancelData, Notification}; -use error::{ConnectError, Error, DbError, SqlState}; +use error::{ConnectError, Error, DbError, UNDEFINED_TABLE, UNDEFINED_COLUMN}; use params::{ConnectParams, IntoConnectParams}; use stmt::{Statement, Column}; use stream::PostgresStream; @@ -774,7 +774,7 @@ impl Connection { match e { // Range types weren't added until Postgres 9.2, so pg_range may not exist Error::Db(e, c) => { - if e.code != SqlState::UndefinedTable { + if e.code != UNDEFINED_TABLE { return Either::B(Err(Error::Db(e, c)).into_future()); } @@ -832,7 +832,7 @@ impl Connection { ORDER BY enumsortorder", ).or_else(|e| match e { Error::Db(e, c) => { - if e.code != SqlState::UndefinedColumn { + if e.code != UNDEFINED_COLUMN { return Either::B(Err(Error::Db(e, c)).into_future()); } diff --git a/tokio-postgres/src/test.rs b/tokio-postgres/src/test.rs index 45fb0d47..d868e1ad 100644 --- a/tokio-postgres/src/test.rs +++ b/tokio-postgres/src/test.rs @@ -6,7 +6,7 @@ use std::time::Duration; use tokio_core::reactor::{Core, Interval}; use super::*; -use error::{Error, ConnectError, SqlState}; +use error::{Error, ConnectError, INVALID_PASSWORD, INVALID_AUTHORIZATION_SPECIFICATION, QUERY_CANCELED}; use params::{ConnectParams, Host}; use types::{ToSql, FromSql, Type, IsNull, Kind}; @@ -48,7 +48,7 @@ fn md5_user_wrong_pass() { &handle, ); match l.run(done) { - Err(ConnectError::Db(ref e)) if e.code == SqlState::InvalidPassword => {} + Err(ConnectError::Db(ref e)) if e.code == INVALID_PASSWORD => {} Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } @@ -92,7 +92,7 @@ fn pass_user_wrong_pass() { &handle, ); match l.run(done) { - Err(ConnectError::Db(ref e)) if e.code == SqlState::InvalidPassword => {} + Err(ConnectError::Db(ref e)) if e.code == INVALID_PASSWORD => {} Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } @@ -123,7 +123,7 @@ fn batch_execute_err() { .and_then(|c| c.batch_execute("SELECT * FROM bogo")) .then(|r| match r { Err(Error::Db(e, s)) => { - assert!(e.code == SqlState::UndefinedTable); + assert!(e.code == UNDEFINED_TABLE); s.batch_execute("SELECT * FROM foo") } Err(e) => panic!("unexpected error: {}", e), @@ -249,7 +249,7 @@ fn ssl_user_ssl_required() { ); match l.run(done) { - Err(ConnectError::Db(e)) => assert!(e.code == SqlState::InvalidAuthorizationSpecification), + Err(ConnectError::Db(e)) => assert!(e.code == INVALID_AUTHORIZATION_SPECIFICATION), Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } @@ -437,7 +437,7 @@ fn cancel() { let (select, cancel) = l.run(done).unwrap(); cancel.unwrap(); match select { - Err(Error::Db(e, _)) => assert_eq!(e.code, SqlState::QueryCanceled), + Err(Error::Db(e, _)) => assert_eq!(e.code, QUERY_CANCELED), Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), }