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.
- TLSVerified client and server upgrades with encrypted cancellation.
- Protocol serversApplication handlers with typed response helpers and cancellation tokens.
Boundaries
Concrete coverage, with limits attached.
TLS clients verify server certificate chains and DNS names, and servers can require encrypted startup. Client-certificate authentication and SCRAM channel binding remain explicit boundaries.
Review all current boundaries| Concern | Contract |
|---|---|
| TLS | Startup_TLS and Serve_TLS use PostgreSQL SSLRequest negotiation without plaintext fallback; encrypted cancellation is available separately. sslnegotiation=direct is not yet supported. |
| 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 with verified TLS. pgish is a read-only Postgres-like server with configurable required TLS, virtual Flyology, and catalog tables. Use them together, or connect either side to real Postgres tooling.