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

49.10. ロジカルデコーディングための2相コミット #

<title>Two-phase Commit Support for Logical Decoding</title>

With the basic output plugin callbacks (eg., <function>begin_cb</function>, <function>change_cb</function>, <function>commit_cb</function> and <function>message_cb</function>) two-phase commit commands like <command>PREPARE TRANSACTION</command>, <command>COMMIT PREPARED</command> and <command>ROLLBACK PREPARED</command> are not decoded. While the <command>PREPARE TRANSACTION</command> is ignored, <command>COMMIT PREPARED</command> is decoded as a <command>COMMIT</command> and <command>ROLLBACK PREPARED</command> is decoded as a <command>ROLLBACK</command>. 基本的な出力プラグインコールバック(例えば、begin_cbchange_cbcommit_cbmessage_cb)では、PREPARE TRANSACTIONCOMMIT PREPAREDROLLBACK PREPAREDのような2相コミットコマンドはデコードされません。 PREPARE TRANSACTIONは無視されますが、COMMIT PREPAREDCOMMITとしてデコードされ、ROLLBACK PREPAREDROLLBACKとしてデコードされます。

To support the streaming of two-phase commands, an output plugin needs to provide additional callbacks. There are multiple two-phase commit callbacks that are required, (<function>begin_prepare_cb</function>, <function>prepare_cb</function>, <function>commit_prepared_cb</function>, <function>rollback_prepared_cb</function> and <function>stream_prepare_cb</function>) and an optional callback (<function>filter_prepare_cb</function>). 2相コマンドのストリーミングをサポートするために、出力プラグインは追加のコールバックを提供する必要があります。 複数の必要な2相コミットコールバック(begin_prepare_cbprepare_cbcommit_prepared_cbrollback_prepared_cbstream_prepare_cb)とオプションのコールバック(filter_prepare_cb)があります。

If the output plugin callbacks for decoding two-phase commit commands are provided, then on <command>PREPARE TRANSACTION</command>, the changes of that transaction are decoded, passed to the output plugin, and the <function>prepare_cb</function> callback is invoked. This differs from the basic decoding setup where changes are only passed to the output plugin when a transaction is committed. The start of a prepared transaction is indicated by the <function>begin_prepare_cb</function> callback. 2相コミットコマンドをデコードするための出力プラグインコールバックが提供されている場合、PREPARE TRANSACTIONで、そのトランザクションの変更がデコードされ、出力プラグインに渡され、prepare_cbコールバックが呼び出されます。 これは、トランザクションがコミットされたときにのみ変更が出力プラグインに渡される基本的なデコード設定とは異なります。 準備されたトランザクションの開始は、begin_prepare_cbコールバックによって示されます。

When a prepared transaction is rolled back using the <command>ROLLBACK PREPARED</command>, then the <function>rollback_prepared_cb</function> callback is invoked and when the prepared transaction is committed using <command>COMMIT PREPARED</command>, then the <function>commit_prepared_cb</function> callback is invoked. 準備されたトランザクションがROLLBACK PREPAREDを使用してロールバックされると、rollback_prepared_cbコールバックが呼び出されます。 準備されたトランザクションがCOMMIT PREPAREDを使用してコミットされると、commit_prepared_cbコールバックが呼び出されます。

Optionally the output plugin can define filtering rules via <function>filter_prepare_cb</function> to decode only specific transaction in two phases. This can be achieved by pattern matching on the <parameter>gid</parameter> or via lookups using the <parameter>xid</parameter>. オプションで、出力プラグインはfilter_prepare_cbを使ってフィルタリング規則を定義し、特定のトランザクションのみを2つの相でデコードすることができます。 これはgidでパターンマッチングを行うか、xidを使って検索することで実現できます。

The users that want to decode prepared transactions need to be careful about below mentioned points: 準備されたトランザクションをデコードしようとするユーザは、以下の点に注意する必要があります。