diff --git a/lib/errors.py b/lib/errors.py index 492d5aac..99ab0b04 100644 --- a/lib/errors.py +++ b/lib/errors.py @@ -21,1519 +21,1294 @@ def lookup(code): _by_sqlstate = {} +def for_sqlstate(state): + def for_sqlstate_(cls): + _by_sqlstate[state] = cls + return cls + return for_sqlstate_ + + # autogenerated data: do not edit below this point. # Class 02 - No Data (this is also a warning class per the SQL standard) +@for_sqlstate('02000') class NoData(DatabaseError): pass -_by_sqlstate['02000'] = NoData - +@for_sqlstate('02001') class NoAdditionalDynamicResultSetsReturned(DatabaseError): pass -_by_sqlstate['02001'] = NoAdditionalDynamicResultSetsReturned - # Class 03 - SQL Statement Not Yet Complete +@for_sqlstate('03000') class SqlStatementNotYetComplete(DatabaseError): pass -_by_sqlstate['03000'] = SqlStatementNotYetComplete - # Class 08 - Connection Exception +@for_sqlstate('08000') class ConnectionException(DatabaseError): pass -_by_sqlstate['08000'] = ConnectionException - +@for_sqlstate('08001') class SqlclientUnableToEstablishSqlconnection(DatabaseError): pass -_by_sqlstate['08001'] = SqlclientUnableToEstablishSqlconnection - +@for_sqlstate('08003') class ConnectionDoesNotExist(DatabaseError): pass -_by_sqlstate['08003'] = ConnectionDoesNotExist - +@for_sqlstate('08004') class SqlserverRejectedEstablishmentOfSqlconnection(DatabaseError): pass -_by_sqlstate['08004'] = SqlserverRejectedEstablishmentOfSqlconnection - +@for_sqlstate('08006') class ConnectionFailure(DatabaseError): pass -_by_sqlstate['08006'] = ConnectionFailure - +@for_sqlstate('08007') class TransactionResolutionUnknown(DatabaseError): pass -_by_sqlstate['08007'] = TransactionResolutionUnknown - +@for_sqlstate('08P01') class ProtocolViolation(DatabaseError): pass -_by_sqlstate['08P01'] = ProtocolViolation - # Class 09 - Triggered Action Exception +@for_sqlstate('09000') class TriggeredActionException(DatabaseError): pass -_by_sqlstate['09000'] = TriggeredActionException - # Class 0A - Feature Not Supported +@for_sqlstate('0A000') class FeatureNotSupported(NotSupportedError): pass -_by_sqlstate['0A000'] = FeatureNotSupported - # Class 0B - Invalid Transaction Initiation +@for_sqlstate('0B000') class InvalidTransactionInitiation(DatabaseError): pass -_by_sqlstate['0B000'] = InvalidTransactionInitiation - # Class 0F - Locator Exception +@for_sqlstate('0F000') class LocatorException(DatabaseError): pass -_by_sqlstate['0F000'] = LocatorException - +@for_sqlstate('0F001') class InvalidLocatorSpecification(DatabaseError): pass -_by_sqlstate['0F001'] = InvalidLocatorSpecification - # Class 0L - Invalid Grantor +@for_sqlstate('0L000') class InvalidGrantor(DatabaseError): pass -_by_sqlstate['0L000'] = InvalidGrantor - +@for_sqlstate('0LP01') class InvalidGrantOperation(DatabaseError): pass -_by_sqlstate['0LP01'] = InvalidGrantOperation - # Class 0P - Invalid Role Specification +@for_sqlstate('0P000') class InvalidRoleSpecification(DatabaseError): pass -_by_sqlstate['0P000'] = InvalidRoleSpecification - # Class 0Z - Diagnostics Exception +@for_sqlstate('0Z000') class DiagnosticsException(DatabaseError): pass -_by_sqlstate['0Z000'] = DiagnosticsException - +@for_sqlstate('0Z002') class StackedDiagnosticsAccessedWithoutActiveHandler(DatabaseError): pass -_by_sqlstate['0Z002'] = StackedDiagnosticsAccessedWithoutActiveHandler - # Class 20 - Case Not Found +@for_sqlstate('20000') class CaseNotFound(ProgrammingError): pass -_by_sqlstate['20000'] = CaseNotFound - # Class 21 - Cardinality Violation +@for_sqlstate('21000') class CardinalityViolation(ProgrammingError): pass -_by_sqlstate['21000'] = CardinalityViolation - # Class 22 - Data Exception +@for_sqlstate('22000') class DataException(DataError): pass -_by_sqlstate['22000'] = DataException - +@for_sqlstate('22001') class StringDataRightTruncation(DataError): pass -_by_sqlstate['22001'] = StringDataRightTruncation - +@for_sqlstate('22002') class NullValueNoIndicatorParameter(DataError): pass -_by_sqlstate['22002'] = NullValueNoIndicatorParameter - +@for_sqlstate('22003') class NumericValueOutOfRange(DataError): pass -_by_sqlstate['22003'] = NumericValueOutOfRange - +@for_sqlstate('22004') class NullValueNotAllowed(DataError): pass -_by_sqlstate['22004'] = NullValueNotAllowed - +@for_sqlstate('22005') class ErrorInAssignment(DataError): pass -_by_sqlstate['22005'] = ErrorInAssignment - +@for_sqlstate('22007') class InvalidDatetimeFormat(DataError): pass -_by_sqlstate['22007'] = InvalidDatetimeFormat - +@for_sqlstate('22008') class DatetimeFieldOverflow(DataError): pass -_by_sqlstate['22008'] = DatetimeFieldOverflow - +@for_sqlstate('22009') class InvalidTimeZoneDisplacementValue(DataError): pass -_by_sqlstate['22009'] = InvalidTimeZoneDisplacementValue - +@for_sqlstate('2200B') class EscapeCharacterConflict(DataError): pass -_by_sqlstate['2200B'] = EscapeCharacterConflict - +@for_sqlstate('2200C') class InvalidUseOfEscapeCharacter(DataError): pass -_by_sqlstate['2200C'] = InvalidUseOfEscapeCharacter - +@for_sqlstate('2200D') class InvalidEscapeOctet(DataError): pass -_by_sqlstate['2200D'] = InvalidEscapeOctet - +@for_sqlstate('2200F') class ZeroLengthCharacterString(DataError): pass -_by_sqlstate['2200F'] = ZeroLengthCharacterString - +@for_sqlstate('2200G') class MostSpecificTypeMismatch(DataError): pass -_by_sqlstate['2200G'] = MostSpecificTypeMismatch - +@for_sqlstate('2200H') class SequenceGeneratorLimitExceeded(DataError): pass -_by_sqlstate['2200H'] = SequenceGeneratorLimitExceeded - +@for_sqlstate('2200L') class NotAnXmlDocument(DataError): pass -_by_sqlstate['2200L'] = NotAnXmlDocument - +@for_sqlstate('2200M') class InvalidXmlDocument(DataError): pass -_by_sqlstate['2200M'] = InvalidXmlDocument - +@for_sqlstate('2200N') class InvalidXmlContent(DataError): pass -_by_sqlstate['2200N'] = InvalidXmlContent - +@for_sqlstate('2200S') class InvalidXmlComment(DataError): pass -_by_sqlstate['2200S'] = InvalidXmlComment - +@for_sqlstate('2200T') class InvalidXmlProcessingInstruction(DataError): pass -_by_sqlstate['2200T'] = InvalidXmlProcessingInstruction - +@for_sqlstate('22010') class InvalidIndicatorParameterValue(DataError): pass -_by_sqlstate['22010'] = InvalidIndicatorParameterValue - +@for_sqlstate('22011') class SubstringError(DataError): pass -_by_sqlstate['22011'] = SubstringError - +@for_sqlstate('22012') class DivisionByZero(DataError): pass -_by_sqlstate['22012'] = DivisionByZero - +@for_sqlstate('22013') class InvalidPrecedingOrFollowingSize(DataError): pass -_by_sqlstate['22013'] = InvalidPrecedingOrFollowingSize - +@for_sqlstate('22014') class InvalidArgumentForNtileFunction(DataError): pass -_by_sqlstate['22014'] = InvalidArgumentForNtileFunction - +@for_sqlstate('22015') class IntervalFieldOverflow(DataError): pass -_by_sqlstate['22015'] = IntervalFieldOverflow - +@for_sqlstate('22016') class InvalidArgumentForNthValueFunction(DataError): pass -_by_sqlstate['22016'] = InvalidArgumentForNthValueFunction - +@for_sqlstate('22018') class InvalidCharacterValueForCast(DataError): pass -_by_sqlstate['22018'] = InvalidCharacterValueForCast - +@for_sqlstate('22019') class InvalidEscapeCharacter(DataError): pass -_by_sqlstate['22019'] = InvalidEscapeCharacter - +@for_sqlstate('2201B') class InvalidRegularExpression(DataError): pass -_by_sqlstate['2201B'] = InvalidRegularExpression - +@for_sqlstate('2201E') class InvalidArgumentForLogarithm(DataError): pass -_by_sqlstate['2201E'] = InvalidArgumentForLogarithm - +@for_sqlstate('2201F') class InvalidArgumentForPowerFunction(DataError): pass -_by_sqlstate['2201F'] = InvalidArgumentForPowerFunction - +@for_sqlstate('2201G') class InvalidArgumentForWidthBucketFunction(DataError): pass -_by_sqlstate['2201G'] = InvalidArgumentForWidthBucketFunction - +@for_sqlstate('2201W') class InvalidRowCountInLimitClause(DataError): pass -_by_sqlstate['2201W'] = InvalidRowCountInLimitClause - +@for_sqlstate('2201X') class InvalidRowCountInResultOffsetClause(DataError): pass -_by_sqlstate['2201X'] = InvalidRowCountInResultOffsetClause - +@for_sqlstate('22021') class CharacterNotInRepertoire(DataError): pass -_by_sqlstate['22021'] = CharacterNotInRepertoire - +@for_sqlstate('22022') class IndicatorOverflow(DataError): pass -_by_sqlstate['22022'] = IndicatorOverflow - +@for_sqlstate('22023') class InvalidParameterValue(DataError): pass -_by_sqlstate['22023'] = InvalidParameterValue - +@for_sqlstate('22024') class UnterminatedCString(DataError): pass -_by_sqlstate['22024'] = UnterminatedCString - +@for_sqlstate('22025') class InvalidEscapeSequence(DataError): pass -_by_sqlstate['22025'] = InvalidEscapeSequence - +@for_sqlstate('22026') class StringDataLengthMismatch(DataError): pass -_by_sqlstate['22026'] = StringDataLengthMismatch - +@for_sqlstate('22027') class TrimError(DataError): pass -_by_sqlstate['22027'] = TrimError - +@for_sqlstate('2202E') class ArraySubscriptError(DataError): pass -_by_sqlstate['2202E'] = ArraySubscriptError - +@for_sqlstate('2202G') class InvalidTablesampleRepeat(DataError): pass -_by_sqlstate['2202G'] = InvalidTablesampleRepeat - +@for_sqlstate('2202H') class InvalidTablesampleArgument(DataError): pass -_by_sqlstate['2202H'] = InvalidTablesampleArgument - +@for_sqlstate('22P01') class FloatingPointException(DataError): pass -_by_sqlstate['22P01'] = FloatingPointException - +@for_sqlstate('22P02') class InvalidTextRepresentation(DataError): pass -_by_sqlstate['22P02'] = InvalidTextRepresentation - +@for_sqlstate('22P03') class InvalidBinaryRepresentation(DataError): pass -_by_sqlstate['22P03'] = InvalidBinaryRepresentation - +@for_sqlstate('22P04') class BadCopyFileFormat(DataError): pass -_by_sqlstate['22P04'] = BadCopyFileFormat - +@for_sqlstate('22P05') class UntranslatableCharacter(DataError): pass -_by_sqlstate['22P05'] = UntranslatableCharacter - +@for_sqlstate('22P06') class NonstandardUseOfEscapeCharacter(DataError): pass -_by_sqlstate['22P06'] = NonstandardUseOfEscapeCharacter - # Class 23 - Integrity Constraint Violation +@for_sqlstate('23000') class IntegrityConstraintViolation(IntegrityError): pass -_by_sqlstate['23000'] = IntegrityConstraintViolation - +@for_sqlstate('23001') class RestrictViolation(IntegrityError): pass -_by_sqlstate['23001'] = RestrictViolation - +@for_sqlstate('23502') class NotNullViolation(IntegrityError): pass -_by_sqlstate['23502'] = NotNullViolation - +@for_sqlstate('23503') class ForeignKeyViolation(IntegrityError): pass -_by_sqlstate['23503'] = ForeignKeyViolation - +@for_sqlstate('23505') class UniqueViolation(IntegrityError): pass -_by_sqlstate['23505'] = UniqueViolation - +@for_sqlstate('23514') class CheckViolation(IntegrityError): pass -_by_sqlstate['23514'] = CheckViolation - +@for_sqlstate('23P01') class ExclusionViolation(IntegrityError): pass -_by_sqlstate['23P01'] = ExclusionViolation - # Class 24 - Invalid Cursor State +@for_sqlstate('24000') class InvalidCursorState(InternalError): pass -_by_sqlstate['24000'] = InvalidCursorState - # Class 25 - Invalid Transaction State +@for_sqlstate('25000') class InvalidTransactionState(InternalError): pass -_by_sqlstate['25000'] = InvalidTransactionState - +@for_sqlstate('25001') class ActiveSqlTransaction(InternalError): pass -_by_sqlstate['25001'] = ActiveSqlTransaction - +@for_sqlstate('25002') class BranchTransactionAlreadyActive(InternalError): pass -_by_sqlstate['25002'] = BranchTransactionAlreadyActive - +@for_sqlstate('25003') class InappropriateAccessModeForBranchTransaction(InternalError): pass -_by_sqlstate['25003'] = InappropriateAccessModeForBranchTransaction - +@for_sqlstate('25004') class InappropriateIsolationLevelForBranchTransaction(InternalError): pass -_by_sqlstate['25004'] = InappropriateIsolationLevelForBranchTransaction - +@for_sqlstate('25005') class NoActiveSqlTransactionForBranchTransaction(InternalError): pass -_by_sqlstate['25005'] = NoActiveSqlTransactionForBranchTransaction - +@for_sqlstate('25006') class ReadOnlySqlTransaction(InternalError): pass -_by_sqlstate['25006'] = ReadOnlySqlTransaction - +@for_sqlstate('25007') class SchemaAndDataStatementMixingNotSupported(InternalError): pass -_by_sqlstate['25007'] = SchemaAndDataStatementMixingNotSupported - +@for_sqlstate('25008') class HeldCursorRequiresSameIsolationLevel(InternalError): pass -_by_sqlstate['25008'] = HeldCursorRequiresSameIsolationLevel - +@for_sqlstate('25P01') class NoActiveSqlTransaction(InternalError): pass -_by_sqlstate['25P01'] = NoActiveSqlTransaction - +@for_sqlstate('25P02') class InFailedSqlTransaction(InternalError): pass -_by_sqlstate['25P02'] = InFailedSqlTransaction - +@for_sqlstate('25P03') class IdleInTransactionSessionTimeout(InternalError): pass -_by_sqlstate['25P03'] = IdleInTransactionSessionTimeout - # Class 26 - Invalid SQL Statement Name +@for_sqlstate('26000') class InvalidSqlStatementName(OperationalError): pass -_by_sqlstate['26000'] = InvalidSqlStatementName - # Class 27 - Triggered Data Change Violation +@for_sqlstate('27000') class TriggeredDataChangeViolation(OperationalError): pass -_by_sqlstate['27000'] = TriggeredDataChangeViolation - # Class 28 - Invalid Authorization Specification +@for_sqlstate('28000') class InvalidAuthorizationSpecification(OperationalError): pass -_by_sqlstate['28000'] = InvalidAuthorizationSpecification - +@for_sqlstate('28P01') class InvalidPassword(OperationalError): pass -_by_sqlstate['28P01'] = InvalidPassword - # Class 2B - Dependent Privilege Descriptors Still Exist +@for_sqlstate('2B000') class DependentPrivilegeDescriptorsStillExist(InternalError): pass -_by_sqlstate['2B000'] = DependentPrivilegeDescriptorsStillExist - +@for_sqlstate('2BP01') class DependentObjectsStillExist(InternalError): pass -_by_sqlstate['2BP01'] = DependentObjectsStillExist - # Class 2D - Invalid Transaction Termination +@for_sqlstate('2D000') class InvalidTransactionTermination(InternalError): pass -_by_sqlstate['2D000'] = InvalidTransactionTermination - # Class 2F - SQL Routine Exception +@for_sqlstate('2F000') class SqlRoutineException(InternalError): pass -_by_sqlstate['2F000'] = SqlRoutineException - +@for_sqlstate('2F002') class ModifyingSqlDataNotPermitted(InternalError): pass -_by_sqlstate['2F002'] = ModifyingSqlDataNotPermitted - +@for_sqlstate('2F003') class ProhibitedSqlStatementAttempted(InternalError): pass -_by_sqlstate['2F003'] = ProhibitedSqlStatementAttempted - +@for_sqlstate('2F004') class ReadingSqlDataNotPermitted(InternalError): pass -_by_sqlstate['2F004'] = ReadingSqlDataNotPermitted - +@for_sqlstate('2F005') class FunctionExecutedNoReturnStatement(InternalError): pass -_by_sqlstate['2F005'] = FunctionExecutedNoReturnStatement - # Class 34 - Invalid Cursor Name +@for_sqlstate('34000') class InvalidCursorName(OperationalError): pass -_by_sqlstate['34000'] = InvalidCursorName - # Class 38 - External Routine Exception +@for_sqlstate('38000') class ExternalRoutineException(InternalError): pass -_by_sqlstate['38000'] = ExternalRoutineException - +@for_sqlstate('38001') class ContainingSqlNotPermitted(InternalError): pass -_by_sqlstate['38001'] = ContainingSqlNotPermitted - -class ModifyingSqlDataNotPermitted(InternalError): +@for_sqlstate('38002') +class ModifyingSqlDataNotPermittedExt(InternalError): pass -_by_sqlstate['38002'] = ModifyingSqlDataNotPermitted - -class ProhibitedSqlStatementAttempted(InternalError): +@for_sqlstate('38003') +class ProhibitedSqlStatementAttemptedExt(InternalError): pass -_by_sqlstate['38003'] = ProhibitedSqlStatementAttempted - -class ReadingSqlDataNotPermitted(InternalError): +@for_sqlstate('38004') +class ReadingSqlDataNotPermittedExt(InternalError): pass -_by_sqlstate['38004'] = ReadingSqlDataNotPermitted - # Class 39 - External Routine Invocation Exception +@for_sqlstate('39000') class ExternalRoutineInvocationException(InternalError): pass -_by_sqlstate['39000'] = ExternalRoutineInvocationException - +@for_sqlstate('39001') class InvalidSqlstateReturned(InternalError): pass -_by_sqlstate['39001'] = InvalidSqlstateReturned - -class NullValueNotAllowed(InternalError): +@for_sqlstate('39004') +class NullValueNotAllowedExt(InternalError): pass -_by_sqlstate['39004'] = NullValueNotAllowed - +@for_sqlstate('39P01') class TriggerProtocolViolated(InternalError): pass -_by_sqlstate['39P01'] = TriggerProtocolViolated - +@for_sqlstate('39P02') class SrfProtocolViolated(InternalError): pass -_by_sqlstate['39P02'] = SrfProtocolViolated - +@for_sqlstate('39P03') class EventTriggerProtocolViolated(InternalError): pass -_by_sqlstate['39P03'] = EventTriggerProtocolViolated - # Class 3B - Savepoint Exception +@for_sqlstate('3B000') class SavepointException(InternalError): pass -_by_sqlstate['3B000'] = SavepointException - +@for_sqlstate('3B001') class InvalidSavepointSpecification(InternalError): pass -_by_sqlstate['3B001'] = InvalidSavepointSpecification - # Class 3D - Invalid Catalog Name +@for_sqlstate('3D000') class InvalidCatalogName(ProgrammingError): pass -_by_sqlstate['3D000'] = InvalidCatalogName - # Class 3F - Invalid Schema Name +@for_sqlstate('3F000') class InvalidSchemaName(ProgrammingError): pass -_by_sqlstate['3F000'] = InvalidSchemaName - # Class 40 - Transaction Rollback +@for_sqlstate('40000') class TransactionRollback(TransactionRollbackError): pass -_by_sqlstate['40000'] = TransactionRollback - +@for_sqlstate('40001') class SerializationFailure(TransactionRollbackError): pass -_by_sqlstate['40001'] = SerializationFailure - +@for_sqlstate('40002') class TransactionIntegrityConstraintViolation(TransactionRollbackError): pass -_by_sqlstate['40002'] = TransactionIntegrityConstraintViolation - +@for_sqlstate('40003') class StatementCompletionUnknown(TransactionRollbackError): pass -_by_sqlstate['40003'] = StatementCompletionUnknown - +@for_sqlstate('40P01') class DeadlockDetected(TransactionRollbackError): pass -_by_sqlstate['40P01'] = DeadlockDetected - # Class 42 - Syntax Error or Access Rule Violation +@for_sqlstate('42000') class SyntaxErrorOrAccessRuleViolation(ProgrammingError): pass -_by_sqlstate['42000'] = SyntaxErrorOrAccessRuleViolation - +@for_sqlstate('42501') class InsufficientPrivilege(ProgrammingError): pass -_by_sqlstate['42501'] = InsufficientPrivilege - +@for_sqlstate('42601') class SyntaxError(ProgrammingError): pass -_by_sqlstate['42601'] = SyntaxError - +@for_sqlstate('42602') class InvalidName(ProgrammingError): pass -_by_sqlstate['42602'] = InvalidName - +@for_sqlstate('42611') class InvalidColumnDefinition(ProgrammingError): pass -_by_sqlstate['42611'] = InvalidColumnDefinition - +@for_sqlstate('42622') class NameTooLong(ProgrammingError): pass -_by_sqlstate['42622'] = NameTooLong - +@for_sqlstate('42701') class DuplicateColumn(ProgrammingError): pass -_by_sqlstate['42701'] = DuplicateColumn - +@for_sqlstate('42702') class AmbiguousColumn(ProgrammingError): pass -_by_sqlstate['42702'] = AmbiguousColumn - +@for_sqlstate('42703') class UndefinedColumn(ProgrammingError): pass -_by_sqlstate['42703'] = UndefinedColumn - +@for_sqlstate('42704') class UndefinedObject(ProgrammingError): pass -_by_sqlstate['42704'] = UndefinedObject - +@for_sqlstate('42710') class DuplicateObject(ProgrammingError): pass -_by_sqlstate['42710'] = DuplicateObject - +@for_sqlstate('42712') class DuplicateAlias(ProgrammingError): pass -_by_sqlstate['42712'] = DuplicateAlias - +@for_sqlstate('42723') class DuplicateFunction(ProgrammingError): pass -_by_sqlstate['42723'] = DuplicateFunction - +@for_sqlstate('42725') class AmbiguousFunction(ProgrammingError): pass -_by_sqlstate['42725'] = AmbiguousFunction - +@for_sqlstate('42803') class GroupingError(ProgrammingError): pass -_by_sqlstate['42803'] = GroupingError - +@for_sqlstate('42804') class DatatypeMismatch(ProgrammingError): pass -_by_sqlstate['42804'] = DatatypeMismatch - +@for_sqlstate('42809') class WrongObjectType(ProgrammingError): pass -_by_sqlstate['42809'] = WrongObjectType - +@for_sqlstate('42830') class InvalidForeignKey(ProgrammingError): pass -_by_sqlstate['42830'] = InvalidForeignKey - +@for_sqlstate('42846') class CannotCoerce(ProgrammingError): pass -_by_sqlstate['42846'] = CannotCoerce - +@for_sqlstate('42883') class UndefinedFunction(ProgrammingError): pass -_by_sqlstate['42883'] = UndefinedFunction - +@for_sqlstate('428C9') class GeneratedAlways(ProgrammingError): pass -_by_sqlstate['428C9'] = GeneratedAlways - +@for_sqlstate('42939') class ReservedName(ProgrammingError): pass -_by_sqlstate['42939'] = ReservedName - +@for_sqlstate('42P01') class UndefinedTable(ProgrammingError): pass -_by_sqlstate['42P01'] = UndefinedTable - +@for_sqlstate('42P02') class UndefinedParameter(ProgrammingError): pass -_by_sqlstate['42P02'] = UndefinedParameter - +@for_sqlstate('42P03') class DuplicateCursor(ProgrammingError): pass -_by_sqlstate['42P03'] = DuplicateCursor - +@for_sqlstate('42P04') class DuplicateDatabase(ProgrammingError): pass -_by_sqlstate['42P04'] = DuplicateDatabase - +@for_sqlstate('42P05') class DuplicatePreparedStatement(ProgrammingError): pass -_by_sqlstate['42P05'] = DuplicatePreparedStatement - +@for_sqlstate('42P06') class DuplicateSchema(ProgrammingError): pass -_by_sqlstate['42P06'] = DuplicateSchema - +@for_sqlstate('42P07') class DuplicateTable(ProgrammingError): pass -_by_sqlstate['42P07'] = DuplicateTable - +@for_sqlstate('42P08') class AmbiguousParameter(ProgrammingError): pass -_by_sqlstate['42P08'] = AmbiguousParameter - +@for_sqlstate('42P09') class AmbiguousAlias(ProgrammingError): pass -_by_sqlstate['42P09'] = AmbiguousAlias - +@for_sqlstate('42P10') class InvalidColumnReference(ProgrammingError): pass -_by_sqlstate['42P10'] = InvalidColumnReference - +@for_sqlstate('42P11') class InvalidCursorDefinition(ProgrammingError): pass -_by_sqlstate['42P11'] = InvalidCursorDefinition - +@for_sqlstate('42P12') class InvalidDatabaseDefinition(ProgrammingError): pass -_by_sqlstate['42P12'] = InvalidDatabaseDefinition - +@for_sqlstate('42P13') class InvalidFunctionDefinition(ProgrammingError): pass -_by_sqlstate['42P13'] = InvalidFunctionDefinition - +@for_sqlstate('42P14') class InvalidPreparedStatementDefinition(ProgrammingError): pass -_by_sqlstate['42P14'] = InvalidPreparedStatementDefinition - +@for_sqlstate('42P15') class InvalidSchemaDefinition(ProgrammingError): pass -_by_sqlstate['42P15'] = InvalidSchemaDefinition - +@for_sqlstate('42P16') class InvalidTableDefinition(ProgrammingError): pass -_by_sqlstate['42P16'] = InvalidTableDefinition - +@for_sqlstate('42P17') class InvalidObjectDefinition(ProgrammingError): pass -_by_sqlstate['42P17'] = InvalidObjectDefinition - +@for_sqlstate('42P18') class IndeterminateDatatype(ProgrammingError): pass -_by_sqlstate['42P18'] = IndeterminateDatatype - +@for_sqlstate('42P19') class InvalidRecursion(ProgrammingError): pass -_by_sqlstate['42P19'] = InvalidRecursion - +@for_sqlstate('42P20') class WindowingError(ProgrammingError): pass -_by_sqlstate['42P20'] = WindowingError - +@for_sqlstate('42P21') class CollationMismatch(ProgrammingError): pass -_by_sqlstate['42P21'] = CollationMismatch - +@for_sqlstate('42P22') class IndeterminateCollation(ProgrammingError): pass -_by_sqlstate['42P22'] = IndeterminateCollation - # Class 44 - WITH CHECK OPTION Violation +@for_sqlstate('44000') class WithCheckOptionViolation(ProgrammingError): pass -_by_sqlstate['44000'] = WithCheckOptionViolation - # Class 53 - Insufficient Resources +@for_sqlstate('53000') class InsufficientResources(OperationalError): pass -_by_sqlstate['53000'] = InsufficientResources - +@for_sqlstate('53100') class DiskFull(OperationalError): pass -_by_sqlstate['53100'] = DiskFull - +@for_sqlstate('53200') class OutOfMemory(OperationalError): pass -_by_sqlstate['53200'] = OutOfMemory - +@for_sqlstate('53300') class TooManyConnections(OperationalError): pass -_by_sqlstate['53300'] = TooManyConnections - +@for_sqlstate('53400') class ConfigurationLimitExceeded(OperationalError): pass -_by_sqlstate['53400'] = ConfigurationLimitExceeded - # Class 54 - Program Limit Exceeded +@for_sqlstate('54000') class ProgramLimitExceeded(OperationalError): pass -_by_sqlstate['54000'] = ProgramLimitExceeded - +@for_sqlstate('54001') class StatementTooComplex(OperationalError): pass -_by_sqlstate['54001'] = StatementTooComplex - +@for_sqlstate('54011') class TooManyColumns(OperationalError): pass -_by_sqlstate['54011'] = TooManyColumns - +@for_sqlstate('54023') class TooManyArguments(OperationalError): pass -_by_sqlstate['54023'] = TooManyArguments - # Class 55 - Object Not In Prerequisite State +@for_sqlstate('55000') class ObjectNotInPrerequisiteState(OperationalError): pass -_by_sqlstate['55000'] = ObjectNotInPrerequisiteState - +@for_sqlstate('55006') class ObjectInUse(OperationalError): pass -_by_sqlstate['55006'] = ObjectInUse - +@for_sqlstate('55P02') class CantChangeRuntimeParam(OperationalError): pass -_by_sqlstate['55P02'] = CantChangeRuntimeParam - +@for_sqlstate('55P03') class LockNotAvailable(OperationalError): pass -_by_sqlstate['55P03'] = LockNotAvailable - # Class 57 - Operator Intervention +@for_sqlstate('57000') class OperatorIntervention(OperationalError): pass -_by_sqlstate['57000'] = OperatorIntervention - +@for_sqlstate('57014') class QueryCanceled(QueryCanceledError): pass -_by_sqlstate['57014'] = QueryCanceled - +@for_sqlstate('57P01') class AdminShutdown(OperationalError): pass -_by_sqlstate['57P01'] = AdminShutdown - +@for_sqlstate('57P02') class CrashShutdown(OperationalError): pass -_by_sqlstate['57P02'] = CrashShutdown - +@for_sqlstate('57P03') class CannotConnectNow(OperationalError): pass -_by_sqlstate['57P03'] = CannotConnectNow - +@for_sqlstate('57P04') class DatabaseDropped(OperationalError): pass -_by_sqlstate['57P04'] = DatabaseDropped - # Class 58 - System Error (errors external to PostgreSQL itself) +@for_sqlstate('58000') class SystemError(OperationalError): pass -_by_sqlstate['58000'] = SystemError - +@for_sqlstate('58030') class IoError(OperationalError): pass -_by_sqlstate['58030'] = IoError - +@for_sqlstate('58P01') class UndefinedFile(OperationalError): pass -_by_sqlstate['58P01'] = UndefinedFile - +@for_sqlstate('58P02') class DuplicateFile(OperationalError): pass -_by_sqlstate['58P02'] = DuplicateFile - # Class 72 - Snapshot Failure +@for_sqlstate('72000') class SnapshotTooOld(DatabaseError): pass -_by_sqlstate['72000'] = SnapshotTooOld - # Class F0 - Configuration File Error +@for_sqlstate('F0000') class ConfigFileError(InternalError): pass -_by_sqlstate['F0000'] = ConfigFileError - +@for_sqlstate('F0001') class LockFileExists(InternalError): pass -_by_sqlstate['F0001'] = LockFileExists - # Class HV - Foreign Data Wrapper Error (SQL/MED) +@for_sqlstate('HV000') class FdwError(OperationalError): pass -_by_sqlstate['HV000'] = FdwError - +@for_sqlstate('HV001') class FdwOutOfMemory(OperationalError): pass -_by_sqlstate['HV001'] = FdwOutOfMemory - +@for_sqlstate('HV002') class FdwDynamicParameterValueNeeded(OperationalError): pass -_by_sqlstate['HV002'] = FdwDynamicParameterValueNeeded - +@for_sqlstate('HV004') class FdwInvalidDataType(OperationalError): pass -_by_sqlstate['HV004'] = FdwInvalidDataType - +@for_sqlstate('HV005') class FdwColumnNameNotFound(OperationalError): pass -_by_sqlstate['HV005'] = FdwColumnNameNotFound - +@for_sqlstate('HV006') class FdwInvalidDataTypeDescriptors(OperationalError): pass -_by_sqlstate['HV006'] = FdwInvalidDataTypeDescriptors - +@for_sqlstate('HV007') class FdwInvalidColumnName(OperationalError): pass -_by_sqlstate['HV007'] = FdwInvalidColumnName - +@for_sqlstate('HV008') class FdwInvalidColumnNumber(OperationalError): pass -_by_sqlstate['HV008'] = FdwInvalidColumnNumber - +@for_sqlstate('HV009') class FdwInvalidUseOfNullPointer(OperationalError): pass -_by_sqlstate['HV009'] = FdwInvalidUseOfNullPointer - +@for_sqlstate('HV00A') class FdwInvalidStringFormat(OperationalError): pass -_by_sqlstate['HV00A'] = FdwInvalidStringFormat - +@for_sqlstate('HV00B') class FdwInvalidHandle(OperationalError): pass -_by_sqlstate['HV00B'] = FdwInvalidHandle - +@for_sqlstate('HV00C') class FdwInvalidOptionIndex(OperationalError): pass -_by_sqlstate['HV00C'] = FdwInvalidOptionIndex - +@for_sqlstate('HV00D') class FdwInvalidOptionName(OperationalError): pass -_by_sqlstate['HV00D'] = FdwInvalidOptionName - +@for_sqlstate('HV00J') class FdwOptionNameNotFound(OperationalError): pass -_by_sqlstate['HV00J'] = FdwOptionNameNotFound - +@for_sqlstate('HV00K') class FdwReplyHandle(OperationalError): pass -_by_sqlstate['HV00K'] = FdwReplyHandle - +@for_sqlstate('HV00L') class FdwUnableToCreateExecution(OperationalError): pass -_by_sqlstate['HV00L'] = FdwUnableToCreateExecution - +@for_sqlstate('HV00M') class FdwUnableToCreateReply(OperationalError): pass -_by_sqlstate['HV00M'] = FdwUnableToCreateReply - +@for_sqlstate('HV00N') class FdwUnableToEstablishConnection(OperationalError): pass -_by_sqlstate['HV00N'] = FdwUnableToEstablishConnection - +@for_sqlstate('HV00P') class FdwNoSchemas(OperationalError): pass -_by_sqlstate['HV00P'] = FdwNoSchemas - +@for_sqlstate('HV00Q') class FdwSchemaNotFound(OperationalError): pass -_by_sqlstate['HV00Q'] = FdwSchemaNotFound - +@for_sqlstate('HV00R') class FdwTableNotFound(OperationalError): pass -_by_sqlstate['HV00R'] = FdwTableNotFound - +@for_sqlstate('HV010') class FdwFunctionSequenceError(OperationalError): pass -_by_sqlstate['HV010'] = FdwFunctionSequenceError - +@for_sqlstate('HV014') class FdwTooManyHandles(OperationalError): pass -_by_sqlstate['HV014'] = FdwTooManyHandles - +@for_sqlstate('HV021') class FdwInconsistentDescriptorInformation(OperationalError): pass -_by_sqlstate['HV021'] = FdwInconsistentDescriptorInformation - +@for_sqlstate('HV024') class FdwInvalidAttributeValue(OperationalError): pass -_by_sqlstate['HV024'] = FdwInvalidAttributeValue - +@for_sqlstate('HV090') class FdwInvalidStringLengthOrBufferLength(OperationalError): pass -_by_sqlstate['HV090'] = FdwInvalidStringLengthOrBufferLength - +@for_sqlstate('HV091') class FdwInvalidDescriptorFieldIdentifier(OperationalError): pass -_by_sqlstate['HV091'] = FdwInvalidDescriptorFieldIdentifier - # Class P0 - PL/pgSQL Error +@for_sqlstate('P0000') class PlpgsqlError(InternalError): pass -_by_sqlstate['P0000'] = PlpgsqlError - +@for_sqlstate('P0001') class RaiseException(InternalError): pass -_by_sqlstate['P0001'] = RaiseException - +@for_sqlstate('P0002') class NoDataFound(InternalError): pass -_by_sqlstate['P0002'] = NoDataFound - +@for_sqlstate('P0003') class TooManyRows(InternalError): pass -_by_sqlstate['P0003'] = TooManyRows - +@for_sqlstate('P0004') class AssertFailure(InternalError): pass -_by_sqlstate['P0004'] = AssertFailure - # Class XX - Internal Error -class InternalError(InternalError): +@for_sqlstate('XX000') +class InternalError_(InternalError): pass -_by_sqlstate['XX000'] = InternalError - +@for_sqlstate('XX001') class DataCorrupted(InternalError): pass -_by_sqlstate['XX001'] = DataCorrupted - +@for_sqlstate('XX002') class IndexCorrupted(InternalError): pass - -_by_sqlstate['XX002'] = IndexCorrupted diff --git a/scripts/make_errors.py b/scripts/make_errors.py index cdf299f6..6a59cf1a 100755 --- a/scripts/make_errors.py +++ b/scripts/make_errors.py @@ -114,11 +114,24 @@ def fetch_errors(versions): def generate_module_data(classes, errors): tmpl = """ +@for_sqlstate(%(errcode)r) class %(cls)s(%(base)s): - pass - -_by_sqlstate[%(errcode)r] = %(cls)s\ + pass\ """ + specific = { + '38002': 'ModifyingSqlDataNotPermittedExt', + '38003': 'ProhibitedSqlStatementAttemptedExt', + '38004': 'ReadingSqlDataNotPermittedExt', + '39004': 'NullValueNotAllowedExt', + 'XX000': 'InternalError_', + } + + seen = set(""" + Error Warning InterfaceError DataError DatabaseError ProgrammingError + IntegrityError InternalError NotSupportedError OperationalError + QueryCanceledError TransactionRollbackError + """.split()) + for clscode, clslabel in sorted(classes.items()): if clscode in ('00', '01'): # success and warning - never raised @@ -127,7 +140,14 @@ _by_sqlstate[%(errcode)r] = %(cls)s\ yield "\n\n# %s" % clslabel for errcode, errlabel in sorted(errors[clscode].items()): - clsname = errlabel.title().replace('_', '') + if errcode in specific: + clsname = specific[errcode] + else: + clsname = errlabel.title().replace('_', '') + if clsname in seen: + raise Exception("class already existing: %s" % clsname) + seen.add(clsname) + yield tmpl % { 'cls': clsname, 'base': get_base_class_name(errcode),