mariadb-haskell: Alpha streaming Haskell driver for MariaDB

[ database, library ] [ Propose Tags ] [ Report a vulnerability ]

Alpha software: extensively validated with automated tests and benchmarks, but not yet validated in real-world applications. Evaluate in your own environment before relying on it; APIs and behavior may change.

MariaDB-only fork of mysql-haskell. Streaming text and binary queries, managed prepared statements, native bulk execution, cached/extended metadata, session observations and clean connection reset, streamed parameters, server cursors, progress reporting and optional transport compression.

TCP, Unix sockets and verified TLS, including client certificates and explicit PAM/Kerberos authentication. Row-based CDC supports MariaDB GTID resume, complete-group checkpoints and manual semisync acknowledgements.

See the packaged README, user guide, migration guide and benchmark guide, or https://github.com/aantich/mariadb-haskell. User guide; benchmarks; live validation. Public modules retain Database.MySQL names; MySQL servers are not supported. Full validation currently covers MariaDB 12.3.3 on macOS and Linux. Linux builds require zlib and MIT Kerberos development libraries; macOS uses the system GSS framework. Windows GSSAPI is unavailable.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
validation

Build the developer-only correctness and benchmark harness

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log ChangeLog.md
Dependencies asn1-encoding (>=0.9 && <0.10), asn1-types (>=0.3 && <0.4), base (>=4.17 && <4.22), binary (>=0.8.3 && <0.9), blaze-textual (>=0.2 && <0.3), bytestring (>=0.10.2.0 && <0.12 || >=0.12.0 && <0.13), bytestring-lexing (>=0.5 && <0.6), containers (>=0.5 && <0.9), crypton (>=2.0.0 && <2.1 || >=2.1.0 && <2.2), crypton-pem (>=0.2.4 && <0.4), crypton-x509 (>=1.5 && <2), crypton-x509-store (>=1.5 && <2), crypton-x509-system (>=1.5 && <2), data-default-class (>=0.1.2 && <0.2 || >=0.2.0 && <0.3), deepseq (>=1.4.6 && <1.5 || >=1.5.0 && <1.6), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), io-streams (>=1.2 && <2), mariadb-haskell, monad-loops (>=0.4 && <0.5), network (>=2.3 && <4), process (>=1.6 && <1.7), ram (>=0.20 && <0.23), scientific (>=0.3 && <0.4), text (>=1.1 && <2.2), time (>=1.5.0 && <1.12 || >=1.12.2 && <1.13 || >=1.14 && <1.15), tls (>=1.7.0 && <1.8 || >=1.8.0 && <1.9 || >=1.9.0 && <1.10 || >=2.0.0 && <2.1 || >=2.1.0 && <2.2 || >=2.2.0 && <2.3 || >=2.3.0 && <2.4 || >=2.4.0 && <2.5), vector (>=0.8 && <0.13 || >=0.13.0 && <0.14), word-compat (>=0.0 && <0.1), zlib (>=0.6 && <0.8) [details]
Tested with ghc ==9.4.7, ghc ==9.10.3
License BSD-3-Clause AND MPL-2.0[multiple license files]
Copyright (c) 2016 Winterland
Author winterland1989
Maintainer Anton Antich <anton.antich@gmail.com>
Uploaded by aantich at 2026-11-09T16:03:36Z
Category Database
Home page https://github.com/aantich/mariadb-haskell
Bug tracker https://github.com/aantich/mariadb-haskell/issues
Source repo head: git clone https://github.com/aantich/mariadb-haskell
Distributions
Executables mariadb-validation
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for mariadb-haskell-0.1.0.0

[back to package description]

MariaDB Haskell

Status: Alpha. Extensive automated tests and benchmarks cover the documented MariaDB capabilities, but the driver has not yet been validated in real-world applications. Evaluate it in your own environment; APIs and behavior may change.

A streaming Haskell driver for MariaDB only, forked from mysql-haskell. This fork adds MariaDB's native statement, session, authentication and replication capabilities, with bounded decoding and explicit connection ownership. MySQL servers are not a support target.

User guide and examples · Live test and benchmark report · Benchmark guide · Migration guide

Features

Area What the driver provides
Connections TCP, Unix sockets, verified TLS and client certificates; full Unicode (utf8mb4) by default
Queries Streaming list/vector rows, checked text parameters, managed binary prepared statements, multiple results and stored-procedure OUT parameters
Native statements MariaDB binary bulk execution, NULL/DEFAULT/IGNORE indicators, per-unit results, cached and extended column metadata
Large data One-shot streamed byte/text parameters, bounded upload chunks and server cursor fetches
Sessions Public session observations and connection reset with role/schema/charset restoration and an initialization hook for pools
Operations Progress callbacks and opt-in zlib transport compression
Authentication Native password, Unix-socket accounts, ed25519, PARSEC, SHA-2, TLS certificate accounts, explicit PAM dialogs and Kerberos GSSAPI
MariaDB values Signed/unsigned integers, exact decimals, Unicode and bytes, raw zero/partial dates, and wire representations for JSON, UUID, INET, VECTOR and geometry
CDC Row-based binlog decoding, checksums and compressed events, MariaDB GTID resume, complete-transaction checkpoints and consumer-controlled semisync ACKs
Reliability One command owner per connection, bounded messages/metadata/cleanup, stale-handle rejection, cancellation retirement and uncertain-COMMIT diagnostics

