Merge pull request #55 from cocreature/libpq-access

Expose access to raw libpq connection
This commit is contained in:
Nikita Volkov 2016-07-23 15:40:12 +03:00 committed by GitHub
commit 4542b52282
2 changed files with 7 additions and 0 deletions

View File

@ -8,6 +8,7 @@ module Hasql.Connection
release,
Settings,
settings,
withLibPQConnection
)
where

View File

@ -42,3 +42,9 @@ release (Connection pqConnectionRef _ _) =
nullConnection <- LibPQ.newNullConnection
pqConnection <- swapMVar pqConnectionRef nullConnection
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