Open-Source Wikis

/

ClickHouse

/

API

/

Postgres wire

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_SCHEMA queries).

What doesn't

  • Postgres-specific built-ins (pg_catalog functions 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.
  • Stringtext.
  • DateTime, Datetimestamp, date.
  • Array(T)text[] (or matched array OIDs where possible).
  • UUIDuuid.
  • 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 PostgreSQL table engine and postgresql(...) table function.
  • MaterializedPostgreSQL engine for replicating an upstream Postgres database into a local schema. Backed by logical replication slots; see src/Storages/PostgreSQL/ and src/Databases/MaterializedPostgreSQL/.
  • Dictionaries with <source><postgresql> (see Dictionaries).

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Postgres wire – ClickHouse wiki | Factory