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

第49章 ロジカルデコーディング

目次

49.1. ロジカルデコーディングの例
49.2. ロジカルデコーディングのコンセプト
49.2.1. ロジカルデコーディング
49.2.2. レプリケーションスロット
49.2.3. 出力プラグイン
49.2.4. スナップショットのエクスポート
49.3. ストリームレプリケーションプロトコルインタフェース
49.4. ロジカルデコーディングSQLインタフェース
49.5. ロジカルデコーディング関連のシステムカタログ
49.6. ロジカルデコーディングの出力プラグイン
49.6.1. 初期化関数
49.6.2. 機能
49.6.3. 出力モード
49.6.4. 出力プラグインコールバック
49.6.5. 出力生成関数
49.7. ロジカルデコーディング出力ライタ
49.8. ロジカルデコーディングにおける同期レプリケーションのサポート
49.8.1. 概要
49.8.2. 警告
49.9. ロジカルデコーディングための大規模トランザクションのストリーミング
49.10. ロジカルデコーディングための2相コミット
<title>Logical Decoding</title>

PostgreSQL provides infrastructure to stream the modifications performed via SQL to external consumers. This functionality can be used for a variety of purposes, including replication solutions and auditing. PostgreSQLは、SQLによって実行された更新結果を外部のコンシューマにストリーミングする基盤を提供しています。 この機能は、レプリケーションソリューションや監査など、さまざまな目的に使用できます。

Changes are sent out in streams identified by logical replication slots. 更新結果は、ロジカルレプリケーションスロット(logical replication slots)で識別されるストリームに送出されます。

The format in which those changes are streamed is determined by the output plugin used. An example plugin is provided in the PostgreSQL distribution. Additional plugins can be written to extend the choice of available formats without modifying any core code. Every output plugin has access to each individual new row produced by <command>INSERT</command> and the new row version created by <command>UPDATE</command>. Availability of old row versions for <command>UPDATE</command> and <command>DELETE</command> depends on the configured replica identity (see <xref linkend="sql-altertable-replica-identity"/>). ストリームに送出される更新データのフォーマットは、使用するプラグインで決まります。 サンプルプラグインがPostgreSQLの配布物に含まれています。 追加のプラグインを書くことにより、PostgreSQLのコア部分のコードを一切変更することなく、利用可能なフォーマットの選択肢を増やすことができます。 すべてのプラグインから、 INSERTによって作成された個々の新しい行と、UPDATEによって作成された新しい個々の行のバージョンにアクセスできます。 UPDATEDELETEによって生じた古いバージョンの行へのアクセスが可能かどうかは、 レプリカアイデンティティ(replica identity)の設定によって決まります(REPLICA IDENTITY参照)。

Changes can be consumed either using the streaming replication protocol (see <xref linkend="protocol-replication"/> and <xref linkend="logicaldecoding-walsender"/>), or by calling functions via SQL (see <xref linkend="logicaldecoding-sql"/>). It is also possible to write additional methods of consuming the output of a replication slot without modifying core code (see <xref linkend="logicaldecoding-writer"/>). 変更データの消費は、ストリーミングレプリケーションのプロトコル(55.449.3を参照)を使うか、SQL関数(49.4)を使って行います。 また、コア部分に手を入れなくても、レプリケーションスロットの出力を消費する別の方法を実装することもできます (49.7参照)。