Skip to content

Commit 23bfb89

Browse files
authored
Make functions altering transaction state lenient in on demand mode (#83)
The database is read only anyway in the on demand mode, so it's alright.
1 parent 8995d02 commit 23bfb89

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# hpqtypes-1.14.0.0 (2025-??-??)
2+
* Make `begin`, `commit` and `rollback` do nothing instead of throwing an error
3+
if the on demand connection acquisition mode is active.
4+
15
# hpqtypes-1.13.0.1 (2025-11-27)
26
* Fix a bug in `initConnectionState` and `finalizeConnectionState` that could
37
lead to leaking connections.

hpqtypes.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22
build-type: Simple
33
name: hpqtypes
4-
version: 1.13.0.1
4+
version: 1.14.0.0
55
synopsis: Haskell bindings to libpqtypes
66

77
description: Efficient and easy-to-use bindings to (slightly modified)

src/Database/PostgreSQL/PQTypes/Transaction.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ withSavepoint (Savepoint savepoint) m =
5656
begin :: (HasCallStack, MonadDB m, MonadMask m) => m ()
5757
begin = do
5858
getConnectionAcquisitionMode >>= \case
59-
AcquireOnDemand -> do
60-
throwDB $ HPQTypesError "Can't begin a transaction in OnDemand mode"
59+
AcquireOnDemand -> pure ()
6160
AcquireAndHold isolationLevel permissions -> uninterruptibleMask_ $ do
6261
runSQL_ $
6362
smconcat
@@ -77,8 +76,7 @@ begin = do
7776
commit :: (HasCallStack, MonadDB m, MonadMask m) => m ()
7877
commit = do
7978
getConnectionAcquisitionMode >>= \case
80-
AcquireOnDemand -> do
81-
throwDB $ HPQTypesError "Can't commit a transaction in OnDemand mode"
79+
AcquireOnDemand -> pure ()
8280
AcquireAndHold {} -> uninterruptibleMask_ $ do
8381
runSQL_ "COMMIT"
8482
begin
@@ -87,8 +85,7 @@ commit = do
8785
rollback :: (HasCallStack, MonadDB m, MonadMask m) => m ()
8886
rollback = do
8987
getConnectionAcquisitionMode >>= \case
90-
AcquireOnDemand -> do
91-
throwDB $ HPQTypesError "Can't rollback a transaction in OnDemand mode"
88+
AcquireOnDemand -> pure ()
9289
AcquireAndHold {} -> uninterruptibleMask_ $ do
9390
runSQL_ "ROLLBACK"
9491
begin

0 commit comments

Comments
 (0)