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

55.9. 論理レプリケーションのメッセージ書式 #

<title>Logical Replication Message Formats</title>

This section describes the detailed format of each logical replication message. These messages are either returned by the replication slot SQL interface or are sent by a walsender. In the case of a walsender, they are encapsulated inside replication protocol WAL messages as described in <xref linkend="protocol-replication"/>, and generally obey the same message flow as physical replication. 本節では論理レプリケーションの各メッセージの書式の詳細について説明します。 これらのメッセージはレプリケーションスロットのSQLインタフェースから返されるか、あるいはwalsenderから送信されるかのいずれかです。 walsenderの場合は、55.4で説明されているようにレプリケーションプロトコルのWALメッセージ内でカプセル化され、通常は物理レプリケーションと同じメッセージフローに従います。

Begin #
Byte1('B')

Identifies the message as a begin message. メッセージが開始メッセージであることを識別します。

Int64 (XLogRecPtr)

The final LSN of the transaction. トランザクションの最後のLSNです。

Int64 (TimestampTz)

Commit timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのコミット時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

Message #
Byte1('M')

Identifies the message as a logical decoding message. ロジカルデコーディングメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int8

Flags; Either 0 for no flags or 1 if the logical decoding message is transactional. フラグ。0はフラグなし、ロジカルデコーディングメッセージがトランザクションであれば1です。

Int64 (XLogRecPtr)

The LSN of the logical decoding message. ロジカルデコーディングメッセージのLSN。

String

The prefix of the logical decoding message. ロジカルデコーディングメッセージの接頭辞。

Int32

Length of the content. 内容の長さ。

Byten

The content of the logical decoding message. ロジカルデコーディングメッセージの内容。

Commit #
Byte1('C')

Identifies the message as a commit message. メッセージがCommitメッセージであることを識別します。

Int8(0)

Flags; currently unused. フラグ。 現在は使用されていません。

Int64 (XLogRecPtr)

The LSN of the commit. コミットのLSNです。

Int64 (XLogRecPtr)

The end LSN of the transaction. トランザクションの終了LSNです。

Int64 (TimestampTz)

Commit timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのコミット時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Origin #
Byte1('O')

Identifies the message as an origin message. メッセージがOriginメッセージであることを識別します。

Int64 (XLogRecPtr)

The LSN of the commit on the origin server. Originサーバ上のコミットのLSNです。

String

Name of the origin. Originの名前です。

Note that there can be multiple Origin messages inside a single transaction. 一つのトランザクション内で複数のOriginメッセージがあり得ることに注意してください。

Relation #
Byte1('R')

Identifies the message as a relation message. メッセージがRelationメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int32 (Oid)

OID of the relation. リレーションのOID。

String

Namespace (empty string for <literal>pg_catalog</literal>). 名前空間(pg_catalogの場合は空文字列)。

String

Relation name. リレーション名。

Int8

Replica identity setting for the relation (same as <structfield>relreplident</structfield> in <structname>pg_class</structname>). リレーションのレプリカ識別子の設定(pg_classrelreplidentと同じ)。

Int16

Number of columns. 列数。

Next, the following message part appears for each column included in the publication (except generated columns): 次に、パブリケーションを含む各列について以下のメッセージ部分があります。(生成列を除く)

Int8

Flags for the column. Currently can be either 0 for no flags or 1 which marks the column as part of the key. 列のフラグ。 現在は、フラグがないことを示す0か、列がキーの一部であることを示す1のいずれかにできます。

String

Name of the column. 列名。

Int32 (Oid)

OID of the column's data type. 列のデータ型のOID。

Int32

Type modifier of the column (<structfield>atttypmod</structfield>). 列の型修飾子(atttypmod)。

Type #
Byte1('Y')

Identifies the message as a type message. メッセージがTypeメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int32 (Oid)

OID of the data type. データ型のOID。

String

Namespace (empty string for <literal>pg_catalog</literal>). 名前空間(pg_catalogの場合は空文字列)。

String

Name of the data type. データ型の名前。

Insert #
Byte1('I')

Identifies the message as an insert message. メッセージがInsertメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int32 (Oid)

OID of the relation corresponding to the ID in the relation message. Relationメッセージ中のIDに対応するリレーションのOID。

Byte1('N')

Identifies the following TupleData message as a new tuple. 以下のTupleDataメッセージが新しいタプルであることを識別します。

TupleData

TupleData message part representing the contents of new tuple. 新しいタプルの内容を表すTupleDataメッセージ部分です。

Update #
Byte1('U')

Identifies the message as an update message. メッセージがUpdateメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int32 (Oid)

OID of the relation corresponding to the ID in the relation message. Relationメッセージ中のIDに対応するリレーションのOID。

Byte1('K')

Identifies the following TupleData submessage as a key. This field is optional and is only present if the update changed data in any of the column(s) that are part of the REPLICA IDENTITY index. これに続くTupleData副メッセージがキーであることを識別します。 このフィールドはオプションで、UPDATEがREPLICA IDENTITYインデックスの一部となっている列のどれかを変更したときにのみ存在します。

