clickhouse-c is a minimalist, header-only C client that implements ClickHouse's native binary protocol (Native Protocol over TCP carrying Native Format blocks). It is designed for easy embedding in constrained environments such as PostgreSQL extensions (supports palloc-style allocators via wiring but contains no Postgres-specific code). The design splits a single core header that provides block reader/writer, type parsing, allocation and IO abstractions from optional follow-up headers that add TCP packet handling, compression (LZ4, ZSTD), OpenSSL-backed IO, and a posix blocking IO implementation. A quickstart shows how to decode clickhouse-local Native-format output using chc_in/chc_block_read and a caller-supplied chc_io; the code pattern uses a single translation unit with CHC_IMPLEMENTATION and an optional CHC_PROVIDE_STDLIB_ALLOC for malloc wiring. The client expects servers configured with output_format_native_encode_types_in_binary_format=0 and the TCP client targets ClickHouse 23.3+.
The repo includes per-header documentation, runnable examples, and tests driven by test.sh (tests can spawn a ClickHouse server or use recorded fixtures). Follow-up headers are independent, so consumers pick only what they need. Explicit non-goals include HTTP (libcurl), DNS/round-robin, connection pooling, SSL/TLS context lifecycle, internal threading, and in-library async IO; a separate ioless async header exists for event-loop driven consumers. Licensed under Apache-2.0 and intentionally single-threaded, the library aims for a compact, dependency-light wire-format implementation for embedding and tooling.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.