| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hpgsql.Connection
Synopsis
- connect :: ConnectionString -> DiffTime -> IO HPgConnection
- connectOpts :: ConnectOpts -> ConnectionString -> DiffTime -> IO HPgConnection
- defaultConnectOpts :: ConnectOpts
- withConnection :: ConnectionString -> DiffTime -> (HPgConnection -> IO a) -> IO a
- withConnectionOpts :: ConnectOpts -> ConnectionString -> DiffTime -> (HPgConnection -> IO a) -> IO a
- closeGracefully :: HPgConnection -> IO ()
- closeForcefully :: HPgConnection -> IO ()
- data ConnectionString = ConnectionString {}
- parseLibpqConnectionString :: Text -> Either String ConnectionString
- data ResetConnectionOpts = ResetConnectionOpts {}
- resetConnectionState :: HPgConnection -> Maybe ResetConnectionOpts -> IO ()
- renderLibpqConnectionString :: ConnectionString -> ByteString
- refreshTypeInfoCache :: HPgConnection -> Pipeline (IO ())
- resetTypeInfoCache :: HPgConnection -> IO ()
- getParameterStatus :: HPgConnection -> Text -> IO (Maybe Text)
- getBackendPid :: HPgConnection -> Int32
Documentation
connect :: ConnectionString -> DiffTime -> IO HPgConnection Source #
connectOpts :: ConnectOpts -> ConnectionString -> DiffTime -> IO HPgConnection Source #
withConnection :: ConnectionString -> DiffTime -> (HPgConnection -> IO a) -> IO a Source #
withConnectionOpts :: ConnectOpts -> ConnectionString -> DiffTime -> (HPgConnection -> IO a) -> IO a Source #
closeGracefully :: HPgConnection -> IO () Source #
Closes the connection with postgres. Do not use this in exception handlers; use closeForcefully
instead.
closeForcefully :: HPgConnection -> IO () Source #
Closes the connection with postgres as quickly as possible without the proper postgres protocol handshake procedures. This is equivalent to closing the connection's socket in the kernel without making postgres aware of it. Use this if you need to close the connection in exception handlers or if you received an irrecoverable Hpgsql exception.
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 # | |
parseLibpqConnectionString :: Text -> Either String ConnectionString Source #
Parses a libpq compatible connection string.
data ResetConnectionOpts Source #
Constructors
| ResetConnectionOpts | |
Fields
| |
Arguments
| :: HPgConnection | |
| -> Maybe ResetConnectionOpts | Pass |
| -> IO () |
Resets many forms of connection state in an attempt to make it
as similar as possible to a newly opened connection. It can be useful to
run this before e.g. putting a connection back into a connection pool.
Check ResetConnectionOpts for more details.
renderLibpqConnectionString :: ConnectionString -> ByteString Source #
Renders a libpq compatible connection string.
refreshTypeInfoCache :: HPgConnection -> Pipeline (IO ()) Source #
Fetches custom types from postgres and refreshes this connection's
internal typeInfo cache with them.
Note that builtin postgres types are always available in the typeInfo cache;
this just refreshes any other custom types, including removing those that
no longer exist and adding new ones.
Hpgsql runs this automatically for new connections unless you disable it.
This is a Pipeline so you can batch it with other commands for reduced latency.
See ConnectOpts and resetTypeInfoCache for more.
resetTypeInfoCache :: HPgConnection -> IO () Source #
Useful to reset the connection's internal typeInfo cache to the builtin postgres types.
getParameterStatus :: HPgConnection -> Text -> IO (Maybe Text) Source #
getBackendPid :: HPgConnection -> Int32 Source #