DBIO-ClickHouse

 view release on metacpan or  search on metacpan

docs/adr/0001-mysql-wire-protocol-transport.md  view on Meta::CPAN

ClickHouse is a column-oriented OLAP database. It exposes several client
protocols: its native TCP protocol (port 9000), an HTTP interface (port 8123),
and — the one that matters here — the **MySQL wire protocol** (port 9004).

There is **no native `DBD::ClickHouse` on CPAN** (verified). Writing and
maintaining a native XS/FFI DBD against ClickHouse's native protocol is a large,
open-ended effort and is out of scope for a DBIO driver. DBIO drivers are thin
layers on top of an existing DBI driver; they do not implement the DBI transport
themselves.

ClickHouse's MySQL-wire endpoint lets any MySQL-protocol client connect. The
DBIO family already depends on two such DBI drivers for `dbio-mysql`:
`DBD::MariaDB` (bundles the MariaDB Connector/C) and `DBD::mysql`. Either can
talk to ClickHouse's port 9004.

## Decision

`DBIO::ClickHouse` rides the **MySQL wire protocol** via an existing MySQL-wire
DBI driver rather than a native `DBD::ClickHouse`:

1. `DBD::mysql` is the **recommended** transport (`recommends` in the

docs/adr/0001-mysql-wire-protocol-transport.md  view on Meta::CPAN

  (whose `connection()` sets `storage_type('+DBIO::ClickHouse::Storage')`) or by
  the `-ch` shortcut. This is documented prominently in the README, CLAUDE.md
  and the module POD.
- The `ClickHouse` driver name is still registered
  (`register_driver('ClickHouse' => ...)`) so the component / shortcut resolver
  and `apply_driver` work; it is simply never reached by *DSN* autodetection.
- Any MySQL feature the protocol advertises but ClickHouse does not actually
  implement (transactions, savepoints, `FOR UPDATE`, `RETURNING`,
  auto-increment) must be neutralised in the storage/SQLMaker rather than
  inherited blindly. See ADR 0002.
- The driver depends on ClickHouse's MySQL-wire endpoint being enabled
  (server config `mysql_port = 9004`).
- **`DBD::MariaDB` additionally requires a server-side setting to connect at
  all.** Found in the first live run (ClickHouse 25.3.14.14, 2026-07-26), not
  by reading docs. On connect, `DBD::MariaDB` unconditionally issues
  `SET character_set_server = 'utf8mb4'` — the statement is a hardcoded string
  in the compiled driver and there is no connect attribute that suppresses it.
  ClickHouse rejects a `SET` of any name it does not know unless that name
  begins with a registered custom-settings prefix, and ships with only `SQL_`:

      Code: 115. DB::Exception: Setting character_set_server is neither a

docs/adr/0003-no-transactions-policy.md  view on Meta::CPAN

# ADR 0003 — Transactions: no-op with a warning, but rollback throws

- Status: accepted
- Date: 2026-07-25

## Context

ClickHouse has no transactions. `BEGIN` / `COMMIT` over the MySQL wire endpoint
(ADR 0001) do not give real atomicity, and there are no savepoints — the
savepoint hooks (`_exec_svp_begin` / `_exec_svp_release` / `_exec_svp_rollback`)
already throw. What was left open is DBIO's *transaction* API:
`txn_do`, `txn_begin`, `txn_commit`, `txn_rollback`.

This is not a corner of the API that a driver can ignore. Core itself reaches
for transactions on ordinary operations: `ResultSet::populate`, `delete_all`,
`update_all`, multi-create in `Row::insert`, and cascading delete all open a
`DBIO::Storage::TxnScopeGuard`, i.e. `txn_begin` + `txn_commit`, with
`txn_rollback` on the unwind. Whatever this driver decides, it decides for the



( run in 0.904 second using v1.01-cache-2.11-cpan-eb134014566 )