Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sql.postgres.protocol

import sql.postgres.protocol

sql lifts part of this module out to its own top level; each name below is shown with the path that reaches it. Anything still spelled sql.postgres.protocol.* needs import sql.postgres.protocol.

The PostgreSQL frontend/backend protocol, version 3.

A connection is a sequence of messages in both directions. The client sends a request and then a Sync, and the server answers with some number of messages ending in ReadyForQuery. Everything between those two points belongs to the request, and nothing else may be sent until it arrives, which is what makes this a state machine rather than a set of independent calls.

Why statements are described before they are bound

A value can be sent and received either as text or in the server’s own binary form, chosen per parameter and per column, and the choice is made in the Bind message. To choose well, the types have to be known first, which is what Describe reports. So a statement is parsed and described once, and every execution after that reuses what was learned. A statement run in a loop pays for this once.


2026, Richard Ore and Zuri contributors