clickhouse/clickhouse
Postgres wire
ClickHouse implements the PostgreSQL wire protocol so psql, libpq, and tools that speak Postgres can connect without changes. Default port: 9005. Implementation: src/Server/PostgreSQLHandler.cpp and src/Server/PostgreSQLHandlerFactory.cpp, with the parser-side support under src/Core/PostgreSQL*.cpp and src/Parsers/PostgreSQL/.
psql "host=localhost port=9005 user=user dbname=default sslmode=disable"What works
- Simple query and extended query protocols.
- Prepared statements.
- Authentication:
md5,scram-sha-256,cleartext. - TLS.
- Cursor-style streaming (basic) and chunked rows.
- ClickHouse SQL dialect (with light translation of
INFORMATION_SCHEMAqueries).
What doesn't
- Postgres-specific built-ins (
pg_catalogfunctions beyond a small compatibility shim). - Server-side commands (
COPY,LISTEN/NOTIFY,PREPARE TRANSACTION). - Stored procedures, triggers.
Type mapping
ClickHouse types are advertised with the closest matching PostgreSQL OID:
- Numeric types map to
int4/int8/numeric/float8. String→text.DateTime,Date→timestamp,date.Array(T)→text[](or matched array OIDs where possible).UUID→uuid.Decimal(P,S)→numeric(P,S).
When to use it
- You already have a Postgres-only client or BI tool.
- You want to combine ClickHouse with the ecosystem of
psql,pgcli, and Postgres-flavoured ORMs. - You're migrating an internal tool from Postgres to ClickHouse and want a transitional layer.
Postgres-as-a-source
The opposite direction (read from / write to Postgres) is supported via:
- The
PostgreSQLtable engine andpostgresql(...)table function. MaterializedPostgreSQLengine for replicating an upstream Postgres database into a local schema. Backed by logical replication slots; seesrc/Storages/PostgreSQL/andsrc/Databases/MaterializedPostgreSQL/.- Dictionaries with
<source><postgresql>(see Dictionaries).
Related pages
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.