-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Another postgresql-simple transaction monad
--   
--   Another postgresql-simple transaction monad
@package pg-transact
@version 0.1.0.1

module Database.PostgreSQL.Transact
newtype DBT m a
DBT :: ReaderT Connection m a -> DBT m a
[unDBT] :: DBT m a -> ReaderT Connection m a
type DB = DBT IO
isClass25 :: SqlError -> Bool
getConnection :: Monad m => DBT m Connection
runDBT :: MonadBaseControl IO m => DBT m a -> IsolationLevel -> Connection -> m a
runDBTSerializable :: MonadBaseControl IO m => DBT m a -> Connection -> m a

-- | Perform a <tt>SELECT</tt> or other SQL query that is expected to
--   return results. All results are retrieved and converted before this
--   function returns.
--   
--   When processing large results, this function will consume a lot of
--   client-side memory. Consider using <a>fold</a> instead.
--   
--   Exceptions that may be thrown:
--   
--   <ul>
--   <li><a>FormatError</a>: the query string could not be formatted
--   correctly.</li>
--   <li><a>QueryError</a>: the result contains no columns (i.e. you should
--   be using <a>execute</a> instead of <a>query</a>).</li>
--   <li><a>ResultError</a>: result conversion failed.</li>
--   <li><a>SqlError</a>: the postgresql backend returned an error, e.g. a
--   syntax or type error, or an incorrect table or column name.</li>
--   </ul>
query :: (ToRow a, FromRow b, MonadIO m) => Query -> a -> DBT m [b]

-- | A version of <a>query</a> that does not perform query substitution.
query_ :: (FromRow b, MonadIO m) => Query -> DBT m [b]

-- | Execute an <tt>INSERT</tt>, <tt>UPDATE</tt>, or other SQL query that
--   is not expected to return results.
--   
--   Returns the number of rows affected.
--   
--   Throws <a>FormatError</a> if the query could not be formatted
--   correctly, or a <a>SqlError</a> exception if the backend returns an
--   error.
execute :: (ToRow q, MonadIO m) => Query -> q -> DBT m Int64

-- | A version of execute that does not perform query substitution.
execute_ :: MonadIO m => Query -> DBT m Int64

-- | Execute a multi-row <tt>INSERT</tt>, <tt>UPDATE</tt>, or other SQL
--   query that is not expected to return results.
--   
--   Returns the number of rows affected. If the list of parameters is
--   empty, this function will simply return 0 without issuing the query to
--   the backend. If this is not desired, consider using the
--   <tt>Values</tt> constructor instead.
--   
--   Throws <a>FormatError</a> if the query could not be formatted
--   correctly, or a <a>SqlError</a> exception if the backend returns an
--   error.
--   
--   For example, here's a command that inserts two rows into a table with
--   two columns:
--   
--   <pre>
--   executeMany [sql|
--       INSERT INTO sometable VALUES (?,?)
--    |] [(1, "hello"),(2, "world")]
--   </pre>
--   
--   Here's an canonical example of a multi-row update command:
--   
--   <pre>
--   executeMany [sql|
--       UPDATE sometable
--          SET sometable.y = upd.y
--         FROM (VALUES (?,?)) as upd(x,y)
--        WHERE sometable.x = upd.x
--    |] [(1, "hello"),(2, "world")]
--   </pre>
executeMany :: (ToRow q, MonadIO m) => Query -> [q] -> DBT m Int64

-- | Execute <tt>INSERT ... RETURNING</tt>, <tt>UPDATE ... RETURNING</tt>,
--   or other SQL query that accepts multi-row input and is expected to
--   return results. Note that it is possible to write <tt><a>query</a>
--   conn "INSERT ... RETURNING ..." ...</tt> in cases where you are only
--   inserting a single row, and do not need functionality analogous to
--   <a>executeMany</a>.
--   
--   If the list of parameters is empty, this function will simply return
--   <tt>[]</tt> without issuing the query to the backend. If this is not
--   desired, consider using the <tt>Values</tt> constructor instead.
--   
--   Throws <a>FormatError</a> if the query could not be formatted
--   correctly.
returning :: (ToRow q, FromRow r, MonadIO m) => Query -> [q] -> DBT m [r]
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Database.PostgreSQL.Transact.DBT m)
instance Control.Monad.Trans.Class.MonadTrans Database.PostgreSQL.Transact.DBT
instance GHC.Base.Functor m => GHC.Base.Functor (Database.PostgreSQL.Transact.DBT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Database.PostgreSQL.Transact.DBT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Database.PostgreSQL.Transact.DBT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Database.PostgreSQL.Transact.DBT m)
instance (Control.Monad.IO.Class.MonadIO m, Control.Monad.Catch.MonadMask m) => Control.Monad.Catch.MonadCatch (Database.PostgreSQL.Transact.DBT m)
