git.iko.soy/typeable/postgresql-simple
on master help sign in
Add isSerializationError predicate to Transaction
commit14d7a3b614f4435a6714dacbee5f0294061f6b02 authorLeon P Smith <leon@melding-monads.com> dateMon 25 Mar 2013, 16:23 (14 years ago) parent4b60ad7
1 file changed+7−3
src/Database/PostgreSQL/Simple/Transaction.hs+7−3
src/Database/PostgreSQL/Simple/Transaction.hs+7−3
@@ -8,6 +8,7 @@ module Database.PostgreSQL.Simple.Transaction
88 , withTransactionMode
99 , withTransactionModeRetry
1010 , withTransactionSerializable
11+ , isSerializationError
1112 , TransactionMode(..)
1213 , IsolationLevel(..)
1314 , ReadWriteMode(..)
@@ -104,13 +105,16 @@ withTransactionSerializable =
104105 { isolationLevel = Serializable
105106 , readWriteMode = ReadWrite
106107 }
107− retryOnNotSerializable
108− where
109− retryOnNotSerializable exception =
108+ isSerializationError
109+
110+
111+isSerializationError :: SqlError -> Bool
112+isSerializationError exception =
110113 case exception of
111114 SqlError{..} | sqlState == serialization_failure
112115 -> True
113116 _ -> False
117+ where
114118 -- http://www.postgresql.org/docs/current/static/errcodes-appendix.html
115119 serialization_failure = "40001"
116120