Expand description
PostgreSQL v3 wire protocol message framing (Phase 3.1 PG parity).
Implements the bits of the PG v3 protocol RedDB needs for simple
query support: startup negotiation, authentication (trust), the
simple query flow (Q → T/D*/C/Z), and error reporting.
The full PG reference lives at: https://www.postgresql.org/docs/current/protocol-message-formats.html
§Frame format (v3)
After the startup message, every frame is:
[u8 type] [i32 length (includes itself)] [payload]Frames are big-endian. We use tokio::io::AsyncRead/Write so the
listener can plug into the same task model as the existing wire
binary protocol.
Structs§
Enums§
- Backend
Message - Backend (server → client) messages we emit.
- Describe
Target - Frontend
Message - Frontend (client → server) messages we parse.
- PgWire
Error - Error type surfaced by the framing layer. Wraps IO errors plus structural validation failures (bad message tag, truncated frame).
- Transaction
Status
Constants§
- PG_
CANCEL_ REQUEST - PG_
GSSENC_ REQUEST - PG_
PROTOCOL_ V3 - Protocol version constant: 3.0 → 196608 (major<<16 | minor).
- PG_
SSL_ REQUEST - Special startup-phase requests that share the StartupMessage length header. The PG reference calls out three: SSLRequest (80877103), GSSENCRequest (80877104), CancelRequest (80877102).
Functions§
- read_
frame - Read a regular tagged frame after the startup handshake.
- read_
startup - Read the initial StartupMessage (or SSL/GSS request). The startup frame has no type byte — just a length prefix followed by the payload. Returns either a decoded Startup/SSL/GSS message or an error.
- write_
frame - Serialize + send a backend message.
- write_
raw_ byte - Emit a raw byte (used for the SSL/GSS negotiation response: ‘N’ meaning “not supported, continue in plaintext”).