バージョンごとのドキュメント一覧

第55章 フロントエンド/バックエンドプロトコル

目次

55.1. 概要
55.1.1. メッセージ処理の概要
55.1.2. 拡張問い合わせの概要
55.1.3. 書式と書式コード
55.2. メッセージの流れ
55.2.1. 開始
55.2.2. 簡易問い合わせ
55.2.3. 拡張問い合わせ
55.2.4. パイプライン化
55.2.5. 関数呼び出し
55.2.6. COPY操作
55.2.7. 非同期操作
55.2.8. 処理中のリクエストの取り消し
55.2.9. 終了
55.2.10. SSLセッション暗号化
55.2.11. GSSAPIセッション暗号化
55.3. SASL認証
55.3.1. SCRAM-SHA-256 認証
55.4. ストリーミングレプリケーションプロトコル
55.5. 論理ストリーミングレプリケーションのプロトコル
55.5.1. 論理ストリーミングレプリケーションのパラメータ
55.5.2. 論理レプリケーションのプロトコルのメッセージ
55.5.3. 論理レプリケーションのプロトコルのメッセージフロー
55.6. メッセージのデータ型
55.7. メッセージの書式
55.8. エラーおよび警報メッセージフィールド
55.9. 論理レプリケーションのメッセージ書式
55.10. プロトコル2.0からの変更点の要約
<title>Frontend/Backend Protocol</title>

<productname>PostgreSQL</productname> uses a message-based protocol for communication between frontends and backends (clients and servers). The protocol is supported over <acronym>TCP/IP</acronym> 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. PostgreSQLはフロントエンドとバックエンド(クライアントとサーバ)の通信にメッセージベースのプロトコルを使用します。 このプロトコルはTCP/IPに加え、Unixドメインソケットをサポートします。 ポート番号5432は、このプロトコルをサポートするサーバ用のTCPポートとしてIANAに登録されています。 しかし、実際には任意の非特権ポート番号を使用することができます。

This document describes version 3.0 of the protocol, implemented in <productname>PostgreSQL</productname> 7.4 and later. For descriptions of the earlier protocol versions, see previous releases of the <productname>PostgreSQL</productname> documentation. A single server can support multiple protocol versions. The initial startup-request message tells the server which protocol version the client is attempting to use. If the major version requested by the client is not supported by the server, the connection will be rejected (for example, this would occur if the client requested protocol version 4.0, which does not exist as of this writing). If the minor version requested by the client is not supported by the server (e.g., the client requests version 3.1, but the server supports only 3.0), the server may either reject the connection or may respond with a NegotiateProtocolVersion message containing the highest minor protocol version which it supports. The client may then choose either to continue with the connection using the specified protocol version or to abort the connection. この文書はPostgreSQL 7.4以降で実装されたプロトコル3.0バージョンについて記載します。 以前のプロトコルバージョンについての説明は、PostgreSQLの以前のリリースの文書を参照してください。 単一のサーバが複数のプロトコルバージョンをサポートできます。 初めの開始要求メッセージは、サーバに対し、クライアントが使用する予定のプロトコルバージョンを通知します。 クライアントが要求したメジャーバージョンをサーバがサポートしない場合は、接続は拒否されます。(これはたとえば、クライアントが本稿執筆時点で存在しないプロトコルバージョン4.0を要求した際に起るでしょう。) クライアントが要求したマイナーバージョンをサーバがサポートしない場合は(たとえばクライアントがバージョン3.1を要求し、サーバが3.0しかサポートしていないようなときです)、サーバは接続を拒否しても良いですし、サポートする最も大きなマイナープロトコルバージョンを含むNegotiateProtocolVersionメッセージを返しても構いません。 クライアントは、指定されたプロトコルバージョンで接続を継続するか、あるいは接続を切断するかのどちらかを選択できます。

In order to serve multiple clients efficiently, the server launches a new <quote>backend</quote> 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 <quote>backend</quote> and <quote>server</quote> are interchangeable; likewise <quote>frontend</quote> and <quote>client</quote> are interchangeable. 複数のクライアントにサービスを効率的に提供するために、サーバは各クライアント毎に新規のバックエンドプロセスを起動します。 現在の実装では、サーバに接続が届いたことを検知すると即座に新しい子プロセスが生成されます。 しかし、これはプロトコルに対して透過的です。 プロトコルという意味では、バックエンドサーバという用語は相互交換可能です。 同様にフロントエンドクライアントも相互交換可能です。