packages feed

hasql 1.8.1 → 1.8.1.1

raw patch · 4 files changed

+28/−14 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.8.1++- In case of exceptions thrown by user from inside of Session, the connection status gets checked to be out of transaction and unless it is the connection gets reset.+ # 1.8  - Move to "iproute" from "network-ip" for the "inet" datatype (#163).
hasql.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: hasql-version: 1.8.1+version: 1.8.1.1 category: Hasql, Database, PostgreSQL synopsis: Fast PostgreSQL driver with a flexible mapping API description:
library/Hasql/PreparedStatementRegistry.hs view
@@ -2,6 +2,7 @@   ( PreparedStatementRegistry,     new,     update,+    reset,     LocalKey (..),   ) where@@ -9,7 +10,7 @@ import ByteString.StrictBuilder qualified as B import Data.HashTable.IO qualified as A import Hasql.LibPq14 qualified as Pq-import Hasql.Prelude hiding (lookup)+import Hasql.Prelude hiding (lookup, reset)  data PreparedStatementRegistry   = PreparedStatementRegistry !(A.BasicHashTable LocalKey ByteString) !(IORef Word)@@ -41,6 +42,15 @@               B.builderBytes . B.asciiIntegral $ n     old =       onOldRemoteKey++reset :: PreparedStatementRegistry -> IO ()+reset (PreparedStatementRegistry table counter) = do+  -- TODO: This is a temporary measure.+  -- We should just move to a pure implementation.+  do+    entries <- A.toList table+    forM_ entries \(k, _) -> A.delete table k+  writeIORef counter 0  -- | -- Local statement key.
library/Hasql/Session/Core.hs view
@@ -11,6 +11,7 @@ import Hasql.LibPq14 qualified as Pq import Hasql.Pipeline.Core qualified as Pipeline import Hasql.Prelude+import Hasql.PreparedStatementRegistry qualified as PreparedStatementRegistry import Hasql.Statement qualified as Statement  -- |@@ -23,20 +24,19 @@ -- Executes a bunch of commands on the provided connection. run :: Session a -> Connection.Connection -> IO (Either SessionError a) run (Session impl) connection =-  handle @SomeException onExc-    $ runExceptT-    $ runReaderT impl connection+  mask $ \restore -> onException (restore main) handler   where-    onExc exc =+    main =+      runExceptT $ runReaderT impl connection+    handler =       case connection of-        Connection.Connection pqConnVar _ _ ->-          withMVar pqConnVar onPqConn-      where-        onPqConn pqConn = do-          Pq.transactionStatus pqConn >>= \case-            Pq.TransIdle -> pure ()-            _ -> Pq.reset pqConn-          throwIO exc+        Connection.Connection pqConnVar _ registry ->+          withMVar pqConnVar \pqConn ->+            Pq.transactionStatus pqConn >>= \case+              Pq.TransIdle -> pure ()+              _ -> do+                PreparedStatementRegistry.reset registry+                Pq.reset pqConn  -- | -- Possibly a multi-statement query,