hpqtypes-1.4.3: Haskell bindings to libpqtypes

Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.PQTypes.Internal.Connection

Synopsis

Documentation

newtype Connection Source

Wrapper for hiding representation of a connection object.

Constructors

Connection 

data ConnectionData Source

Representation of a connection object.

Constructors

ConnectionData 

Fields

cdFrgnPtr :: !(ForeignPtr (Ptr PGconn))

Foreign pointer to pointer to connection object.

cdPtr :: !(Ptr PGconn)

Pointer to connection object (the same as in cdFrgnPtr).

cdStats :: !ConnectionStats

Statistics associated with the connection.

data ConnectionStats Source

Simple connection statistics.

Constructors

ConnectionStats 

Fields

statsQueries :: !Int

Number of queries executed so far.

statsRows :: !Int

Number of rows fetched from the database.

statsValues :: !Int

Number of values fetched from the database.

statsParams :: !Int

Number of parameters sent to the database.

data ConnectionSettings Source

Constructors

ConnectionSettings 

Fields

csConnInfo :: !ByteString

Connection info string.

csClientEncoding :: !(Maybe ByteString)

Client-side encoding. If set to Nothing, database encoding is used.

csComposites :: ![ByteString]

A list of composite types to register. In order to be able to (de)serialize specific composite types, you need to register them.

def :: Default a => a

The default value for this type.

newtype ConnectionSource Source

Database connection supplier.

Constructors

ConnectionSource 

Fields

withConnection :: (MonadBase IO m, MonadMask m) => (Connection -> m a) -> m a
 

simpleSource :: ConnectionSettings -> ConnectionSource Source

Default connection supplier. It estabilishes new database connection each time withConnection is called.

poolSource Source

Arguments

:: ConnectionSettings 
-> Int

Stripe count. The number of distinct sub-pools to maintain. The smallest acceptable value is 1.

-> NominalDiffTime

Amount of time for which an unused database connection is kept open. The smallest acceptable value is 0.5 seconds.

The elapsed time before closing database connection may be a little longer than requested, as the reaper thread wakes at 1-second intervals.

-> Int

Maximum number of database connections to keep open per stripe. The smallest acceptable value is 1.

Requests for database connections will block if this limit is reached on a single stripe, even if other stripes have idle connections available.

-> IO ConnectionSource 

Pooled source. It uses striped pool from resource-pool package to cache estabilished connections and reuse them.

connect :: ConnectionSettings -> IO Connection Source

Low-level function for connecting to the database. Useful if one wants to implement custom connection source.

disconnect :: Connection -> IO () Source

Low-level function for disconnecting from the database. Useful if one wants to implement custom connection source.