@@ -91,9 +91,11 @@ module Database.PostgreSQL.Simple
91 , defaultTransactionMode
91 , defaultTransactionMode
92 , defaultIsolationLevel
92 , defaultIsolationLevel
93 , defaultReadWriteMode
93 , defaultReadWriteMode
94+ , withTransactionLevel
94 , withTransactionMode
95 , withTransactionMode
95-- , Base.autocommit
96-- , Base.autocommit
97 , beginMode
99 , beginMode
99 , rollback
101 , rollback
@@ -524,6 +526,11 @@ withTransaction :: Connection -> IO a -> IO a
524withTransaction = withTransactionMode defaultTransactionMode
526withTransaction = withTransactionMode defaultTransactionMode
526-- | Execute an action inside a SQL transaction with a given isolation level.
528-- | Execute an action inside a SQL transaction with a given isolation level.
529+withTransactionLevel :: IsolationLevel -> Connection -> IO a -> IO a
530+withTransactionLevel lvl
531+ = withTransactionMode defaultTransactionMode { isolationLevel = lvl }
533+-- | Execute an action inside a SQL transaction with a given transaction mode.
527withTransactionMode :: TransactionMode -> Connection -> IO a -> IO a
534withTransactionMode :: TransactionMode -> Connection -> IO a -> IO a
528withTransactionMode mode conn act = do
535withTransactionMode mode conn act = do
529 beginMode mode conn
536 beginMode mode conn
@@ -544,6 +551,10 @@ begin :: Connection -> IO ()
544begin = beginMode defaultTransactionMode
551begin = beginMode defaultTransactionMode
546-- | Begin a transaction with a given isolation level
553-- | Begin a transaction with a given isolation level
554+beginLevel :: IsolationLevel -> Connection -> IO ()
555+beginLevel lvl = beginMode defaultTransactionMode { isolationLevel = lvl }
557+-- | Begin a transaction with a given transaction mode
547beginMode :: TransactionMode -> Connection -> IO ()
558beginMode :: TransactionMode -> Connection -> IO ()
548beginMode mode conn = do
559beginMode mode conn = do
549 execute_ conn $! case mode of
560 execute_ conn $! case mode of