SQL features such as CTEs, window functions, sequences, RETURNING, Oracle mode and system-versioned tables pass through to MariaDB. The driver does not need a separate API for every server function. This is not an ORM or a collection of Haskell domain types for every SQL type.

Quick start

The package is mariadb-haskell, starting with version 0.1.0.0. Public modules retain Database.MySQL.* names, which do not imply MySQL support. See release status for candidate/publication status. Build the checkout as follows; after publication, add mariadb-haskell >=0.1 && <0.2 to your application's Cabal dependencies.

On Linux install a C toolchain, zlib development files and MIT Kerberos (libkrb5-dev on Debian/Ubuntu), even when not using GSSAPI. macOS uses the system GSS framework and Apple's command-line tools. The driver itself does not require Connector/C.

cabal update
cabal build lib:mariadb-haskell

The complete Quickstart.hs reads connection settings from the environment. For an existing ConnectInfo, a prepared query looks like this:

{-# LANGUAGE OverloadedStrings #-}
import Control.Exception (bracket)
import qualified Database.MySQL.Base as DB
import qualified System.IO.Streams as Streams

printCustomer ci customerId =
  bracket (DB.connect ci) DB.close $ \conn ->
    DB.withPreparedStatement conn
      "SELECT name FROM customers WHERE id = ?" $ \statement -> do
        (_, rows) <- DB.queryPrepared statement [DB.MySQLInt64 customerId]
        Streams.foldM (\() row -> print row) () rows

Consume every result stream within the connection and statement brackets, before issuing another command. A connection and its stream have one owning thread; use separate connections for concurrent workers. Use TLS or a Unix socket for sensitive credentials. The user guide covers connections, values, transactions, bulk, uploads, cursors, pooling, authentication, failures and durable CDC consumers.

Validation and performance

The committed release-input capture from 6bbcf13, recorded on 9 November 2026, reports 844 PASS, 0 FAIL, 0 unsupported API inventory entries and 0 unavailable fixtures on macOS. The inherited suites cover 183 unit/property cases (182 pass and one inherited external-HTTPS case is ignored) and 32 passing integration tests; 180 policy tests pass. A separate Linux profile also passes all 844 checks and 39 native benchmark smoke paths; its exact revision is retained in the release evidence. This closes the original suite's missing driver APIs and authentication fixtures; it does not certify every version or platform.

The Mac run measures 63 profiles, seven process repetitions each. Selected comparisons use alternatives in the same current build:

Comparison (Current vs Baseline) Time unit Baseline Current Change vs baseline
Native bulk vs sequential prepared insert ns/row 41,574.20 1,966.40 -95.27%
Native bulk vs text batch insert ns/row 11,001.40 1,966.40 -82.13%
Cached vs uncached wide prepared metadata ns/execution 76,824.00 56,378.00 -26.61%
Reset/restore vs reconnect/prepare TLS session ns/request 38,469,366.67 464,833.33 -98.79%

Baseline means the named alternative in this build. Change is (current / baseline − 1) × 100; negative means less elapsed time. The benchmark guide also records allocations. These local measurements are not promises for other applications. The host was not idle and timing investigations remain open. Streaming uploads allocate more in the measured case; cursors and compression cost time on local transfers. Some ordinary workloads remain slower than the original fork baseline. No allocation-regression signals were found against the frozen references; this differs from comparing two alternatives within this build.

See the benchmark guide for environment, tradeoffs and immutable data. The live report on main is refreshed from complete captures, retaining failures, baselines and exact source provenance. This dated snapshot describes the recorded release inputs; ordinary documentation/results commits do not claim another measurement.

Live validation status

Tested scope and limits

Full recorded profiles use MariaDB 12.3.3, macOS arm64/GHC 9.10.3 and Linux/GHC 9.4.7. Other server/compiler versions need separate profiles. Capabilities depend on the server version/configuration. Windows is not a verified release platform and its GSSAPI implementation is unavailable.

CDC fails closed on unsupported non-ignorable events. Advanced XA checkpointing, two-phase ALTER and storage-engine-binlog GTID semisync are unsupported by the transaction-aware API. Checkpoints are not persisted by the driver; ACKs alone do not provide exactly-once destination writes. Text codecs cover UTF-8, ASCII and MariaDB latin1; other result charsets remain bytes.

Timeouts/cancellation during protocol I/O retire the connection. Reconnect; never blindly replay a transaction with an uncertain COMMIT. There is no built-in pool or automatic SQL replay.

Development and license

Unit/property tests: cabal test test --enable-tests. Integration/benchmarks require a provisioned server first; follow the validation instructions and managed macOS setup. Implementation history remains in docs/.

Driver code: BSD 3-Clause; see LICENSE. Bundled Mozilla CA data: MPL-2.0; see CA provenance. Original work by Winterland and upstream contributors retains its copyright notices. Report reproducible problems through GitHub issues, including server/compiler versions and sanitized diagnostics.