Byte1('O')

Identifies the following TupleData submessage as an old tuple. This field is optional and is only present if table in which the update happened has REPLICA IDENTITY set to FULL. これに続くTupleData副メッセージが古いタプルであることを識別します。 このフィールドはオプションで、UPDATEが発生したテーブルでREPLICA IDENTITYがFULLに設定されている場合にのみ存在します。

TupleData

TupleData message part representing the contents of the old tuple or primary key. Only present if the previous 'O' or 'K' part is present. 古いタプルまたは主キーの内容を表すTupleDataメッセージ部分です。 この前に'O'または'K'の部分が存在するときにのみ存在します。

Byte1('N')

Identifies the following TupleData message as a new tuple. 以下のTupleDataメッセージが新しいタプルであることを識別します。

TupleData

TupleData message part representing the contents of a new tuple. 新しいタプルの内容を表すTupleDataメッセージ部分です。

The Update message may contain either a 'K' message part or an 'O' message part or neither of them, but never both of them. Updateメッセージは'K'メッセージ部分と'O'メッセージ部分のいずれかを含むか、どちらも含まないかであり、その両方を含むことはできません。

Delete #
Byte1('D')

Identifies the message as a delete message. メッセージがDeleteメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int32 (Oid)

OID of the relation corresponding to the ID in the relation message. Relationメッセージ中のIDに対応するリレーションのOID。

Byte1('K')

Identifies the following TupleData submessage as a key. This field is present if the table in which the delete has happened uses an index as REPLICA IDENTITY. これに続くTupleData副メッセージがキーであることを識別します。 このフィールドはDELETEが発生したテーブルがインデックスをREPLICA IDENTITYとして使用している場合にのみ存在します。

Byte1('O')

Identifies the following TupleData message as an old tuple. This field is present if the table in which the delete happened has REPLICA IDENTITY set to FULL. これに続くTupleDataメッセージが古いタプルであることを識別します。 このフィールドはDELETEが発生したテーブルでREPLICA IDENTITYがFULLに設定されている場合にのみ存在します。

TupleData

TupleData message part representing the contents of the old tuple or primary key, depending on the previous field. 直前のフィールドに従って、古いタプルまたは主キーの内容を表すTupleDataメッセージ部分です。

The Delete message may contain either a 'K' message part or an 'O' message part, but never both of them. Deleteメッセージは'K'メッセージ部分と'O'メッセージ部分のいずれかを含みますが、両方を含むことはできません。

Truncate #
Byte1('T')

Identifies the message as a truncate message. メッセージをTruncateメッセージと識別します。

Int32 (TransactionId)

Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2. トランザクションのxid(ストリームトランザクションのためにのみ存在します)。 このフィールドはプロトコルバージョン2以降で利用可能です。

Int32

Number of relations リレーション数

Int8

Option bits for <command>TRUNCATE</command>: 1 for <literal>CASCADE</literal>, 2 for <literal>RESTART IDENTITY</literal> TRUNCATEに対するオプションビット。1はCASCADE、2はRESTART IDENTITY

Int32 (Oid)

OID of the relation corresponding to the ID in the relation message. This field is repeated for each relation. リレーションメッセージのIDに一致するリレーションのOID。 このフィールドは各リレーション毎に繰り返されます。

The following messages (Stream Start, Stream Stop, Stream Commit, and Stream Abort) are available since protocol version 2. 次のメッセージ(Stream Start、Stream Stop、Stream Commit、Stream Abort)はプロトコルバージョン2以降で利用可能です。

Stream Start #
Byte1('S')

Identifies the message as a stream start message. メッセージがストリーム開始メッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

Int8

A value of 1 indicates this is the first stream segment for this XID, 0 for any other stream segment. 値が1ならこのXIDの最初のストリームセグメントであることを、0なら他のストリームセグメントであることを識別します。

Stream Stop #
Byte1('E')

Identifies the message as a stream stop message. メッセージがストリーム停止メッセージであることを識別します。

Stream Commit #
Byte1('c')

Identifies the message as a stream commit message. メッセージがストリームコミットメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

Int8(0)

Flags; currently unused. フラグ。 現在は使用されていません。

Int64 (XLogRecPtr)

The LSN of the commit. コミットのLSNです。

Int64 (XLogRecPtr)

The end LSN of the transaction. トランザクションの終了LSNです。

Int64 (TimestampTz)

Commit timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのコミット時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Stream Abort #
Byte1('A')

Identifies the message as a stream abort message. メッセージがストリームアボートメッセージであることを識別します。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

Int32 (TransactionId)

Xid of the subtransaction (will be same as xid of the transaction for top-level transactions). サブトラクションxid(トップレベルのトランザクションのxidと同じものになるでしょう)。

Int64 (XLogRecPtr)

The LSN of the abort. This field is available since protocol version 4. LSNのアボート。 このフィールドはプロトコルバージョン4以降で使用できます。

