PostgreSQL front-end

Overview

What the PostgreSQL front-end is, how to start it and what to expect.

Status: available. What is not supported is listed in Errors and limits. Stages 1 to 6 work: the protocol, a large SQL subset, the catalogs psql, JDBC and ORMs read, privileges of roles (also on columns), COPY in text, CSV and binary, PL/pgSQL functions, procedures and triggers of every kind, arrays, JSON functions, pg_dump 18 and pg_restore, LISTEN/NOTIFY, MERGE (with RETURNING), grouping sets, cursors, materialized views, interval and time zones, domains, enums and composite types, time with time zone, updatable views, statistics views, the extensions uuid-ossp, pgcrypto (basics) and pg_trgm, TABLESAMPLE, and pgbench. It is checked against a real PostgreSQL 18 with psql, the PostgreSQL JDBC driver and the Python libraries psycopg2, SQLAlchemy, asyncpg and Django, and the output of all 52 test scripts is identical. Not built: declarative partitioning, range types, tsvector values with ts_rank and the other text search functions beyond @@, rules, large objects and extensions other than the three above (see Errors and limits). Other drivers (Npgsql, node-postgres, Prisma, TypeORM, ActiveRecord) speak the same protocol but have not been tried. Speed claims are about the raw Raft DB protocol, not this front-end (see design decisions).

raftdb-pg answers PostgreSQL clients (psql, pgjdbc, and any driver that speaks protocol 3.0) over the PostgreSQL wire protocol (crate raftdb-pgwire, D104). A statement is parsed as PostgreSQL SQL, translated just before it runs into the SQL of the engine behind raftdb-mysql (the MariaDB dialect, as for raftdb-mssql), run in an engine session, and the answer is typed and printed the way PostgreSQL does it. This file lists what is supported, how it is translated, what is refused and where the output still differs from PostgreSQL. Design reasons are in D104.

State of the checks (stage 1). Seven test scripts and one JDBC program are run through psql / pgjdbc against raftdb-pg and against a real PostgreSQL 18 (a throwaway cluster made with initdb on a free port; locale C, time zone UTC). Every one of them ends identical to PostgreSQL 18 (about 2000 lines of output, statements echoed, errors with their LINE n: caret). The JDBC program runs in text and in binary transfer mode and includes DatabaseMetaData (getTables, getColumns, getPrimaryKeys, getIndexInfo, getSchemas). One script lists what is refused and its output is kept (not compared with PostgreSQL: by definition it differs). The scripts also ran with --tls (psql sslmode=require) and with each authentication method (scram-sha-256, md5, password, trust). The tests of raftdb-pgwire and raftdb-pg together number 41.

State of the checks (stage 2, D110). Besides the stage 1 scripts and the JDBC program, six more scripts are run against raftdb-pg and a real PostgreSQL 18 and end identical: privileges (two scripts: ownership, GRANT/REVOKE, PUBLIC, roles and INHERIT, SET ROLE, default privileges, has_*_privilege, errors), COPY (text, CSV, binary, both directions, options and their errors, \copy), PL/pgSQL (about 70 functions, procedures and DO blocks), triggers (on all events, WHEN, RAISE) and types (SIMILAR TO). raftdb-pg has 28 unit tests and 11 session tests besides the protocol tests. pgbench runs against it (D110.5).

State of the checks (stage 3, D112). Seven more scripts end identical to PostgreSQL 18: arrays, objects (comments, pg_proc, triggers, sequences, dependencies, PREPARE), LISTEN/NOTIFY, queries (FILTER, ordered-set aggregates, WITH TIES, grouping sets, generated columns, MERGE, LATERAL), meta-commands (\df, \sf, \dx, \dm, ...), cursors and materialized views, and a second JDBC program (arrays in text and binary transfer, fetch size, LISTEN between two connections, CopyManager, batches, generated keys). A dump test runs pg_dump 18 against raftdb-pg and a real PostgreSQL 18 server and restores the dumps into real databases: plain, schema then data, and custom format with pg_restore all end with 0 errors and the same \d+ and data as the original; the data-only dump is byte-identical; the other plain dumps differ in 9 lines (the deparsed text of a CHECK and of a view). The tests of the two crates together number 64.

Running#

raftdb-pg --listen 127.0.0.1:5433 --user postgres --password SECRET --embed raftdb.conf --raftdb-user NAME --raftdb-password PW
raftdb-pg --listen 127.0.0.1:5433 --user postgres --password SECRET --raftdb 127.0.0.1:7480 --raftdb-user NAME --raftdb-password PW
        [--auth scram-sha-256|md5|password|trust] [--ssl auto | --ssl-cert FILE --ssl-key FILE] [--identity neutral]

The superuser is --user (default postgres) with --password. The databases postgres (made at start) and the ones CREATE DATABASE makes are PostgreSQL databases; each is an engine database with the front-end's own tables (__pg_tbl, __pg_col, __pg_con, __pg_idx, __pg_sch, __pg_func, __pg_trg). Roles, memberships, grants and default privileges live in the engine database rdb_pg_cluster (hidden). SSLRequest is answered with TLS (rustls through raftdb-tls, TLS 1.2 and 1.3) when a certificate is configured or --ssl auto made one, else with N.

Identity#

By default SELECT version() answers Raft DB 0.0.5 (compatible with PostgreSQL 18.0), protocol 3.0. The text keeps PostgreSQL 18.0, the form that libraries such as SQLAlchemy read the version from; SHOW server_version (18.0), server_version_num (180000) and the server_version parameter sent at login are numeric and unchanged.

version() always answers in Raft DB's own wording; the option --identity vendor was removed (it is refused at start). None of the drivers and tools tried (psql, pgjdbc, psycopg2, SQLAlchemy, asyncpg, Django) needed it.

Connecting#

psql -h 127.0.0.1 -p 5433 -U postgres -d postgres
jdbc:postgresql://127.0.0.1:5433/postgres?user=postgres&password=SECRET

The SQL Server front-end is described in its own chapter.