Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.

PostgreSQL compatibility

holadb serve <dir> --pg 127.0.0.1:5433 adds a PostgreSQL wire-protocol (v3) endpoint. psql, libpq and drivers built on it (psycopg, pgx, JDBC, node-postgres, …) connect to it as if it were a PostgreSQL server; the SQL they send is HolaDB’s SQL subset.

psql postgresql://app@127.0.0.1:5433/holadb
PGPASSWORD=secret psql -h 127.0.0.1 -p 5433 -U app -d holadb -c "SELECT count(*) FROM users"

Supported

  • Startup, SSLRequest (answered with S and upgraded when the server has --tls-cert/--tls-key, N otherwise; --require-tls refuses a plaintext startup with 28000), CancelRequest (ignored).
  • Authentication: none while the database has no users; SCRAM-SHA-256 (SASL) once it has, exactly as psql and libpq drivers expect (PGPASSWORD, .pgpass, the password prompt); over TLS SCRAM-SHA-256-PLUS with tls-server-end-point channel binding is offered first and psql uses it. The user name comes from the startup message. Authentication is re-checked on every message: a session from before the first user, or of a user since dropped, ends with 28000; a changed role set applies at the next statement; a statement the user may not run is refused at Parse with 42501. Failed logins back the client address off (28000 “too many failed logins” inside the window).
  • Limits: --max-connections (53300 when full), --statement-timeout-ms (57014), startup packets over 10 000 bytes and pre-authentication messages over 64 KiB are refused.
  • The parameter statuses clients look for (server_version, client_encoding, DateStyle, TimeZone, integer_datetimes, standard_conforming_strings, …).
  • The simple query protocol, including multi-statement scripts; the extended protocol (Parse / Bind / Describe / Execute / Sync / Close / Flush) with text parameters and binary parameters for the fixed-width types; RowDescription with PostgreSQL type OIDs; text-format results; CommandComplete tags; ErrorResponse with SQLSTATE codes and error positions; transaction status in ReadyForQuery.
  • SET / RESET of session settings a driver sends (client_encoding, DateStyle, application_name, …): accepted, with no effect. The isolation level is not such a setting: SET TRANSACTION ISOLATION LEVEL READ COMMITTED is accepted because that is the level HolaDB has; any other level (SERIALIZABLE, REPEATABLE READ, also through default_transaction_isolation) is refused with 0A000, so that a client is never told it has a guarantee it does not have. SHOW server_version, SHOW transaction_isolation and a few other parameters, SELECT version().
  • Transactions with the PostgreSQL semantics (a failed statement aborts the transaction until ROLLBACK).

Not supported (refused with a clear error, never faked)

  • COPY; the pg_catalog / information_schema tables, so psql’s \d, \dt and ORM introspection do not work — use SHOW TABLES / SHOW COLUMNS FROM t; DECLARE CURSOR; portals with a row limit (Execute with a maximum returns everything); binary result formats; LISTEN / NOTIFY; multiple databases (the database name in the URL is ignored); and every SQL construct outside the subset (JOIN, subqueries, GROUP BY, …).

Type mapping on the wire

HolaDB PostgreSQL type sent to clients
BOOLEAN bool
TINYINT, SMALLINT int2
INTEGER, UTINYINT, USMALLINT int4
BIGINT, UINTEGER int8
UBIGINT numeric (a 64-bit unsigned value may exceed int8)
REAL float4
DOUBLE PRECISION float8
TEXT text
BYTEA bytea (\x hex)
TIMESTAMP timestamp (YYYY-MM-DD HH:MM:SS.ffffff)
JSON json

Security note

Without --tls-* the endpoint is plaintext: bind it to 127.0.0.1 or a trusted network. With TLS, use sslmode=verify-full and sslrootcert (or a publicly trusted certificate) so the client checks the server; --require-tls on the server stops any client from connecting in clear. Passwords are never sent in clear: SCRAM proves possession of the password without transmitting it, and over TLS the proof is bound to the server certificate.