gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

311 行
13KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>52.9. Logical Replication Message Formats</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="protocol-error-fields.html" title="52.8. Error and Notice Message Fields" /><link rel="next" href="protocol-changes.html" title="52.10. Summary of Changes since Protocol 2.0" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.9. Logical Replication Message Formats</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="protocol-error-fields.html" title="52.8. Error and Notice Message Fields">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="protocol.html" title="Chapter 52. Frontend/Backend Protocol">Up</a></td><th width="60%" align="center">Chapter 52. Frontend/Backend Protocol</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="protocol-changes.html" title="52.10. Summary of Changes since Protocol 2.0">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.9. Logical Replication Message Formats</h2></div></div></div><p>
  3. This section describes the detailed format of each logical replication message.
  4. These messages are returned either by the replication slot SQL interface or are
  5. sent by a walsender. In case of a walsender they are encapsulated inside the replication
  6. protocol WAL messages as described in <a class="xref" href="protocol-replication.html" title="52.4. Streaming Replication Protocol">Section 52.4</a>
  7. and generally obey same message flow as physical replication.
  8. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  9. Begin
  10. </span></dt><dd><p>
  11. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  12. Byte1('B')
  13. </span></dt><dd><p>
  14. Identifies the message as a begin message.
  15. </p></dd><dt><span class="term">
  16. Int64
  17. </span></dt><dd><p>
  18. The final LSN of the transaction.
  19. </p></dd><dt><span class="term">
  20. Int64
  21. </span></dt><dd><p>
  22. Commit timestamp of the transaction. The value is in number
  23. of microseconds since PostgreSQL epoch (2000-01-01).
  24. </p></dd><dt><span class="term">
  25. Int32
  26. </span></dt><dd><p>
  27. Xid of the transaction.
  28. </p></dd></dl></div><p>
  29. </p></dd><dt><span class="term">
  30. Commit
  31. </span></dt><dd><p>
  32. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  33. Byte1('C')
  34. </span></dt><dd><p>
  35. Identifies the message as a commit message.
  36. </p></dd><dt><span class="term">
  37. Int8
  38. </span></dt><dd><p>
  39. Flags; currently unused (must be 0).
  40. </p></dd><dt><span class="term">
  41. Int64
  42. </span></dt><dd><p>
  43. The LSN of the commit.
  44. </p></dd><dt><span class="term">
  45. Int64
  46. </span></dt><dd><p>
  47. The end LSN of the transaction.
  48. </p></dd><dt><span class="term">
  49. Int64
  50. </span></dt><dd><p>
  51. Commit timestamp of the transaction. The value is in number
  52. of microseconds since PostgreSQL epoch (2000-01-01).
  53. </p></dd></dl></div><p>
  54. </p></dd><dt><span class="term">
  55. Origin
  56. </span></dt><dd><p>
  57. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  58. Byte1('O')
  59. </span></dt><dd><p>
  60. Identifies the message as an origin message.
  61. </p></dd><dt><span class="term">
  62. Int64
  63. </span></dt><dd><p>
  64. The LSN of the commit on the origin server.
  65. </p></dd><dt><span class="term">
  66. String
  67. </span></dt><dd><p>
  68. Name of the origin.
  69. </p></dd></dl></div><p>
  70. </p><p>
  71. Note that there can be multiple Origin messages inside a single transaction.
  72. </p></dd><dt><span class="term">
  73. Relation
  74. </span></dt><dd><p>
  75. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  76. Byte1('R')
  77. </span></dt><dd><p>
  78. Identifies the message as a relation message.
  79. </p></dd><dt><span class="term">
  80. Int32
  81. </span></dt><dd><p>
  82. ID of the relation.
  83. </p></dd><dt><span class="term">
  84. String
  85. </span></dt><dd><p>
  86. Namespace (empty string for <code class="literal">pg_catalog</code>).
  87. </p></dd><dt><span class="term">
  88. String
  89. </span></dt><dd><p>
  90. Relation name.
  91. </p></dd><dt><span class="term">
  92. Int8
  93. </span></dt><dd><p>
  94. Replica identity setting for the relation (same as
  95. <code class="structfield">relreplident</code> in <code class="structname">pg_class</code>).
  96. </p></dd><dt><span class="term">
  97. Int16
  98. </span></dt><dd><p>
  99. Number of columns.
  100. </p></dd></dl></div><p>
  101. Next, the following message part appears for each column (except generated columns):
  102. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  103. Int8
  104. </span></dt><dd><p>
  105. Flags for the column. Currently can be either 0 for no flags
  106. or 1 which marks the column as part of the key.
  107. </p></dd><dt><span class="term">
  108. String
  109. </span></dt><dd><p>
  110. Name of the column.
  111. </p></dd><dt><span class="term">
  112. Int32
  113. </span></dt><dd><p>
  114. ID of the column's data type.
  115. </p></dd><dt><span class="term">
  116. Int32
  117. </span></dt><dd><p>
  118. Type modifier of the column (<code class="structfield">atttypmod</code>).
  119. </p></dd></dl></div><p>
  120. </p></dd><dt><span class="term">
  121. Type
  122. </span></dt><dd><p>
  123. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  124. Byte1('Y')
  125. </span></dt><dd><p>
  126. Identifies the message as a type message.
  127. </p></dd><dt><span class="term">
  128. Int32
  129. </span></dt><dd><p>
  130. ID of the data type.
  131. </p></dd><dt><span class="term">
  132. String
  133. </span></dt><dd><p>
  134. Namespace (empty string for <code class="literal">pg_catalog</code>).
  135. </p></dd><dt><span class="term">
  136. String
  137. </span></dt><dd><p>
  138. Name of the data type.
  139. </p></dd></dl></div><p>
  140. </p></dd><dt><span class="term">
  141. Insert
  142. </span></dt><dd><p>
  143. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  144. Byte1('I')
  145. </span></dt><dd><p>
  146. Identifies the message as an insert message.
  147. </p></dd><dt><span class="term">
  148. Int32
  149. </span></dt><dd><p>
  150. ID of the relation corresponding to the ID in the relation
  151. message.
  152. </p></dd><dt><span class="term">
  153. Byte1('N')
  154. </span></dt><dd><p>
  155. Identifies the following TupleData message as a new tuple.
  156. </p></dd><dt><span class="term">
  157. TupleData
  158. </span></dt><dd><p>
  159. TupleData message part representing the contents of new tuple.
  160. </p></dd></dl></div><p>
  161. </p></dd><dt><span class="term">
  162. Update
  163. </span></dt><dd><p>
  164. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  165. Byte1('U')
  166. </span></dt><dd><p>
  167. Identifies the message as an update message.
  168. </p></dd><dt><span class="term">
  169. Int32
  170. </span></dt><dd><p>
  171. ID of the relation corresponding to the ID in the relation
  172. message.
  173. </p></dd><dt><span class="term">
  174. Byte1('K')
  175. </span></dt><dd><p>
  176. Identifies the following TupleData submessage as a key.
  177. This field is optional and is only present if
  178. the update changed data in any of the column(s) that are
  179. part of the REPLICA IDENTITY index.
  180. </p></dd><dt><span class="term">
  181. Byte1('O')
  182. </span></dt><dd><p>
  183. Identifies the following TupleData submessage as an old tuple.
  184. This field is optional and is only present if table in which
  185. the update happened has REPLICA IDENTITY set to FULL.
  186. </p></dd><dt><span class="term">
  187. TupleData
  188. </span></dt><dd><p>
  189. TupleData message part representing the contents of the old tuple
  190. or primary key. Only present if the previous 'O' or 'K' part
  191. is present.
  192. </p></dd><dt><span class="term">
  193. Byte1('N')
  194. </span></dt><dd><p>
  195. Identifies the following TupleData message as a new tuple.
  196. </p></dd><dt><span class="term">
  197. TupleData
  198. </span></dt><dd><p>
  199. TupleData message part representing the contents of a new tuple.
  200. </p></dd></dl></div><p>
  201. </p><p>
  202. The Update message may contain either a 'K' message part or an 'O' message part
  203. or neither of them, but never both of them.
  204. </p></dd><dt><span class="term">
  205. Delete
  206. </span></dt><dd><p>
  207. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  208. Byte1('D')
  209. </span></dt><dd><p>
  210. Identifies the message as a delete message.
  211. </p></dd><dt><span class="term">
  212. Int32
  213. </span></dt><dd><p>
  214. ID of the relation corresponding to the ID in the relation
  215. message.
  216. </p></dd><dt><span class="term">
  217. Byte1('K')
  218. </span></dt><dd><p>
  219. Identifies the following TupleData submessage as a key.
  220. This field is present if the table in which the delete has
  221. happened uses an index as REPLICA IDENTITY.
  222. </p></dd><dt><span class="term">
  223. Byte1('O')
  224. </span></dt><dd><p>
  225. Identifies the following TupleData message as a old tuple.
  226. This field is present if the table in which the delete has
  227. happened has REPLICA IDENTITY set to FULL.
  228. </p></dd><dt><span class="term">
  229. TupleData
  230. </span></dt><dd><p>
  231. TupleData message part representing the contents of the old tuple
  232. or primary key, depending on the previous field.
  233. </p></dd></dl></div><p>
  234. </p><p>
  235. The Delete message may contain either a 'K' message part or an 'O' message part,
  236. but never both of them.
  237. </p></dd><dt><span class="term">
  238. Truncate
  239. </span></dt><dd><p>
  240. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  241. Byte1('T')
  242. </span></dt><dd><p>
  243. Identifies the message as a truncate message.
  244. </p></dd><dt><span class="term">
  245. Int32
  246. </span></dt><dd><p>
  247. Number of relations
  248. </p></dd><dt><span class="term">
  249. Int8
  250. </span></dt><dd><p>
  251. Option bits for <code class="command">TRUNCATE</code>:
  252. 1 for <code class="literal">CASCADE</code>, 2 for <code class="literal">RESTART IDENTITY</code>
  253. </p></dd><dt><span class="term">
  254. Int32
  255. </span></dt><dd><p>
  256. ID of the relation corresponding to the ID in the relation
  257. message. This field is repeated for each relation.
  258. </p></dd></dl></div><p>
  259. </p></dd></dl></div><p>
  260. The following message parts are shared by the above messages.
  261. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  262. TupleData
  263. </span></dt><dd><p>
  264. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  265. Int16
  266. </span></dt><dd><p>
  267. Number of columns.
  268. </p></dd></dl></div><p>
  269. Next, one of the following submessages appears for each column (except generated columns):
  270. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  271. Byte1('n')
  272. </span></dt><dd><p>
  273. Identifies the data as NULL value.
  274. </p></dd></dl></div><p>
  275. Or
  276. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  277. Byte1('u')
  278. </span></dt><dd><p>
  279. Identifies unchanged TOASTed value (the actual value is not
  280. sent).
  281. </p></dd></dl></div><p>
  282. Or
  283. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  284. Byte1('t')
  285. </span></dt><dd><p>
  286. Identifies the data as text formatted value.
  287. </p></dd><dt><span class="term">
  288. Int32
  289. </span></dt><dd><p>
  290. Length of the column value.
  291. </p></dd><dt><span class="term">
  292. Byte<em class="replaceable"><code>n</code></em>
  293. </span></dt><dd><p>
  294. The value of the column, in text format. (A future release
  295. might support additional formats.)
  296. <em class="replaceable"><code>n</code></em> is the above length.
  297. </p></dd></dl></div><p>
  298. </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="protocol-error-fields.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="protocol.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="protocol-changes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.8. Error and Notice Message Fields </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 52.10. Summary of Changes since Protocol 2.0</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1