Skip to content

v0.13.0

Choose a tag to compare

@kenshaw kenshaw released this 07 Oct 05:02
· 43 commits to main since this release

This release adds the driver clickhouse, for ClickHouse. No other driver changes for a caller.

New

  • ClickHouse. The package clickhouse runs SQL on ClickHouse through its HTTP interface, measured on ClickHouse 25.3, 25.8 and 26.9. It does not speak the native protocol (D174). The DSN is clickhouse://user:password@host:8123/database, with the key tls and the port 8443 when tls=true (D177).
  • Name. The driver registers the name clickhouse, as ClickHouse/clickhouse-go does, so a program can link only one of the two.
  • Reading. A query reads JSONCompactEachRowWithNamesAndTypes with encoding/json/v2, one token at a time, with six settings on every request: 64-bit integers as numbers, quoted special floats, ISO times, tuples as arrays, the error of a late failure as a marker, and no compression of the answer (D176).
  • Errors after rows. The server answers HTTP 200 with the first rows, so a late error cannot change the status. The driver reads the marker in the stream, and a status other than 200 is an error even when rows came first. A result that ends with no marker and no end of its rows is cut short, and the error wraps dbimp.ErrIncomplete.
  • Parameters. The server binds typed parameters. The driver writes {pN:Type} in the statement and sends param_pN in the query string, with the type chosen from the Go type of the argument.
  • Cancel. Each statement carries a query_id. When the context ends, and when the caller closes the rows before the end, the driver sends KILL QUERY, because a disconnect does not stop a query on 26.9.
  • Types. Int128, Int256, UInt128 and UInt256 are *big.Int. IPv4 and IPv6 are netip.Addr. Time and Time64 are time.Duration. DateTime and DateTime64 are time.Time. A geometry is a nested []any, and a Variant, a Dynamic and a JSON are the decoded JSON value. docs/TYPES.md has two new kinds for the first two (D177).

What a caller must know

  • BeginTx fails with dbimp.ErrNotSupported, because the server answers every BEGIN with HTTP 501.
  • UPDATE goes to the server as written. A server that refuses it answers with its error. ALTER TABLE ... UPDATE works on each release and runs in the background unless the caller sets mutations_sync=2.
  • RowsAffected always fails with dbimp.ErrNotSupported, because the server reports 0 rows for an update and a delete.
  • A statement with a FORMAT clause fails with dbimp.ErrNotSupported.
  • A Tuple and a time.Duration for a Time column have no Go type to bind. Pass JSON text through JSONExtract.
  • QueryRow sends KILL QUERY too, because database/sql closes the rows after the first one.
  • The value of a Variant has no member type, a Dynamic and the paths of a JSON have no type, an instant has no zone, and an AggregateFunction has no value.
  • TLS and a cluster are not measured.

Other changes

  • The workflow pins dbmeta at its release v0.3.0, which publishes the HTTP port of ClickHouse and the user dbmeta_user.
  • ClickHouse has no flavor. The driver asks SELECT version() once for each connection.

Tests

CI passed all 32 jobs on the tagged commit, which includes the integration jobs of ClickHouse 25.8 and 26.9. The author also ran the integration tests on ClickHouse 25.3.