hpgsql
Safe HaskellNone
LanguageHaskell2010

Hpgsql.InternalTypes

Synopsis

Simple types

data ConnectOpts Source #

Constructors

ConnectOpts 

Fields

  • killedThreadPollIntervalMs :: Int

    How long in ms Hpgsql will sleep before re-checking if active queries have been orphaned from their issuing threads having died. The default is 500ms, and this is only relevant if you plan on concurrently issuing queries on a single connection, and even then only if you expect your threads to be killed by asynchronous exceptions frequently enough, and you want resume using the connection and cannot wait ~500ms until Hpgsql realizes it's fine to do so. You probably don't need to worry about this or tune it.

  • cancellationRequestResendIntervalMs :: Int

    How long in ms Hpgsql will wait before re-sending a cancellation request while draining orphaned queries (queries from dead threads). The default is 500ms, and this is only relevant if you plan on interrupting your queries with asynchronous exceptions, either by use of concurrency primitives or functions like timeout, and continue using the connection for new queries after that. It is not recommend setting this below 100ms, because orphaned query draining alternates with resending cancellation requests, so if this is too low it is possible that draining never finishes, leading to a form of livelock.

  • fillTypeInfoCache :: Bool

    Immediately after connecting, run a query to fetch all types from the pg_type table. This makes them available in FromPgField instances. The default is True. You should only set it to False if you really know what you're doing, because class instances of custom types can stop working.

data PostgresError Source #

An error coming from PostgreSQL. You can safely handle this and continue using the connection.

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.

data ResetConnectionOpts Source #

Constructors

ResetConnectionOpts 

Fields

  • resetAll :: Bool

    Runs `RESET ALL` and `RESET ROLE` on the connection. Defaults to True.

  • unlistenAll :: Bool

    Runs `UNLISTEN *` on the connection and clears the internal queue of notifications. Defaults to True.

  • checkTransactionState :: Bool

    Throws an exception if there is an open transaction or if there's a transaction in error state. Defaults to True.

data TransactionStatus Source #

Constructors

TransActive

A command is in progress

TransIdle

Not inside a transaction

TransInTrans

Inside a transaction, but no command running

TransInError 

newtype EncodingContext Source #

Constructors

EncodingContext 

Fields

  • typeInfoCache :: TypeInfoCache

    A map with all builtin PostgreSQL types plus user-defined types, unless you specify custom connection options.

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

data Query Source #

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.

Instances

Instances details
Semigroup Query Source # 
Instance details

Defined in Hpgsql.InternalTypes

Methods

(<>) :: Query -> Query -> Query #

sconcat :: NonEmpty Query -> Query #

stimes :: Integral b => b -> Query -> Query #

IsString Query Source # 
Instance details

Defined in Hpgsql.InternalTypes

Methods

fromString :: String -> Query #

Show Query Source # 
Instance details

Defined in Hpgsql.InternalTypes

Methods

showsPrec :: Int -> Query -> ShowS #

show :: Query -> String #

showList :: [Query] -> ShowS #

data SingleQuery Source #

A single statement, not multiple, with dollar-numbered query arguments starting from $1.

Instances

Instances details
Show SingleQuery Source # 
Instance details

Defined in Hpgsql.InternalTypes

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

Instances details
Show ParseComplete Source # 
Instance details

Defined in Hpgsql.InternalTypes

data BindComplete Source #

Constructors

BindComplete 

Instances

Instances details
Show BindComplete Source # 
Instance details

Defined in Hpgsql.InternalTypes

data NoData Source #

Constructors

NoData 

Instances

Instances details
Show NoData Source # 
Instance details

Defined in Hpgsql.InternalTypes

newtype RowDescription Source #

Column names and type OIDs.

Constructors

RowDescription 

Fields

Instances

Instances details
Show RowDescription Source # 
Instance details

Defined in Hpgsql.InternalTypes

data CopyInResponse Source #

Constructors

CopyInResponse 

Instances

Instances details
Show CopyInResponse Source # 
Instance details

Defined in Hpgsql.InternalTypes

newtype ErrorResponse Source #

Instances

Instances details
Show ErrorResponse Source # 
Instance details

Defined in Hpgsql.InternalTypes

newtype CommandComplete Source #

Constructors

CommandComplete 

Fields

Instances

Instances details
Show CommandComplete Source # 
Instance details

Defined in Hpgsql.InternalTypes

newtype DataRow Source #

Constructors

DataRow 

Instances

Instances details
Show DataRow Source # 
Instance details

Defined in Hpgsql.InternalTypes

newtype ReadyForQuery Source #

Instances

Instances details
Show ReadyForQuery Source # 
Instance details

Defined in Hpgsql.InternalTypes

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

Instances details
Show WeakThreadId Source # 
Instance details

Defined in Hpgsql.InternalTypes

Eq WeakThreadId Source # 
Instance details

Defined in Hpgsql.InternalTypes

data QueryState Source #

Constructors

QueryState 

Fields

Instances

Instances details
Show QueryState Source # 
Instance details

Defined in Hpgsql.InternalTypes

newtype QueryId Source #

An Integer avoids any headaches from wrap-around when comparing query ids. An Int64 should be fine, but the cost of this is negligible.

Constructors

QueryId Integer 

data Either3 a b c Source #

Constructors

Left3 !a 
Middle3 !b 
Right3 !c 

Instances

Instances details
(Show a, Show b, Show c) => Show (Either3 a b c) Source # 
Instance details

Defined in Hpgsql.InternalTypes

Methods

showsPrec :: Int -> Either3 a b c -> ShowS #

show :: Either3 a b c -> String #

showList :: [Either3 a b c] -> ShowS #

Connection and Pipeline types

newtype Mutex Source #

A reentrant mutex, i.e. one that can be re-acquired by the same thread without deadlocking.

Constructors

Mutex (TVar (Maybe (WeakThreadId, Int))) 

data Pipeline a Source #

Constructors

Pipeline [(SingleQuery, Maybe Int)] (HPgConnection -> [QueryId] -> a) 

Instances

Instances details
Applicative Pipeline Source # 
Instance details

Defined in Hpgsql.InternalTypes

Methods

pure :: a -> Pipeline a #

(<*>) :: Pipeline (a -> b) -> Pipeline a -> Pipeline b #

liftA2 :: (a -> b -> c) -> Pipeline a -> Pipeline b -> Pipeline c #

(*>) :: Pipeline a -> Pipeline b -> Pipeline b #

(<*) :: Pipeline a -> Pipeline b -> Pipeline a #

Functor Pipeline Source # 
Instance details

Defined in Hpgsql.InternalTypes

Methods

fmap :: (a -> b) -> Pipeline a -> Pipeline b #

(<$) :: a -> Pipeline b -> Pipeline a #