Efficient and easy-to-use bindings to (slightly modified) libpqtypes,
libpq extension that adds support for binary transport format and
composite types.
Source code of libpqtypes is bundled along with the bindings.
The thread that starts a DB session now owns it. If another thread uses the
session, the library throws ThreadMismatchError wrapped in DBException.
Previously, threads shared the session, including its connection and its
transaction. This change affects all threads that get the session from a
fork, e.g. the threads of race and concurrently from lifted-async. To
run queries in another thread, call withNewSession in that thread.
Rename withNewConnection to withNewSession, because the new session does
not always acquire a connection immediately. Replace each use of
withNewConnection with withNewSession.
Fix two bugs of withNewSession (withNewConnection in earlier versions)
in a forked thread. If the parent session ended first, the function failed
with the error finalized connection. While the parent session ran a query,
the function waited for the query to finish.
Fix a use-after-free of the buffer that holds the connection string in
connect. If an asynchronous exception interrupted connect, the
use-after-free was possible.
Execution of a COPY statement now throws an error that says the statement
is not supported. Previously the library silently reported success and left
the connection in copy mode until the next query.
Fix transaction restart handling. A restarted transaction no longer runs
with asynchronous exceptions masked. An asynchronous exception, e.g. a
timeout, no longer triggers a restart. A restart predicate that matches
it makes no difference. If a transaction fails, a subsequent failure of
its cleanup no longer masks the original exception. Previously this hid
the exception from the restart predicate.
Fix a bug in the on demand connection acquisition mode. If a query left
the connection in a state that admits no further queries, e.g. because the
connection died, the ROLLBACK that ended the automatic transaction of the
query failed. Its failure masked the exception thrown from the query.
Fix a bug in withSavepoint. If the action threw and the cleanup of the
savepoint failed as well, e.g. because the connection died, the failure of
the cleanup masked the exception of the action.
Fix a bug in unsafeWithoutTransaction. If the action threw and the BEGIN
that restores the transaction failed as well, e.g. because the connection
died, the failure of the BEGIN masked the exception of the action.
Row fetching functions no longer decode all rows of the result up front
and retain them until the fold completes. They decode each row right
before the fold function consumes it. As a result, e.g. mapDB_ over a
large result runs in constant additional memory.
Add FromSQL and ToSQL instances for Word16, Word32 and Word64.
Add FromSQL and ToSQL instances for Integer, mapped to numeric.
JSON and JSONB now serialize and deserialize the wrapped type with its
ToJSON and FromJSON instances. They work for any such type and support
deriving via, e.g. deriving (PQFormat, ToSQL, FromSQL) via JSONB Config.
The aesonFromSQL and aesonToSQL helpers are gone. The instances for
unparsed JSON text moved to the dedicated RawJSON and RawJSONB types,
which wrap a strict ByteString. The instances for lazy ByteString are
gone. The encodeRawJSON and encodeRawJSONB functions build these types
from any type with a ToJSON instance. The decodeRawJSON and
decodeRawJSONB functions convert back and return Nothing on a failure.
The eitherDecodeRawJSON and eitherDecodeRawJSONB functions return the
reason for the failure instead.
Fix a bug in changeAcquisitionModeTo. If the commit of a transaction
failed during the transition from the AcquireAndHold to the
AcquireOnDemand mode, the library held on to an invalid connection
object.
Fix a bug in withCursor. If the enclosing transaction was in the aborted
state, the failure of the cursor cleanup masked an exception thrown from
the continuation. In particular, this prevented restarts of transactions
run with a RestartPredicate.
Fix a bug in commit, rollback and unsafeWithoutTransaction. If the
issued COMMIT failed, e.g. because of a deferred constraint violation,
the session stayed in the autocommit mode instead of starting a new
transaction.
Fix a bug in withCursor where an asynchronous exception cancelled the
CLOSE query and left the cursor open.
Fix a bug in withSavepoint where an asynchronous exception cancelled the
ROLLBACK TO SAVEPOINT or RELEASE SAVEPOINT query. The savepoint stayed in
place, or the transaction stayed in the aborted state.
hpqtypes-1.14.0.0 (2025-12-10)
Make begin, commit and rollback do nothing instead of throwing an error
if the on demand connection acquisition mode is active.
hpqtypes-1.13.0.1 (2025-11-27)
Fix a bug in initConnectionState and finalizeConnectionState that could
lead to leaking connections.
hpqtypes-1.13.0.0 (2025-11-26)
Drop support for GHC < 9.2.
Include time spent executing queries in ConnectionStats.
Add initialConnectionStats.
Introduce on-demand connection acquisition mode.
hpqtypes-1.12.0.0 (2024-03-18)
Drop support for GHC 8.8.
Attach CallStack and BackendPid to DBException.
Add getBackendPid to MonadDB for getting the ID of the server process
attached to the current session.
hpqtypes-1.11.1.2 (2023-11-08)
Support multihost setups and the connect_timeout parameter in the connection
string.
hpqtypes-1.11.1.1 (2023-03-14)
Add support for GHC 9.6.
hpqtypes-1.11.1.0 (2023-01-31)
Add support for setting a custom role when establishing a connection.
hpqtypes-1.11.0.0 (2023-01-18)
Require resource-pool >= 0.4 and adjust the createPool function to
seamlessly accommodate future changes to the resource-pool library.
hpqtypes-1.10.0.2 (2022-10-12)
Simplify Setup.
hpqtypes-1.10.0.1 (2022-09-23)
Provide detailed error when openConnection fails.
hpqtypes-1.10.0.0 (2022-09-14)
Improve Show instances of HPQTypesError and LibPQError.
Remove INLINE and INLINABLE pragmas.
Fix a rare bug in the connect function related to file descriptors.
Add support for GHC 9.4.
Require resource-pool >= 0.3 (changes type signature of poolSource).
hpqtypes-1.9.4.0 (2022-05-18)
Add support for prepared statements.
Make more foreign C calls safe.
Don’t manage PGconn with a ForeignPtr.
Use closeFdWith when closing connections.
hpqtypes-1.9.3.1 (2022-03-30)
Fix withTransaction and withSavepoint with short-circuiting monad
transformers such as ExceptT.
hpqtypes-1.9.3.0 (2022-02-25)
Fix support for M1 chips.
Add support for aeson >= 2.0.
Add support for GHC 9.2.
Drop support for GHC < 8.8.
hpqtypes-1.9.2.1 (2021-11-04)
Improve an SQL query that gets information about composite types.
hpqtypes-1.9.2.0 (2021-09-29)
Add method withFrozenLastQuery to (temporarily) stop recording queries.
hpqtypes-1.9.1.2 (2021-07-29)
Fix compilation issues caused by ambiguos occurence of controlT.
hpqtypes-1.9.1.1 (2021-05-27)
Support GHC 9.0.
hpqtypes-1.9.1.0 (2020-09-14)
Expose aesonFromSQL and aesonToSQL for convenience.
hpqtypes-1.9.0.1 (2020-09-04)
Remove upper bounds of dependencies.
hpqtypes-1.9.0.0 (2020-04-02)
Support GHC 8.8 and 8.10.
hpqtypes-1.8.0.1 (2020-02-06)
Make poolSource work properly with shortcircuiting monad transformers.
Remove the Default instances for ConnectionSettings and
TransactionSettings; use defaultConnectionSettings and
defaultTransactionsettings instead
(#15).