← Ferrosa Suite home · Database home

PostgreSQL Wire Protocol

Alongside CQL, Ferrosa speaks the PostgreSQL frontend/backend protocol (v3) with SCRAM-SHA-256 authentication — so psql, psycopg2, tokio-postgres, and other standard clients can connect to the same data. This page documents what works today, how it is tested, and where it is headed.

Developer preview: the Postgres front-end is newer than the CQL surface and covers a focused subset of SQL. Validate against your workload before relying on it. Its behavior is continuously cross-checked against a real PostgreSQL 16 (see Differential testing).

On this page

Protocol & connecting

Ferrosa implements the PostgreSQL v3 wire protocol on port 5432 with SCRAM-SHA-256 authentication. Both the simple query protocol and the extended query protocol (Parse / Bind / Describe / Execute / Sync) are supported.

# Any standard PostgreSQL client connects:
psql "host=127.0.0.1 port=5432 user=ferrosa_user dbname=ferrosa"

# psycopg2 / tokio-postgres / Postgrex use the same wire + SCRAM auth.

The active transaction status (I idle, T in-transaction, E failed) is reported in ReadyForQuery exactly as PostgreSQL does, so drivers track transaction state correctly.

Queries (SELECT)

The query surface is verified row-for-row against PostgreSQL across a fixed corpus:

CapabilityStatusNotes
Projection & *column lists and star
WHERE=, !=, </<=/>/>=, AND/OR/NOT, parentheses
Three-valued logiccomparisons with NULL are UNKNOWN → excluded (Kleene AND/OR/NOT)
JOINinner equi-join
GROUP BY + aggregatesCOUNT, SUM, MIN, MAX, AVG; empty SUM/MINNULL
HAVING / DISTINCT
ORDER BY / LIMIT / OFFSETASC/DESC, multi-key; text orders by C collation (byte order)
Expression selectsSELECT 1, version(), current_database() (simple + extended)
Scalar typesint, text, bool, float8, numeric, uuid, bytea, inet, timestamp, date, time

Writes (INSERT / UPDATE / DELETE)

Single-row DML writes through the same storage engine the CQL path uses, sharing one canonical row encoder so a row written over Postgres reads back identically over CQL.

INSERT INTO kv (id, v, n) VALUES (1, 'one', 10);   -- INSERT 0 1
UPDATE kv SET v = 'ONE' WHERE id = 1;            -- UPDATE 1
DELETE FROM kv WHERE id = 1;                     -- DELETE 1

Transactions

BEGIN / COMMIT / ROLLBACK are honored at the protocol level: the connection moves through idle → in-transaction → (on error) failed, and a failed transaction rejects further statements with SQLSTATE 25P02 until ROLLBACK.

In progress: multi-statement atomicity routes through Accord (Ferrosa's strict-serializable transaction engine). The protocol-state machine is complete; the atomic commit path is being wired up.

Differential testing

Every CI build runs a differential oracle: the same data and the same SQL are executed against a real PostgreSQL 16 and the Ferrosa front-end, and the result sets must agree. It is the cross-check that catches the front-end silently diverging from PostgreSQL.

How it stays honest: three verdicts (Match / Mismatch / Out-of-scope, never a silent pass); a sound value comparator (exact match first, a numeric tolerance only for genuine float-vs-numeric text formatting); a restricted-query oracle proving unsupported SQL fails loud rather than returning wrong rows; a self-contained NULL/3VL known-answer corpus; and a declared COLLATE "C" ordering contract. The corpus covers SELECT, the full INSERT/UPDATE/DELETE lifecycle, and temporal/numeric/inet types.

See the postgres-oracle job in .github/workflows/ci.yml and ferrosa-postgres/tests/differential_oracle.rs.

Not yet supported

These surface a clean driver error today rather than silently-wrong results, and are tracked on the roadmap:

FeatureStatus
$N params in DMLin progress — extended-protocol bind for writes
RETURNING / ON CONFLICTplanned
IS [NOT] NULLplanned
Subqueries, WITH, UNION, window functionsnot supported
Non-C collationsv1 is COLLATE "C" only
CQL is the mature surface. For the broadest compatibility today, see the CQL Reference. The Postgres front-end shares the same storage, schema, and transaction engine underneath.