hpgsql
Safe HaskellNone
LanguageHaskell2010

Hpgsql.Connection

Synopsis

Documentation

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.

parseLibpqConnectionString :: Text -> Either String ConnectionString Source #

Parses a libpq compatible connection string.

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.

resetConnectionState Source #

Arguments

:: HPgConnection 
-> Maybe ResetConnectionOpts

Pass Nothing to use defaults.

-> 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.