HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulepostgresql-simple-0.7.0.0Haskell2010

Database.PostgreSQL.Simple.Transaction

  • 4 types
  • 22 values

Transaction handling

17 declarations
valuewithTransaction :: Connection -> IO a -> IO a
#

Execute an action inside a SQL transaction.

This function initiates a transaction with a "begin transaction" statement, then executes the supplied action. If the action succeeds, the transaction will be completed with Base.commit before this function returns.

If the action throws any kind of exception (not just a PostgreSQL-related exception), the transaction will be rolled back using rollback, then the exception will be rethrown.

For nesting transactions, see withSavepoint.

Execute an action inside of a Serializable transaction. If a serialization failure occurs, roll back the transaction and try again. Be warned that this may execute the IO action multiple times.

A Serializable transaction creates the illusion that your program has exclusive access to the database. This means that, even in a concurrent setting, you can perform queries in sequence without having to worry about what might happen between one statement and the next.

Think of it as STM, but without retry.

datadata IsolationLevel
#

Of the four isolation levels defined by the SQL standard, these are the three levels distinguished by PostgreSQL as of version 9.0. See https://www.postgresql.org/docs/9.5/static/transaction-iso.html for more information. Note that prior to PostgreSQL 9.0, RepeatableRead was equivalent to Serializable.

Constructors

Instances5Bounded, Enum, Eq, Ord, Show
  • Bounded IsolationLevelDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Enum IsolationLevelDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Eq IsolationLevelDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Ord IsolationLevelDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Show IsolationLevelDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
datadata ReadWriteMode
#

Constructors

  • DefaultReadWriteMode

    the read-write mode will be taken from PostgreSQL's per-connection default_transaction_read_only variable, which is initialized according to the server's config. The default configuration is ReadWrite.

  • ReadWrite
  • ReadOnly
Instances5Bounded, Enum, Eq, Ord, Show
  • Bounded ReadWriteModeDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Enum ReadWriteModeDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Eq ReadWriteModeDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Ord ReadWriteModeDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction
  • Show ReadWriteModeDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Transaction

Savepoint

6 declarations
newtypenewtype Savepoint
#
Instances4Eq, Ord, Read, Show
  • Eq SavepointDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Types
  • Ord SavepointDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Types
  • Read SavepointDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Types
  • Show SavepointDefined in postgresql-simple-0.7.0.0 · Database.PostgreSQL.Simple.Types

Error predicates

3 declarations