mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-28 04:57:14 +03:00
Merge pull request #55 from cocreature/libpq-access
Expose access to raw libpq connection
This commit is contained in:
commit
4542b52282
@ -8,6 +8,7 @@ module Hasql.Connection
|
|||||||
release,
|
release,
|
||||||
Settings,
|
Settings,
|
||||||
settings,
|
settings,
|
||||||
|
withLibPQConnection
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -42,3 +42,9 @@ release (Connection pqConnectionRef _ _) =
|
|||||||
nullConnection <- LibPQ.newNullConnection
|
nullConnection <- LibPQ.newNullConnection
|
||||||
pqConnection <- swapMVar pqConnectionRef nullConnection
|
pqConnection <- swapMVar pqConnectionRef nullConnection
|
||||||
IO.releaseConnection pqConnection
|
IO.releaseConnection pqConnection
|
||||||
|
|
||||||
|
-- | Execute an operation on the raw @libpq@ 'LibPQ.Connection'.
|
||||||
|
--
|
||||||
|
-- The access to the connection is exclusive.
|
||||||
|
withLibPQConnection :: Connection -> (LibPQ.Connection -> IO a) -> IO a
|
||||||
|
withLibPQConnection (Connection pqConnectionRef _ _) = withMVar pqConnectionRef
|
||||||
|
Loading…
Reference in New Issue
Block a user