Postgres frontend/backend protocol for Flyology
Postgres, in native Ada.
Flyology Postgres provides typed, bounded client and server primitives over Flyology I/O.
Client.Send_Query
(Session,
"select id, value from items",
Timeout => 5.0);
Sessions.Send_Data_Row
(Client, "Ada", Timeout => 5.0);
Sessions.Send_Command_Complete
(Client, "SELECT 1", Timeout => 5.0);
Two protocol directions
Build clients and protocol servers from the same wire model.
The protocol layer owns framing and typed messages. Client sessions and server sessions add explicit state, streaming, authentication, and cancellation behavior.
Connect to Postgres
Speak to Postgres tools
Protocol architecture
Every transition stays inspectable.
Startup, queries, COPY, recovery, and cancellation each have an explicit contract. Applications retain control without reimplementing frame validation.
Read the implementation guide-
01
Startup and authentication
Trust, cleartext password, and SCRAM-SHA-256 are handled through the Postgres startup exchange.
-
02
Typed wire messages
Known protocol messages receive owned typed views. Unknown future tags retain their original bytes.
-
03
Bounded streaming
Simple queries, extended queries, and COPY return one event or frame per call, with no hidden result accumulator.
-
04
Separate cancellation
Backend cancellation credentials travel on the separate connection required by the Postgres protocol.
Current coverage
The high-value protocol paths, without an async language.
Calls remain ordinary synchronous Ada operations. On a lightweight task, Flyology suspends the task while its loop thread remains available.
- Simple queriesTyped row descriptions, rows, completion, diagnostics, and readiness.
- Extended queriesPrepared statements, portals, flush, sync, suspension, and recovery.
- COPYBounded COPY IN, COPY OUT, and COPY BOTH streams.
- AuthenticationTrust, cleartext password, and SCRAM-SHA-256.
- Protocol serversApplication handlers with typed response helpers and cancellation tokens.
Boundaries
Concrete coverage, with limits attached.
TLS and channel binding are intentionally deferred. Cleartext-password authentication is for trusted test or private networks until transport upgrades are available.
Review all current boundaries| Concern | Contract |
|---|---|
| TLS | Clients currently start in plaintext; servers answer SSLRequest with N. |
| Authentication | No MD5, GSSAPI, SSPI, certificate auth, or SCRAM-SHA-256-PLUS. |
| Memory | Rows and COPY frames are returned individually; callers own their buffering policy. |
| Scheduling | Continuously readable COPY streams may need explicit Flyology fairness points. |
Working examples
Exercise both ends of the wire.
psqlish is a compact Postgres client. pgish is a read-only Postgres-like server with virtual Flyology and catalog tables. Use them together, or connect either side to real Postgres tooling.