| Portability | portable |
|---|---|
| Stability | provisional |
| Maintainer | John Goerzen <jgoerzen@complete.org> |
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 ConnectionSource
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 aSource
Connect to a PostgreSQL server, and automatically disconnect if the handler exits normally or throws an exception.
withPostgreSQL' :: String -> (Connection -> IO a) -> IO aSource
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 :: StringSource
Is set to "00000".
warningDynamicResultSetsReturned :: StringSource
Is set to "0100C".
warningImplicitZeroBitPadding :: StringSource
Is set to "01008".
warningNullValueEliminatedInSetFunction :: StringSource
Is set to "01003".
warningPrivilegeNotGranted :: StringSource
Is set to "01007".
warningPrivilegeNotRevoked :: StringSource
Is set to "01006".
warningStringDataRightTruncation :: StringSource
Is set to "01004".
warningDeprecatedFeature :: StringSource
Is set to "01P01".
noAdditionalDynamicResultSetsReturned :: StringSource
Is set to "02001".
sqlStatementNotYetComplete :: StringSource
Is set to "03000".
connectionException :: StringSource
Is set to "08000".
connectionDoesNotExist :: StringSource
Is set to "08003".
connectionFailure :: StringSource
Is set to "08006".
sqlclientUnableToEstablishSqlconnection :: StringSource
Is set to "08001".
sqlserverRejectedEstablishmentOfSqlconnection :: StringSource
Is set to "08004".
transactionResolutionUnknown :: StringSource
Is set to "08007".
protocolViolation :: StringSource
Is set to "08P01".
triggeredActionException :: StringSource
Is set to "09000".
featureNotSupported :: StringSource
Is set to "0A000".
invalidTransactionInitiation :: StringSource
Is set to "0B000".
locatorException :: StringSource
Is set to "0F000".
lEInvalidSpecification :: StringSource
Is set to "0F001".
invalidGrantor :: StringSource
Is set to "0L000".
invalidGrantOperation :: StringSource
Is set to "0LP01".
invalidRoleSpecification :: StringSource
Is set to "0P000".
cardinalityViolation :: StringSource
Is set to "21000".
Is set to "22000".
arrayElementError :: StringSource
Is set to "2202E".
arraySubscriptError :: StringSource
Same as arrayElementError.
characterNotInRepertoire :: StringSource
Is set to "22021".
datetimeFieldOverflow :: StringSource
Is set to "22008".
divisionByZero :: StringSource
Is set to "22012".
errorInAssignment :: StringSource
Is set to "22005".
escapeCharacterConflict :: StringSource
Is set to "2200B".
indicatorOverflow :: StringSource
Is set to "22022".
intervalFieldOverflow :: StringSource
Is set to "22015".
invalidArgumentForLog :: StringSource
Is set to "2201E".
invalidArgumentForPowerFunction :: StringSource
Is set to "2201F".
invalidArgumentForWidthBucketFunction :: StringSource
Is set to "2201G".
invalidCharacterValueForCast :: StringSource
Is set to "22018".
invalidDatetimeFormat :: StringSource
Is set to "22007".
invalidEscapeCharacter :: StringSource
Is set to "22019".
invalidEscapeOctet :: StringSource
Is set to "2200D".
invalidEscapeSequence :: StringSource
Is set to "22025".
nonstandardUseOfEscapeCharacter :: StringSource
Is set to "22P06".
invalidIndicatorParameterValue :: StringSource
Is set to "22010".
invalidLimitValue :: StringSource
Is set to "22020".
invalidParameterValue :: StringSource
Is set to "22023".
invalidRegularExpression :: StringSource
Is set to "2201B".
invalidTimeZoneDisplacementValue :: StringSource
Is set to "22009".
invalidUseOfEscapeCharacter :: StringSource
Is set to "2200C".
mostSpecificTypeMismatch :: StringSource
Is set to "2200G".
nullValueNotAllowed :: StringSource
Is set to "22004".
nullValueNoIndicatorParameter :: StringSource
Is set to "22002".
numericValueOutOfRange :: StringSource
Is set to "22003".
stringDataLengthMismatch :: StringSource
Is set to "22026".
stringDataRightTruncation :: StringSource
Is set to "22001".
substringError :: StringSource
Is set to "22011".
unterminatedCString :: StringSource
Is set to "22024".
zeroLengthCharacterString :: StringSource
Is set to "2200F".
floatingPointException :: StringSource
Is set to "22P01".
invalidTextRepresentation :: StringSource
Is set to "22P02".
invalidBinaryRepresentation :: StringSource
Is set to "22P03".
badCopyFileFormat :: StringSource
Is set to "22P04".
untranslatableCharacter :: StringSource
Is set to "22P05".
notAnXmlDocument :: StringSource
Is set to "2200L".
invalidXmlDocument :: StringSource
Is set to "2200M".
invalidXmlContent :: StringSource
Is set to "2200N".
invalidXmlComment :: StringSource
Is set to "2200S".
invalidXmlProcessingInstruction :: StringSource
Is set to "2200T".
integrityConstraintViolation :: StringSource
Is set to "23000".
restrictViolation :: StringSource
Is set to "23001".
notNullViolation :: StringSource
Is set to "23502".
foreignKeyViolation :: StringSource
Is set to "23503".
uniqueViolation :: StringSource
Is set to "23505".
checkViolation :: StringSource
Is set to "23514".
invalidCursorState :: StringSource
Is set to "24000".
invalidTransactionState :: StringSource
Is set to "25000".
activeSqlTransaction :: StringSource
Is set to "25001".
branchTransactionAlreadyActive :: StringSource
Is set to "25002".
heldCursorRequiresSameIsolationLevel :: StringSource
Is set to "25008".
inappropriateAccessModeForBranchTransaction :: StringSource
Is set to "25003".
inappropriateIsolationLevelForBranchTransaction :: StringSource
Is set to "25004".
noActiveSqlTransactionForBranchTransaction :: StringSource
Is set to "25005".
readOnlySqlTransaction :: StringSource
Is set to "25006".
schemaAndDataStatementMixingNotSupported :: StringSource
Is set to "25007".
noActiveSqlTransaction :: StringSource
Is set to "25P01".
inFailedSqlTransaction :: StringSource
Is set to "25P02".
invalidSqlStatementName :: StringSource
Is set to "26000".
triggeredDataChangeViolation :: StringSource
Is set to "27000".
invalidAuthorizationSpecification :: StringSource
Is set to "28000".
dependentPrivilegeDescriptorsStillExist :: StringSource
Is set to "2B000".
dependentObjectsStillExist :: StringSource
Is set to "2BP01".
invalidTransactionTermination :: StringSource
Is set to "2D000".
sqlRoutineException :: StringSource
Is set to "2F000".
sREFunctionExecutedNoReturnStatement :: StringSource
Is set to "2F005".
sREModifyingSqlDataNotPermitted :: StringSource
Is set to "2F002".
sREProhibitedSqlStatementAttempted :: StringSource
Is set to "2F003".
sREReadingSqlDataNotPermitted :: StringSource
Is set to "2F004".
invalidCursorName :: StringSource
Is set to "34000".
externalRoutineException :: StringSource
Is set to "38000".
eREContainingSqlNotPermitted :: StringSource
Is set to "38001".
eREModifyingSqlDataNotPermitted :: StringSource
Is set to "38002".
eREProhibitedSqlStatementAttempted :: StringSource
Is set to "38003".
eREReadingSqlDataNotPermitted :: StringSource
Is set to "38004".
externalRoutineInvocationException :: StringSource
Is set to "39000".
eRIEInvalidSqlstateReturned :: StringSource
Is set to "39001".
eRIENullValueNotAllowed :: StringSource
Is set to "39004".
eRIETriggerProtocolViolated :: StringSource
Is set to "39P01".
eRIESrfProtocolViolated :: StringSource
Is set to "39P02".
savepointException :: StringSource
Is set to "3B000".
sEInvalidSpecification :: StringSource
Is set to "3B001".
invalidCatalogName :: StringSource
Is set to "3D000".
invalidSchemaName :: StringSource
Is set to "3F000".
transactionRollback :: StringSource
Is set to "40000".
tRIntegrityConstraintViolation :: StringSource
Is set to "40002".
tRSerializationFailure :: StringSource
Is set to "40001".
tRStatementCompletionUnknown :: StringSource
Is set to "40003".
tRDeadlockDetected :: StringSource
Is set to "40P01".
syntaxErrorOrAccessRuleViolation :: StringSource
Is set to "42000".
Is set to "42601".
insufficientPrivilege :: StringSource
Is set to "42501".
Is set to "42846".
Is set to "42803".
invalidForeignKey :: StringSource
Is set to "42830".
Is set to "42602".
Is set to "42622".
Is set to "42939".
datatypeMismatch :: StringSource
Is set to "42804".
indeterminateDatatype :: StringSource
Is set to "42P18".
wrongObjectType :: StringSource
Is set to "42809".
undefinedColumn :: StringSource
Is set to "42703".
undefinedCursor :: StringSource
Same as invalidCursorName.
undefinedDatabase :: StringSource
Same as invalidCatalogName.
undefinedFunction :: StringSource
Is set to "42883".
undefinedSchema :: StringSource
Same as invalidSchemaName.
undefinedTable :: StringSource
Is set to "42P01".
undefinedParameter :: StringSource
Is set to "42P02".
undefinedObject :: StringSource
Is set to "42704".
duplicateColumn :: StringSource
Is set to "42701".
duplicateCursor :: StringSource
Is set to "42P03".
duplicateDatabase :: StringSource
Is set to "42P04".
duplicateFunction :: StringSource
Is set to "42723".
duplicatePstatement :: StringSource
Is set to "42P05".
duplicateSchema :: StringSource
Is set to "42P06".
duplicateTable :: StringSource
Is set to "42P07".
duplicateAlias :: StringSource
Is set to "42712".
duplicateObject :: StringSource
Is set to "42710".
ambiguousColumn :: StringSource
Is set to "42702".
ambiguousFunction :: StringSource
Is set to "42725".
ambiguousParameter :: StringSource
Is set to "42P08".
ambiguousAlias :: StringSource
Is set to "42P09".
invalidColumnReference :: StringSource
Is set to "42P10".
invalidColumnDefinition :: StringSource
Is set to "42611".
invalidCursorDefinition :: StringSource
Is set to "42P11".
invalidDatabaseDefinition :: StringSource
Is set to "42P12".
invalidFunctionDefinition :: StringSource
Is set to "42P13".
invalidPstatementDefinition :: StringSource
Is set to "42P14".
invalidSchemaDefinition :: StringSource
Is set to "42P15".
invalidTableDefinition :: StringSource
Is set to "42P16".
invalidObjectDefinition :: StringSource
Is set to "42P17".
withCheckOptionViolation :: StringSource
Is set to "44000".
insufficientResources :: StringSource
Is set to "53000".
Is set to "53200".
tooManyConnections :: StringSource
Is set to "53300".
programLimitExceeded :: StringSource
Is set to "54000".
statementTooComplex :: StringSource
Is set to "54001".
tooManyColumns :: StringSource
Is set to "54011".
tooManyArguments :: StringSource
Is set to "54023".
objectNotInPrerequisiteState :: StringSource
Is set to "55000".
Is set to "55006".
cantChangeRuntimeParam :: StringSource
Is set to "55P02".
lockNotAvailable :: StringSource
Is set to "55P03".
operatorIntervention :: StringSource
Is set to "57000".
Is set to "57014".
Is set to "57P01".
Is set to "57P02".
cannotConnectNow :: StringSource
Is set to "57P03".
Is set to "58P01".
Is set to "58P02".
configFileError :: StringSource
Is set to "F0000".
lockFileExists :: StringSource
Is set to "F0001".
Is set to "P0000".
raiseException :: StringSource
Is set to "P0001".
Is set to "P0002".
Is set to "P0003".
Is set to "XX000".
Is set to "XX001".
indexCorrupted :: StringSource
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.