Chapter 58. Frontend/Backend Protocol

Table of Contents

58.1. Overview
58.1.1. Messaging Overview
58.1.2. Extended Query Overview
58.1.3. Formats and Format Codes
58.1.4. Protocol Versions
58.2. Message Flow
58.2.1. Start-up
58.2.2. Simple Query
58.2.3. Extended Query
58.2.4. Pipelining
58.2.5. Function Call
58.2.6. COPY Operations
58.2.7. Asynchronous Operations
58.2.8. Canceling Requests in Progress
58.2.9. Termination
58.2.10. SSL Session Encryption
58.2.11. GSSAPI Session Encryption
58.3. SASL Authentication
58.3.1. SCRAM-SHA-256 Authentication
58.3.2. OAUTHBEARER Authentication
58.4. Streaming Replication Protocol
58.5. Logical Streaming Replication Protocol
58.5.1. Logical Streaming Replication Parameters
58.5.2. Logical Replication Protocol Messages
58.5.3. Logical Replication Protocol Message Flow
58.6. Message Data Types
58.7. Message Formats
58.8. Error and Notice Message Fields
58.9. Logical Replication Message Formats
58.10. Summary of Changes since Protocol 2.0

Postgres Pro Shardman uses a message-based protocol for communication between frontends and backends (clients and servers). The protocol is supported over TCP/IP and also over Unix-domain sockets. Port number 5432 has been registered with IANA as the customary TCP port number for servers supporting this protocol, but in practice any non-privileged port number can be used.

This document describes version 3.2 of the protocol, introduced in Postgres Pro Shardman version 18. The server and the libpq client library are backwards compatible with protocol version 3.0, implemented in PostgreSQL 7.4 and later.

In order to serve multiple clients efficiently, the server launches a new backend process for each client. In the current implementation, a new child process is created immediately after an incoming connection is detected. This is transparent to the protocol, however. For purposes of the protocol, the terms backend and server are interchangeable; likewise frontend and client are interchangeable.