| Copyright | Copyright (C) 2005-2011 John Goerzen |
|---|---|
| License | BSD3 |
| Maintainer | John Goerzen <jgoerzen@complete.org> |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell98 |
Database.HDBC.PostgreSQL
Description
HDBC driver interface for PostgreSQL 8.x
Written by John Goerzen, jgoerzen@complete.org
NOTE ON DATES AND TIMES
The recommended correspondence between PostgreSQL date and time types and HDBC SqlValue types is:
- SqlLocalDate: DATE
- SqlLocalTimeOfDay: TIME WITHOUT TIME ZONE
- SqlZonedLocalTimeOfDay: TIME WITH TIME ZONE
- SqlLocalTime: TIMESTAMP WITHOUT TIME ZONE
- SqlZonedTime: TIMESTAMP WITH TIME ZONE
- SqlUTCTime: TIMESTAMP WITH TIME ZONE
- SqlDiffTime: INTERVAL
- SqlPOSIXTime: NUMERIC
- SqlEpochTime: INTEGER
- SqlTimeDiff: INTERVAL
Other combinations are possible, and may even be converted automatically. The above simply represents the types that seem the most logical correspondence, and thus are tested by the HDBC-PostgreSQL test suite.
- connectPostgreSQL :: String -> IO Connection
- withPostgreSQL :: String -> (Connection -> IO a) -> IO a
- connectPostgreSQL' :: String -> IO Connection
- withPostgreSQL' :: String -> (Connection -> IO a) -> IO a
- data Connection
- begin :: Connection -> IO ()
- successfulCompletion :: String
- warning :: String
- warningDynamicResultSetsReturned :: String
- warningImplicitZeroBitPadding :: String
- warningNullValueEliminatedInSetFunction :: String
- warningPrivilegeNotGranted :: String
- warningPrivilegeNotRevoked :: String
- warningStringDataRightTruncation :: String
- warningDeprecatedFeature :: String
- noData :: String
- noAdditionalDynamicResultSetsReturned :: String
- sqlStatementNotYetComplete :: String
- connectionException :: String
- connectionDoesNotExist :: String
- connectionFailure :: String
- sqlclientUnableToEstablishSqlconnection :: String
- sqlserverRejectedEstablishmentOfSqlconnection :: String
- transactionResolutionUnknown :: String
- protocolViolation :: String
- triggeredActionException :: String
- featureNotSupported :: String
- invalidTransactionInitiation :: String
- locatorException :: String
- lEInvalidSpecification :: String
- invalidGrantor :: String
- invalidGrantOperation :: String
- invalidRoleSpecification :: String
- cardinalityViolation :: String
- dataException :: String
- arrayElementError :: String
- arraySubscriptError :: String
- characterNotInRepertoire :: String
- datetimeFieldOverflow :: String
- datetimeValueOutOfRange :: String
- divisionByZero :: String
- errorInAssignment :: String
- escapeCharacterConflict :: String
- indicatorOverflow :: String
- intervalFieldOverflow :: String
- invalidArgumentForLog :: String
- invalidArgumentForPowerFunction :: String
- invalidArgumentForWidthBucketFunction :: String
- invalidCharacterValueForCast :: String
- invalidDatetimeFormat :: String
- invalidEscapeCharacter :: String
- invalidEscapeOctet :: String
- invalidEscapeSequence :: String
- nonstandardUseOfEscapeCharacter :: String
- invalidIndicatorParameterValue :: String
- invalidLimitValue :: String
- invalidParameterValue :: String
- invalidRegularExpression :: String
- invalidTimeZoneDisplacementValue :: String
- invalidUseOfEscapeCharacter :: String
- mostSpecificTypeMismatch :: String
- nullValueNotAllowed :: String
- nullValueNoIndicatorParameter :: String
- numericValueOutOfRange :: String
- stringDataLengthMismatch :: String
- stringDataRightTruncation :: String
- substringError :: String
- trimError :: String
- unterminatedCString :: String
- zeroLengthCharacterString :: String
- floatingPointException :: String
- invalidTextRepresentation :: String
- invalidBinaryRepresentation :: String
- badCopyFileFormat :: String
- untranslatableCharacter :: String
- notAnXmlDocument :: String
- invalidXmlDocument :: String
- invalidXmlContent :: String
- invalidXmlComment :: String
- invalidXmlProcessingInstruction :: String
- integrityConstraintViolation :: String
- restrictViolation :: String
- notNullViolation :: String
- foreignKeyViolation :: String
- uniqueViolation :: String
- checkViolation :: String
- invalidCursorState :: String
- invalidTransactionState :: String
- activeSqlTransaction :: String
- branchTransactionAlreadyActive :: String
- heldCursorRequiresSameIsolationLevel :: String
- inappropriateAccessModeForBranchTransaction :: String
- inappropriateIsolationLevelForBranchTransaction :: String
- noActiveSqlTransactionForBranchTransaction :: String
- readOnlySqlTransaction :: String
- schemaAndDataStatementMixingNotSupported :: String
- noActiveSqlTransaction :: String
- inFailedSqlTransaction :: String
- invalidSqlStatementName :: String
- triggeredDataChangeViolation :: String
- invalidAuthorizationSpecification :: String
- dependentPrivilegeDescriptorsStillExist :: String
- dependentObjectsStillExist :: String
- invalidTransactionTermination :: String
- sqlRoutineException :: String
- sREFunctionExecutedNoReturnStatement :: String
- sREModifyingSqlDataNotPermitted :: String
- sREProhibitedSqlStatementAttempted :: String
- sREReadingSqlDataNotPermitted :: String
- invalidCursorName :: String
- externalRoutineException :: String
- eREContainingSqlNotPermitted :: String
- eREModifyingSqlDataNotPermitted :: String
- eREProhibitedSqlStatementAttempted :: String
- eREReadingSqlDataNotPermitted :: String
- externalRoutineInvocationException :: String
- eRIEInvalidSqlstateReturned :: String
- eRIENullValueNotAllowed :: String
- eRIETriggerProtocolViolated :: String
- eRIESrfProtocolViolated :: String
- savepointException :: String
- sEInvalidSpecification :: String
- invalidCatalogName :: String
- invalidSchemaName :: String
- transactionRollback :: String
- tRIntegrityConstraintViolation :: String
- tRSerializationFailure :: String
- tRStatementCompletionUnknown :: String
- tRDeadlockDetected :: String
- syntaxErrorOrAccessRuleViolation :: String
- syntaxError :: String
- insufficientPrivilege :: String
- cannotCoerce :: String
- groupingError :: String
- invalidForeignKey :: String
- invalidName :: String
- nameTooLong :: String
- reservedName :: String
- datatypeMismatch :: String
- indeterminateDatatype :: String
- wrongObjectType :: String
- undefinedColumn :: String
- undefinedCursor :: String
- undefinedDatabase :: String
- undefinedFunction :: String
- undefinedPstatement :: String
- undefinedSchema :: String
- undefinedTable :: String
- undefinedParameter :: String
- undefinedObject :: String
- duplicateColumn :: String
- duplicateCursor :: String
- duplicateDatabase :: String
- duplicateFunction :: String
- duplicatePstatement :: String
- duplicateSchema :: String
- duplicateTable :: String
- duplicateAlias :: String
- duplicateObject :: String
- ambiguousColumn :: String
- ambiguousFunction :: String
- ambiguousParameter :: String
- ambiguousAlias :: String
- invalidColumnReference :: String
- invalidColumnDefinition :: String
- invalidCursorDefinition :: String
- invalidDatabaseDefinition :: String
- invalidFunctionDefinition :: String
- invalidPstatementDefinition :: String
- invalidSchemaDefinition :: String
- invalidTableDefinition :: String
- invalidObjectDefinition :: String
- withCheckOptionViolation :: String
- insufficientResources :: String
- diskFull :: String
- outOfMemory :: String
- tooManyConnections :: String
- programLimitExceeded :: String
- statementTooComplex :: String
- tooManyColumns :: String
- tooManyArguments :: String
- objectNotInPrerequisiteState :: String
- objectInUse :: String
- cantChangeRuntimeParam :: String
- lockNotAvailable :: String
- operatorIntervention :: String
- queryCanceled :: String
- adminShutdown :: String
- crashShutdown :: String
- cannotConnectNow :: String
- ioError :: String
- undefinedFile :: String
- duplicateFile :: String
- configFileError :: String
- lockFileExists :: String
- plpgsqlError :: String
- raiseException :: String
- noDataFound :: String
- tooManyRows :: String
- internalError :: String
- dataCorrupted :: String
- indexCorrupted :: String
Connecting to Databases
connectPostgreSQL :: String -> IO Connection Source #
Connect to a PostgreSQL server.
See http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT for the meaning of the connection string.
withPostgreSQL :: String -> (Connection -> IO a) -> IO a Source #
Connect to a PostgreSQL server, and automatically disconnect if the handler exits normally or throws an exception.
connectPostgreSQL' :: String -> IO Connection Source #
withPostgreSQL' :: String -> (Connection -> IO a) -> IO a Source #
data Connection Source #
Instances
Transactions
begin :: Connection -> IO () Source #
PostgreSQL Error Codes
When an SqlError is thrown, the field seState is set to one of the following
error codes.
successfulCompletion :: String Source #
Is set to "00000".
warningDynamicResultSetsReturned :: String Source #
Is set to "0100C".
warningImplicitZeroBitPadding :: String Source #
Is set to "01008".
warningNullValueEliminatedInSetFunction :: String Source #
Is set to "01003".
warningPrivilegeNotGranted :: String Source #
Is set to "01007".
warningPrivilegeNotRevoked :: String Source #
Is set to "01006".
warningStringDataRightTruncation :: String Source #
Is set to "01004".
warningDeprecatedFeature :: String Source #
Is set to "01P01".
noAdditionalDynamicResultSetsReturned :: String Source #
Is set to "02001".
sqlStatementNotYetComplete :: String Source #
Is set to "03000".
connectionException :: String Source #
Is set to "08000".
connectionDoesNotExist :: String Source #
Is set to "08003".
connectionFailure :: String Source #
Is set to "08006".
sqlclientUnableToEstablishSqlconnection :: String Source #
Is set to "08001".
sqlserverRejectedEstablishmentOfSqlconnection :: String Source #
Is set to "08004".
transactionResolutionUnknown :: String Source #
Is set to "08007".
protocolViolation :: String Source #
Is set to "08P01".
triggeredActionException :: String Source #
Is set to "09000".
featureNotSupported :: String Source #
Is set to "0A000".
invalidTransactionInitiation :: String Source #
Is set to "0B000".
locatorException :: String Source #
Is set to "0F000".
lEInvalidSpecification :: String Source #
Is set to "0F001".
invalidGrantor :: String Source #
Is set to "0L000".
invalidGrantOperation :: String Source #
Is set to "0LP01".
invalidRoleSpecification :: String Source #
Is set to "0P000".
cardinalityViolation :: String Source #
Is set to "21000".
dataException :: String Source #
Is set to "22000".
arrayElementError :: String Source #
Is set to "2202E".
arraySubscriptError :: String Source #
Same as arrayElementError.
characterNotInRepertoire :: String Source #
Is set to "22021".
datetimeFieldOverflow :: String Source #
Is set to "22008".
datetimeValueOutOfRange :: String Source #
Same as datetimeFieldOverflow.
divisionByZero :: String Source #
Is set to "22012".
errorInAssignment :: String Source #
Is set to "22005".
escapeCharacterConflict :: String Source #
Is set to "2200B".
indicatorOverflow :: String Source #
Is set to "22022".
intervalFieldOverflow :: String Source #
Is set to "22015".
invalidArgumentForLog :: String Source #
Is set to "2201E".
invalidArgumentForPowerFunction :: String Source #
Is set to "2201F".
invalidArgumentForWidthBucketFunction :: String Source #
Is set to "2201G".
invalidCharacterValueForCast :: String Source #
Is set to "22018".
invalidDatetimeFormat :: String Source #
Is set to "22007".
invalidEscapeCharacter :: String Source #
Is set to "22019".
invalidEscapeOctet :: String Source #
Is set to "2200D".
invalidEscapeSequence :: String Source #
Is set to "22025".
nonstandardUseOfEscapeCharacter :: String Source #
Is set to "22P06".
invalidIndicatorParameterValue :: String Source #
Is set to "22010".
invalidLimitValue :: String Source #
Is set to "22020".
invalidParameterValue :: String Source #
Is set to "22023".
invalidRegularExpression :: String Source #
Is set to "2201B".
invalidTimeZoneDisplacementValue :: String Source #
Is set to "22009".
invalidUseOfEscapeCharacter :: String Source #
Is set to "2200C".
mostSpecificTypeMismatch :: String Source #
Is set to "2200G".
nullValueNotAllowed :: String Source #
Is set to "22004".
nullValueNoIndicatorParameter :: String Source #
Is set to "22002".
numericValueOutOfRange :: String Source #
Is set to "22003".
stringDataLengthMismatch :: String Source #
Is set to "22026".
stringDataRightTruncation :: String Source #
Is set to "22001".
substringError :: String Source #
Is set to "22011".
unterminatedCString :: String Source #
Is set to "22024".
zeroLengthCharacterString :: String Source #
Is set to "2200F".
floatingPointException :: String Source #
Is set to "22P01".
invalidTextRepresentation :: String Source #
Is set to "22P02".
invalidBinaryRepresentation :: String Source #
Is set to "22P03".
badCopyFileFormat :: String Source #
Is set to "22P04".
untranslatableCharacter :: String Source #
Is set to "22P05".
notAnXmlDocument :: String Source #
Is set to "2200L".
invalidXmlDocument :: String Source #
Is set to "2200M".
invalidXmlContent :: String Source #
Is set to "2200N".
invalidXmlComment :: String Source #
Is set to "2200S".
invalidXmlProcessingInstruction :: String Source #
Is set to "2200T".
integrityConstraintViolation :: String Source #
Is set to "23000".
restrictViolation :: String Source #
Is set to "23001".
notNullViolation :: String Source #
Is set to "23502".
foreignKeyViolation :: String Source #
Is set to "23503".
uniqueViolation :: String Source #
Is set to "23505".
checkViolation :: String Source #
Is set to "23514".
invalidCursorState :: String Source #
Is set to "24000".
invalidTransactionState :: String Source #
Is set to "25000".
activeSqlTransaction :: String Source #
Is set to "25001".
branchTransactionAlreadyActive :: String Source #
Is set to "25002".
heldCursorRequiresSameIsolationLevel :: String Source #
Is set to "25008".
inappropriateAccessModeForBranchTransaction :: String Source #
Is set to "25003".
inappropriateIsolationLevelForBranchTransaction :: String Source #
Is set to "25004".
noActiveSqlTransactionForBranchTransaction :: String Source #
Is set to "25005".
readOnlySqlTransaction :: String Source #
Is set to "25006".
schemaAndDataStatementMixingNotSupported :: String Source #
Is set to "25007".
noActiveSqlTransaction :: String Source #
Is set to "25P01".
inFailedSqlTransaction :: String Source #
Is set to "25P02".
invalidSqlStatementName :: String Source #
Is set to "26000".
triggeredDataChangeViolation :: String Source #
Is set to "27000".
invalidAuthorizationSpecification :: String Source #
Is set to "28000".
dependentPrivilegeDescriptorsStillExist :: String Source #
Is set to "2B000".
dependentObjectsStillExist :: String Source #
Is set to "2BP01".
invalidTransactionTermination :: String Source #
Is set to "2D000".
sqlRoutineException :: String Source #
Is set to "2F000".
sREFunctionExecutedNoReturnStatement :: String Source #
Is set to "2F005".
sREModifyingSqlDataNotPermitted :: String Source #
Is set to "2F002".
sREProhibitedSqlStatementAttempted :: String Source #
Is set to "2F003".
sREReadingSqlDataNotPermitted :: String Source #
Is set to "2F004".
invalidCursorName :: String Source #
Is set to "34000".
externalRoutineException :: String Source #
Is set to "38000".
eREContainingSqlNotPermitted :: String Source #
Is set to "38001".
eREModifyingSqlDataNotPermitted :: String Source #
Is set to "38002".
eREProhibitedSqlStatementAttempted :: String Source #
Is set to "38003".
eREReadingSqlDataNotPermitted :: String Source #
Is set to "38004".
externalRoutineInvocationException :: String Source #
Is set to "39000".
eRIEInvalidSqlstateReturned :: String Source #
Is set to "39001".
eRIENullValueNotAllowed :: String Source #
Is set to "39004".
eRIETriggerProtocolViolated :: String Source #
Is set to "39P01".
eRIESrfProtocolViolated :: String Source #
Is set to "39P02".
savepointException :: String Source #
Is set to "3B000".
sEInvalidSpecification :: String Source #
Is set to "3B001".
invalidCatalogName :: String Source #
Is set to "3D000".
invalidSchemaName :: String Source #
Is set to "3F000".
transactionRollback :: String Source #
Is set to "40000".
tRIntegrityConstraintViolation :: String Source #
Is set to "40002".
tRSerializationFailure :: String Source #
Is set to "40001".
tRStatementCompletionUnknown :: String Source #
Is set to "40003".
tRDeadlockDetected :: String Source #
Is set to "40P01".
syntaxErrorOrAccessRuleViolation :: String Source #
Is set to "42000".
syntaxError :: String Source #
Is set to "42601".
insufficientPrivilege :: String Source #
Is set to "42501".
cannotCoerce :: String Source #
Is set to "42846".
groupingError :: String Source #
Is set to "42803".
invalidForeignKey :: String Source #
Is set to "42830".
invalidName :: String Source #
Is set to "42602".
nameTooLong :: String Source #
Is set to "42622".
reservedName :: String Source #
Is set to "42939".
datatypeMismatch :: String Source #
Is set to "42804".
indeterminateDatatype :: String Source #
Is set to "42P18".
wrongObjectType :: String Source #
Is set to "42809".
undefinedColumn :: String Source #
Is set to "42703".
undefinedCursor :: String Source #
Same as invalidCursorName.
undefinedDatabase :: String Source #
Same as invalidCatalogName.
undefinedFunction :: String Source #
Is set to "42883".
undefinedPstatement :: String Source #
Same as invalidSqlStatementName.
undefinedSchema :: String Source #
Same as invalidSchemaName.
undefinedTable :: String Source #
Is set to "42P01".
undefinedParameter :: String Source #
Is set to "42P02".
undefinedObject :: String Source #
Is set to "42704".
duplicateColumn :: String Source #
Is set to "42701".
duplicateCursor :: String Source #
Is set to "42P03".
duplicateDatabase :: String Source #
Is set to "42P04".
duplicateFunction :: String Source #
Is set to "42723".
duplicatePstatement :: String Source #
Is set to "42P05".
duplicateSchema :: String Source #
Is set to "42P06".
duplicateTable :: String Source #
Is set to "42P07".
duplicateAlias :: String Source #
Is set to "42712".
duplicateObject :: String Source #
Is set to "42710".
ambiguousColumn :: String Source #
Is set to "42702".
ambiguousFunction :: String Source #
Is set to "42725".
ambiguousParameter :: String Source #
Is set to "42P08".
ambiguousAlias :: String Source #
Is set to "42P09".
invalidColumnReference :: String Source #
Is set to "42P10".
invalidColumnDefinition :: String Source #
Is set to "42611".
invalidCursorDefinition :: String Source #
Is set to "42P11".
invalidDatabaseDefinition :: String Source #
Is set to "42P12".
invalidFunctionDefinition :: String Source #
Is set to "42P13".
invalidPstatementDefinition :: String Source #
Is set to "42P14".
invalidSchemaDefinition :: String Source #
Is set to "42P15".
invalidTableDefinition :: String Source #
Is set to "42P16".
invalidObjectDefinition :: String Source #
Is set to "42P17".
withCheckOptionViolation :: String Source #
Is set to "44000".
insufficientResources :: String Source #
Is set to "53000".
outOfMemory :: String Source #
Is set to "53200".
tooManyConnections :: String Source #
Is set to "53300".
programLimitExceeded :: String Source #
Is set to "54000".
statementTooComplex :: String Source #
Is set to "54001".
tooManyColumns :: String Source #
Is set to "54011".
tooManyArguments :: String Source #
Is set to "54023".
objectNotInPrerequisiteState :: String Source #
Is set to "55000".
objectInUse :: String Source #
Is set to "55006".
cantChangeRuntimeParam :: String Source #
Is set to "55P02".
lockNotAvailable :: String Source #
Is set to "55P03".
operatorIntervention :: String Source #
Is set to "57000".
queryCanceled :: String Source #
Is set to "57014".
adminShutdown :: String Source #
Is set to "57P01".
crashShutdown :: String Source #
Is set to "57P02".
cannotConnectNow :: String Source #
Is set to "57P03".
undefinedFile :: String Source #
Is set to "58P01".
duplicateFile :: String Source #
Is set to "58P02".
configFileError :: String Source #
Is set to "F0000".
lockFileExists :: String Source #
Is set to "F0001".
plpgsqlError :: String Source #
Is set to "P0000".
raiseException :: String Source #
Is set to "P0001".
noDataFound :: String Source #
Is set to "P0002".
tooManyRows :: String Source #
Is set to "P0003".
internalError :: String Source #
Is set to "XX000".
dataCorrupted :: String Source #
Is set to "XX001".
indexCorrupted :: String Source #
Is set to "XX002".
Threading
Provided the local libpq library is thread-safe, multiple Connections may be used
to have concurrent database queries. Concurrent queries issued on a single
Connection will be performed serially.
When the local libpq library is not thread-safe (ie. it has not been compiled with --enable-thread-safety), only a single database function will be performed at a time.