hpqtypes-1.10.0.1: Haskell bindings to libpqtypes
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

Note: PGconn is not managed with a ForeignPtr because finalizers are broken and at program exit might run even though another thread is inside the relevant withForeignPtr block, executing a safe FFI call (in this case executing an SQL query).

See https://gitlab.haskell.org/ghc/ghc/-/issues/10975 for more info.

Constructors

ConnectionData 

Fields

data ConnectionStats Source #

Simple connection statistics.

Constructors

ConnectionStats 

Fields

defaultConnectionSettings :: ConnectionSettings Source #

Default connection settings. Note that all strings sent to PostgreSQL by the library are encoded as UTF-8, so don't alter client encoding unless you know what you're doing.

newtype ConnectionSourceM m Source #

Database connection supplier.

Constructors

ConnectionSourceM 

Fields

newtype ConnectionSource (cs :: [(Type -> Type) -> Constraint]) Source #

Wrapper for a polymorphic connection source.

Constructors

ConnectionSource 

Fields

simpleSource :: ConnectionSettings -> ConnectionSource [MonadBase IO, MonadMask] Source #

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

poolSource Source #

Arguments

:: ConnectionSettings 
-> Double

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

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

-> Int

The maximum number of database connections to keep open.

Note: for each stripe the number of resources is divided by the number of capabilities and rounded up. Therefore the pool might end up creating up to N - 1 resources more in total than specified, where N is the number of capabilities.

-> IO (ConnectionSource [MonadBase IO, MonadMask]) 

Pooled source. It uses striped pool from resource-pool package to cache established 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.

Warning: the Connection needs to be explicitly destroyed with disconnect, otherwise there will be a resource leak.

disconnect :: Connection -> IO () Source #

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