Int64 (TimestampTz)

Abort timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). This field is available since protocol version 4. トランザクションのアボート時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。 このフィールドはプロトコルバージョン4以降で使用可能です。

The following messages (Begin Prepare, Prepare, Commit Prepared, Rollback Prepared, Stream Prepare) are available since protocol version 3. 次のメッセージ(Begin Prepare、Prepare、 Commit Prepared、Rollback Prepared、Stream Prepare)はプロトコルバージョン3以降で利用可能です。

Begin Prepare #
Byte1('b')

Identifies the message as the beginning of a prepared transaction message. メッセージがプリペアドトランザクションメッセージの先頭であることを識別します。

Int64 (XLogRecPtr)

The LSN of the prepare. プリペアドのLSNです。

Int64 (XLogRecPtr)

The end LSN of the prepared transaction. プリペアドトランザクションの終了LSNです。

Int64 (TimestampTz)

Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのプリペアド(準備された)時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

String

The user defined GID of the prepared transaction. プリペアドトランザクションのユーザ定義GIDです。

Prepare #
Byte1('P')

Identifies the message as a prepared transaction message. メッセージがプリペアドトランザクションメッセージであることを識別します。

Int8(0)

Flags; currently unused. フラグ。 現在は使用されていません。

Int64 (XLogRecPtr)

The LSN of the prepare. プリペアドのLSNです。

Int64 (XLogRecPtr)

The end LSN of the prepared transaction. プリペアドトランザクションの終了LSNです。

Int64 (TimestampTz)

Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのプリペアド(準備された)時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

String

The user defined GID of the prepared transaction. プリペアドトランザクションのユーザ定義GIDです。

Commit Prepared #
Byte1('K')

Identifies the message as the commit of a prepared transaction message. メッセージがプリペアドトランザクションメッセージのコミットであることを識別します。

Int8(0)

Flags; currently unused. フラグ。 現在は使用されていません。

Int64 (XLogRecPtr)

The LSN of the commit of the prepared transaction. プリペアドトランザクションのコミットのLSNです。

Int64 (XLogRecPtr)

The end LSN of the commit of the prepared transaction. プリペアドトランザクションのコミットの終了LSNです。

Int64 (TimestampTz)

Commit timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのコミット時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

String

The user defined GID of the prepared transaction. プリペアドトランザクションのユーザ定義GIDです。

Rollback Prepared #
Byte1('r')

Identifies the message as the rollback of a prepared transaction message. メッセージがプリペアドトランザクションメッセージのロールバックであることを識別します。

Int8(0)

Flags; currently unused. フラグ。 現在は使用されていません。

Int64 (XLogRecPtr)

The end LSN of the prepared transaction. プリペアドトランザクションの終了LSNです。

Int64 (XLogRecPtr)

The end LSN of the rollback of the prepared transaction. プリペアドトランザクションのロールバックの終了LSNです。

Int64 (TimestampTz)

Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのプリペアド(準備された)時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int64 (TimestampTz)

Rollback timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのロールバック時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

String

The user defined GID of the prepared transaction. プリペアドトランザクションのユーザ定義GIDです。

Stream Prepare #
Byte1('p')

Identifies the message as a stream prepared transaction message. メッセージがストリーム準備トランザクションメッセージであることを識別します。

Int8(0)

Flags; currently unused. フラグ。 現在は使用されていません。

Int64 (XLogRecPtr)

The LSN of the prepare. プリペアドのLSNです。

Int64 (XLogRecPtr)

The end LSN of the prepared transaction. プリペアドトランザクションの終了LSNです。

Int64 (TimestampTz)

Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01). トランザクションのプリペアド(準備された)時刻です。 その値はPostgreSQLのエポック(2000-01-01)からのマイクロ秒数です。

Int32 (TransactionId)

Xid of the transaction. トランザクションのXIDです。

String

The user defined GID of the prepared transaction. プリペアドトランザクションのユーザ定義GIDです。

The following message parts are shared by the above messages. 以下のメッセージ部分は上記のメッセージに共通です。

TupleData #
Int16

Number of columns. 列数。

Next, one of the following submessages appears for each column (except generated columns): 次に、各カラム(生成されたカラムを除く)に対して、以下のサブメッセージのいずれかが表示されます。

Byte1('n')

Identifies the data as NULL value. データをNULL値として識別します。

Or

Byte1('u')

Identifies unchanged TOASTed value (the actual value is not sent). TOAST値が変更されないことを識別します(実際の値は送信されません)。

Or

Byte1('t')

Identifies the data as text formatted value. データがテキスト形式の値であることを識別します。

Or

Byte1('b')

Identifies the data as binary formatted value. データがバイナリフォーマット値であることを識別します。

Int32

Length of the column value. 列値の長さ。

Byten

The value of the column, either in binary or in text format. (As specified in the preceding format byte). <replaceable>n</replaceable> is the above length. テキスト形式あるいはバイナリ形式での列の値。 (先行するフォーマットバイトで指定されます。) nは上記の長さです。