Permalink
Browse files

Add isSerializationError predicate to Transaction

  • Loading branch information...
1 parent 4b60ad7 commit 14d7a3b614f4435a6714dacbee5f0294061f6b02 @lpsmith committed Mar 25, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/Database/PostgreSQL/Simple/Transaction.hs
@@ -8,6 +8,7 @@ module Database.PostgreSQL.Simple.Transaction
, withTransactionMode
, withTransactionModeRetry
, withTransactionSerializable
+ , isSerializationError
, TransactionMode(..)
, IsolationLevel(..)
, ReadWriteMode(..)
@@ -104,13 +105,16 @@ withTransactionSerializable =
{ isolationLevel = Serializable
, readWriteMode = ReadWrite
}
- retryOnNotSerializable
- where
- retryOnNotSerializable exception =
+ isSerializationError
+
+
+isSerializationError :: SqlError -> Bool
+isSerializationError exception =
case exception of
SqlError{..} | sqlState == serialization_failure
-> True
_ -> False
+ where
-- http://www.postgresql.org/docs/current/static/errcodes-appendix.html
serialization_failure = "40001"

0 comments on commit 14d7a3b

Please sign in to comment.