Home Explore Blog CI



postgresql

16th chunk of `doc/src/sgml/logicaldecoding.sgml`
43e5bf20d8d0404ae006b70a9a94a0e5164a5c65a32543120000000100000fad
 for all modified
      rows will have been called before this, if there have been any modified
      rows. The <parameter>gid</parameter> field, which is part of the
      <parameter>txn</parameter> parameter, can be used in this callback.
<programlisting>
typedef void (*LogicalDecodePrepareCB) (struct LogicalDecodingContext *ctx,
                                        ReorderBufferTXN *txn,
                                        XLogRecPtr prepare_lsn);
</programlisting>
     </para>
    </sect3>

    <sect3 id="logicaldecoding-output-plugin-commit-prepared">
     <title>Transaction Commit Prepared Callback</title>

     <para>
      The required <function>commit_prepared_cb</function> callback is called
      whenever a transaction <command>COMMIT PREPARED</command> has been decoded.
      The <parameter>gid</parameter> field, which is part of the
      <parameter>txn</parameter> parameter, can be used in this callback.
<programlisting>
typedef void (*LogicalDecodeCommitPreparedCB) (struct LogicalDecodingContext *ctx,
                                               ReorderBufferTXN *txn,
                                               XLogRecPtr commit_lsn);
</programlisting>
     </para>
    </sect3>

    <sect3 id="logicaldecoding-output-plugin-rollback-prepared">
     <title>Transaction Rollback Prepared Callback</title>

     <para>
      The required <function>rollback_prepared_cb</function> callback is called
      whenever a transaction <command>ROLLBACK PREPARED</command> has been
      decoded. The <parameter>gid</parameter> field, which is part of the
      <parameter>txn</parameter> parameter, can be used in this callback. The
      parameters <parameter>prepare_end_lsn</parameter> and
      <parameter>prepare_time</parameter> can be used to check if the plugin
      has received this <command>PREPARE TRANSACTION</command> in which case
      it can apply the rollback, otherwise, it can skip the rollback operation. The
      <parameter>gid</parameter> alone is not sufficient because the downstream
      node can have a prepared transaction with same identifier.
<programlisting>
typedef void (*LogicalDecodeRollbackPreparedCB) (struct LogicalDecodingContext *ctx,
                                                 ReorderBufferTXN *txn,
                                                 XLogRecPtr prepare_end_lsn,
                                                 TimestampTz prepare_time);
</programlisting>
     </para>
    </sect3>

    <sect3 id="logicaldecoding-output-plugin-stream-start">
     <title>Stream Start Callback</title>
     <para>
      The required <function>stream_start_cb</function> callback is called when
      opening a block of streamed changes from an in-progress transaction.
<programlisting>
typedef void (*LogicalDecodeStreamStartCB) (struct LogicalDecodingContext *ctx,
                                            ReorderBufferTXN *txn);
</programlisting>
     </para>
    </sect3>

    <sect3 id="logicaldecoding-output-plugin-stream-stop">
     <title>Stream Stop Callback</title>
     <para>
      The required <function>stream_stop_cb</function> callback is called when
      closing a block of streamed changes from an in-progress transaction.
<programlisting>
typedef void (*LogicalDecodeStreamStopCB) (struct LogicalDecodingContext *ctx,
                                           ReorderBufferTXN *txn);
</programlisting>
     </para>
    </sect3>

    <sect3 id="logicaldecoding-output-plugin-stream-abort">
     <title>Stream Abort Callback</title>
     <para>
      The required <function>stream_abort_cb</function> callback is called to
      abort a previously streamed transaction.
<programlisting>
typedef void (*LogicalDecodeStreamAbortCB) (struct LogicalDecodingContext *ctx,
                                            ReorderBufferTXN *txn,
                                            XLogRecPtr abort_lsn);
</programlisting>
     </para>
    </sect3>

    <sect3 id="logicaldecoding-output-plugin-stream-prepare">

Title: Logical Decoding Output Plugin Callbacks for Transaction Management and Streaming
Summary
This section describes several callbacks for logical decoding output plugins related to transaction management and streaming, including commit prepared, rollback prepared, stream start, stream stop, stream abort, and others, which allow plugins to handle various stages of transactions and streaming changes.