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

Database.PostgreSQL.PQTypes.Class

Contents

Synopsis

Class

class (Applicative m, Monad m) => MonadDB m where Source #

Methods

runQuery :: (HasCallStack, IsSQL sql) => sql -> m Int Source #

Run SQL query and return number of affected/returned rows. Note that for a given connection, only one thread may be executing runQuery at a given time. If simultaneous call is made from another thread, it will block until currently running runQuery finishes.

runPreparedQuery :: (HasCallStack, IsSQL sql) => QueryName -> sql -> m Int Source #

Similar to runQuery, but it prepares and executes a statement under a given name.

getLastQuery :: m SomeSQL Source #

Get last SQL query that was executed.

withFrozenLastQuery :: m a -> m a Source #

Subsequent queries in the callback do not alter the result of getLastQuery.

getBackendPid :: m BackendPid Source #

Get ID of the server process attached to the current session.

getConnectionStats :: HasCallStack => m ConnectionStats Source #

Get current connection statistics.

getQueryResult :: FromRow row => m (Maybe (QueryResult row)) Source #

Get current query result.

clearQueryResult :: m () Source #

Clear current query result.

getTransactionSettings :: m TransactionSettings Source #

Get current transaction settings.

setTransactionSettings :: TransactionSettings -> m () Source #

Set transaction settings to supplied ones. Note that it won't change any properties of currently running transaction, only the subsequent ones.

getNotification :: Int -> m (Maybe Notification) Source #

Attempt to receive a notification from the server. This function waits until a notification arrives or specified number of microseconds has passed. If a negative number of microseconds is passed as an argument, it will wait indefinitely. In addition, there are a couple of things to be aware of:

  • A lock on the underlying database connection is acquired for the duration of the function.
  • Notifications can be received only between transactions (see http://www.postgresql.org/docs/current/static/sql-notify.html for further info), therefore calling this function within a transaction block will return Just only if notifications were received before the transaction began.

withNewConnection :: m a -> m a Source #

Execute supplied monadic action with new connection using current connection source and transaction settings.

Particularly useful when you want to spawn a new thread, but do not want the connection in child thread to be shared with the parent one.

Instances

Instances details
(Applicative (t m), Monad (t m), MonadTrans t, MonadTransControl t, MonadDB m) => MonadDB (t m) Source #

Generic, overlappable instance.

Instance details

Defined in Database.PostgreSQL.PQTypes.Class

(m ~ n, MonadBase IO m, MonadMask m) => MonadDB (DBT_ m n) Source # 
Instance details

Defined in Database.PostgreSQL.PQTypes.Internal.Monad

Misc

newtype BackendPid Source #

Process ID of the server process attached to the current session.

Constructors

BackendPid Int