| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hpgsql.InternalTypes
Synopsis
- data ConnectionString = ConnectionString {}
- data ConnectOpts = ConnectOpts {}
- data PostgresError = PostgresError {}
- data IrrecoverableHpgsqlError = IrrecoverableHpgsqlError {}
- data ErrorDetail
- data NotificationResponse = NotificationResponse {
- notifierPid :: !Int32
- channelName :: !Text
- notifPayload :: !Text
- data ResetConnectionOpts = ResetConnectionOpts {}
- data TransactionStatus
- newtype EncodingContext = EncodingContext {
- typeInfoCache :: TypeInfoCache
- throwIrrecoverableError :: MonadThrow m => Text -> m a
- data SingleQueryFragment
- data Query = Query {
- queryString :: ![SingleQueryFragment]
- queryParams :: ![EncodingContext -> (Maybe Oid, BinaryField)]
- isPrepared :: !Bool
- data SingleQuery = SingleQuery {
- queryString :: !ByteString
- queryParams :: ![EncodingContext -> (Maybe Oid, BinaryField)]
- preparedStmtHash :: !(Maybe String)
- queryToByteString :: Query -> ByteString
- breakQueryIntoStatements :: Query -> NonEmpty SingleQuery
- renumberParamsFrom :: [SingleQueryFragment] -> Int -> (Int, [SingleQueryFragment])
- data ParseComplete = ParseComplete
- data BindComplete = BindComplete
- data NoData = NoData
- newtype RowDescription = RowDescription {
- resultColumnTypes :: [(Text, Oid)]
- data CopyInResponse = CopyInResponse
- newtype ErrorResponse = ErrorResponse (Map ErrorDetail ByteString)
- newtype CommandComplete = CommandComplete {}
- newtype DataRow = DataRow {}
- newtype ReadyForQuery = ReadyForQuery TransactionStatus
- data InternalConnectionState = InternalConnectionState {}
- data WeakThreadId = WeakThreadId !(Weak ThreadId) !Word64
- data QueryState = QueryState {}
- newtype QueryId = QueryId Integer
- data QueryProtocol
- data CopyQueryState
- data ResponseMsgsReceived
- = NoMsgsReceived
- | ParseCompleteReceived ParseComplete
- | BindCompleteReceived BindComplete
- | RowDescriptionOrNoDataOrCopyInResponseReceived (Either3 NoData RowDescription CopyInResponse)
- | ErrorResponseReceived (Maybe (Either3 NoData RowDescription CopyInResponse)) ErrorResponse
- | CommandCompleteReceived (Either3 NoData RowDescription CopyInResponse) CommandComplete
- | ReadyForQueryReceived (Either ErrorResponse CommandComplete) ReadyForQuery
- data ResponseMsg
- data Either3 a b c
- data HPgConnection = HPgConnection {
- socket :: !Socket
- socketClosed :: !(MVar Bool)
- recvBuffer :: !(MVar ByteString)
- sendBuffer :: !(MVar [(ByteString, STM ())])
- socketMutex :: !Mutex
- originalConnStr :: !ConnectionString
- connectedTo :: !AddrInfo
- encodingContext :: !(MVar EncodingContext)
- parameterStatusMap :: !(MVar (Map Text Text))
- internalConnectionState :: !(TVar InternalConnectionState)
- connPid :: !Int32
- cancelSecretKey :: !Int32
- connOpts :: !ConnectOpts
- newtype Mutex = Mutex (TVar (Maybe (WeakThreadId, Int)))
- data Pipeline a = Pipeline [(SingleQuery, Maybe Int)] (HPgConnection -> [QueryId] -> a)
- mkMutex :: IO Mutex
Simple types
data ConnectionString Source #
Constructors
| ConnectionString | |
Instances
| Show ConnectionString Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ConnectionString -> ShowS # show :: ConnectionString -> String # showList :: [ConnectionString] -> ShowS # | |
| Eq ConnectionString Source # | |
Defined in Hpgsql.InternalTypes Methods (==) :: ConnectionString -> ConnectionString -> Bool # (/=) :: ConnectionString -> ConnectionString -> Bool # | |
data ConnectOpts Source #
Constructors
| ConnectOpts | |
Fields
| |
data PostgresError Source #
An error coming from PostgreSQL. You can safely handle this and continue using the connection.
Constructors
| PostgresError | |
Fields | |
Instances
| Exception PostgresError Source # | |
Defined in Hpgsql.InternalTypes Methods toException :: PostgresError -> SomeException # fromException :: SomeException -> Maybe PostgresError # displayException :: PostgresError -> String # backtraceDesired :: PostgresError -> Bool # | |
| Show PostgresError Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> PostgresError -> ShowS # show :: PostgresError -> String # showList :: [PostgresError] -> ShowS # | |
data IrrecoverableHpgsqlError Source #
If you receive this exception, don't run any further SQL statements or use it for anything. Just close the connection with closeForcefully and discard it.
Constructors
| IrrecoverableHpgsqlError | |
Fields | |
Instances
| Exception IrrecoverableHpgsqlError Source # | |
Defined in Hpgsql.InternalTypes | |
| Show IrrecoverableHpgsqlError Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> IrrecoverableHpgsqlError -> ShowS # show :: IrrecoverableHpgsqlError -> String # showList :: [IrrecoverableHpgsqlError] -> ShowS # | |
data ErrorDetail Source #
Constructors
Instances
| Show ErrorDetail Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ErrorDetail -> ShowS # show :: ErrorDetail -> String # showList :: [ErrorDetail] -> ShowS # | |
| Eq ErrorDetail Source # | |
Defined in Hpgsql.InternalTypes | |
| Ord ErrorDetail Source # | |
Defined in Hpgsql.InternalTypes Methods compare :: ErrorDetail -> ErrorDetail -> Ordering # (<) :: ErrorDetail -> ErrorDetail -> Bool # (<=) :: ErrorDetail -> ErrorDetail -> Bool # (>) :: ErrorDetail -> ErrorDetail -> Bool # (>=) :: ErrorDetail -> ErrorDetail -> Bool # max :: ErrorDetail -> ErrorDetail -> ErrorDetail # min :: ErrorDetail -> ErrorDetail -> ErrorDetail # | |
data NotificationResponse Source #
Constructors
| NotificationResponse | |
Fields
| |
Instances
| Show NotificationResponse Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> NotificationResponse -> ShowS # show :: NotificationResponse -> String # showList :: [NotificationResponse] -> ShowS # | |
| Eq NotificationResponse Source # | |
Defined in Hpgsql.InternalTypes Methods (==) :: NotificationResponse -> NotificationResponse -> Bool # (/=) :: NotificationResponse -> NotificationResponse -> Bool # | |
data ResetConnectionOpts Source #
Constructors
| ResetConnectionOpts | |
Fields
| |
data TransactionStatus Source #
Constructors
| TransActive | A command is in progress |
| TransIdle | Not inside a transaction |
| TransInTrans | Inside a transaction, but no command running |
| TransInError |
Instances
| Show TransactionStatus Source # | |
Defined in Hpgsql.TransactionStatusInternal Methods showsPrec :: Int -> TransactionStatus -> ShowS # show :: TransactionStatus -> String # showList :: [TransactionStatus] -> ShowS # | |
| Eq TransactionStatus Source # | |
Defined in Hpgsql.TransactionStatusInternal Methods (==) :: TransactionStatus -> TransactionStatus -> Bool # (/=) :: TransactionStatus -> TransactionStatus -> Bool # | |
newtype EncodingContext Source #
Constructors
| EncodingContext | |
Fields
| |
throwIrrecoverableError :: MonadThrow m => Text -> m a Source #
Query types (moved from Hpgsql.Query)
data SingleQueryFragment Source #
A fragment of a single SQL statement, which is either static SQL or a placeholder for a query argument.
Constructors
| FragmentOfStaticSql !ByteString | |
| FragmentWithSemiColon | |
| FragmentOfCommentsOrWhitespace !ByteString | |
| QueryArgumentPlaceHolder !Int | The number/index of the query argument, starting from 1 in a single statement |
Instances
| Show SingleQueryFragment Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> SingleQueryFragment -> ShowS # show :: SingleQueryFragment -> String # showList :: [SingleQueryFragment] -> ShowS # | |
| Eq SingleQueryFragment Source # | |
Defined in Hpgsql.InternalTypes Methods (==) :: SingleQueryFragment -> SingleQueryFragment -> Bool # (/=) :: SingleQueryFragment -> SingleQueryFragment -> Bool # | |
Query is some SQL with values of query arguments inside and also whether it's a prepared statement.
It can be concatenated to other Query objects freely, and concatenating chains of Queries with
at least one prepared statement among them makes the final Query object a prepared statement, too.
You can build this with the sql and sqlPrep quasiquoters, the former for unprepared statements,
and you can use preparedStatement and nonPreparedStatement to convert between them.
Constructors
| Query | |
Fields
| |
data SingleQuery Source #
A single statement, not multiple, with dollar-numbered query arguments starting from $1.
Constructors
| SingleQuery | |
Fields
| |
Instances
| Show SingleQuery Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> SingleQuery -> ShowS # show :: SingleQuery -> String # showList :: [SingleQuery] -> ShowS # | |
queryToByteString :: Query -> ByteString Source #
breakQueryIntoStatements :: Query -> NonEmpty SingleQuery Source #
For internal usage only. Takes a Query and breaks it up into
individual SQL statements that can be sent to a postgres backend.
renumberParamsFrom :: [SingleQueryFragment] -> Int -> (Int, [SingleQueryFragment]) Source #
Returns new fragments remapped with renumberFrom as the smallest query argument number,
and also returns the maximum (new) query argument number, or 0 if there were no query arguments.
Msgs types (moved to avoid cycles)
data ParseComplete Source #
Constructors
| ParseComplete |
Instances
| Show ParseComplete Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ParseComplete -> ShowS # show :: ParseComplete -> String # showList :: [ParseComplete] -> ShowS # | |
data BindComplete Source #
Constructors
| BindComplete |
Instances
| Show BindComplete Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> BindComplete -> ShowS # show :: BindComplete -> String # showList :: [BindComplete] -> ShowS # | |
Constructors
| NoData |
newtype RowDescription Source #
Column names and type OIDs.
Constructors
| RowDescription | |
Fields
| |
Instances
| Show RowDescription Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> RowDescription -> ShowS # show :: RowDescription -> String # showList :: [RowDescription] -> ShowS # | |
data CopyInResponse Source #
Constructors
| CopyInResponse |
Instances
| Show CopyInResponse Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> CopyInResponse -> ShowS # show :: CopyInResponse -> String # showList :: [CopyInResponse] -> ShowS # | |
newtype ErrorResponse Source #
Constructors
| ErrorResponse (Map ErrorDetail ByteString) |
Instances
| Show ErrorResponse Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ErrorResponse -> ShowS # show :: ErrorResponse -> String # showList :: [ErrorResponse] -> ShowS # | |
newtype CommandComplete Source #
Constructors
| CommandComplete | |
Instances
| Show CommandComplete Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> CommandComplete -> ShowS # show :: CommandComplete -> String # showList :: [CommandComplete] -> ShowS # | |
Constructors
| DataRow | |
Fields | |
newtype ReadyForQuery Source #
Constructors
| ReadyForQuery TransactionStatus |
Instances
| Show ReadyForQuery Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ReadyForQuery -> ShowS # show :: ReadyForQuery -> String # showList :: [ReadyForQuery] -> ShowS # | |
Internal connection state types (moved to avoid cycles)
data InternalConnectionState Source #
Constructors
| InternalConnectionState | |
Fields
| |
data WeakThreadId Source #
From the docs, "in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature will hopefully be corrected at a later date.". And as per https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Control-Concurrent.html#v:mkWeakThreadId even BlockedIndefinitely exceptions aren't delivered if we held a ThreadId directly, so we only keep a WeakThreadId.
Constructors
| WeakThreadId !(Weak ThreadId) !Word64 |
Instances
| Show WeakThreadId Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> WeakThreadId -> ShowS # show :: WeakThreadId -> String # showList :: [WeakThreadId] -> ShowS # | |
| Eq WeakThreadId Source # | |
Defined in Hpgsql.InternalTypes | |
data QueryState Source #
Constructors
| QueryState | |
Fields
| |
Instances
| Show QueryState Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> QueryState -> ShowS # show :: QueryState -> String # showList :: [QueryState] -> ShowS # | |
An Integer avoids any headaches from wrap-around when comparing query ids. An Int64 should be fine, but the cost of this is negligible.
Instances
| Enum QueryId Source # | |
| Num QueryId Source # | |
| Show QueryId Source # | |
| Eq QueryId Source # | |
| Ord QueryId Source # | |
Defined in Hpgsql.InternalTypes | |
data QueryProtocol Source #
Constructors
| CopyQuery CopyQueryState | |
| ExtendedQuery |
Instances
| Show QueryProtocol Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> QueryProtocol -> ShowS # show :: QueryProtocol -> String # showList :: [QueryProtocol] -> ShowS # | |
| Eq QueryProtocol Source # | |
Defined in Hpgsql.InternalTypes Methods (==) :: QueryProtocol -> QueryProtocol -> Bool # (/=) :: QueryProtocol -> QueryProtocol -> Bool # | |
data CopyQueryState Source #
Constructors
| StillCopying | |
| CopyDoneAndSyncSent | |
| CopyFailAndSyncSent |
Instances
| Show CopyQueryState Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> CopyQueryState -> ShowS # show :: CopyQueryState -> String # showList :: [CopyQueryState] -> ShowS # | |
| Eq CopyQueryState Source # | |
Defined in Hpgsql.InternalTypes Methods (==) :: CopyQueryState -> CopyQueryState -> Bool # (/=) :: CopyQueryState -> CopyQueryState -> Bool # | |
data ResponseMsgsReceived Source #
Constructors
Instances
| Show ResponseMsgsReceived Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ResponseMsgsReceived -> ShowS # show :: ResponseMsgsReceived -> String # showList :: [ResponseMsgsReceived] -> ShowS # | |
data ResponseMsg Source #
Constructors
Instances
| Show ResponseMsg Source # | |
Defined in Hpgsql.InternalTypes Methods showsPrec :: Int -> ResponseMsg -> ShowS # show :: ResponseMsg -> String # showList :: [ResponseMsg] -> ShowS # | |
Connection and Pipeline types
data HPgConnection Source #
Constructors
| HPgConnection | |
Fields
| |
Instances
| Eq HPgConnection Source # | |
Defined in Hpgsql.InternalTypes Methods (==) :: HPgConnection -> HPgConnection -> Bool # (/=) :: HPgConnection -> HPgConnection -> Bool # | |
A reentrant mutex, i.e. one that can be re-acquired by the same thread without deadlocking.
Constructors
| Mutex (TVar (Maybe (WeakThreadId, Int))) |
Constructors
| Pipeline [(SingleQuery, Maybe Int)] (HPgConnection -> [QueryId] -> a) |