From 17b836a4aa926eb0a68cdc6edc356595a60d3424 Mon Sep 17 00:00:00 2001
From: Atsushi Torikoshi <torikoshia@oss.nttdata.com>
Date: Tue, 24 Nov 2026 09:20:52 +0900
Subject: [PATCH v4] Correct documentation of logical decoding message LSN

The documentation describes the LSN of a logical decoding message as
the WAL location of the message, implying the start LSN of its WAL
record. In fact, both the message callback and the logical replication
protocol report the end LSN. Correct both descriptions to state this
explicitly.

This difference may matter to logical decoding consumers, for example,
those that persist the LSN of decoded changes and use it to determine
where to resume after an unexpected interruption. Unlike DML changes,
a logical message is reported with the end LSN of its WAL record, so
such consumers may need special handling for logical messages when
determining the resume position.
---
 doc/src/sgml/logicaldecoding.sgml | 8 ++++----
 doc/src/sgml/protocol.sgml        | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml
index 6dc49108997..8c9efc9fe95 100644
--- a/doc/src/sgml/logicaldecoding.sgml
+++ b/doc/src/sgml/logicaldecoding.sgml
@@ -1138,10 +1138,10 @@ typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx,
       the transaction, like the time stamp at which it has been committed and
       its XID. Note however that it can be NULL when the message is
       non-transactional and the XID was not assigned yet in the transaction
-      which logged the message. The <parameter>lsn</parameter> has WAL
-      location of the message. The <parameter>transactional</parameter> says
-      if the message was sent as transactional or not. Similar to the change
-      callback, in case of decoding a prepared (but yet uncommitted)
+      which logged the message. The <parameter>message_lsn</parameter> is
+      the end LSN of the message. The <parameter>transactional</parameter>
+      says if the message was sent as transactional or not. Similar to the
+      change callback, in case of decoding a prepared (but yet uncommitted)
       transaction or decoding of an uncommitted transaction, this message
       callback might also error out due to simultaneous rollback of
       this very same transaction. In that case, the logical decoding of this
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 50ce1cbdb32..a67e7c2eb20 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -6687,7 +6687,7 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
        <term>Int64 (XLogRecPtr)</term>
        <listitem>
         <para>
-         The LSN of the logical decoding message.
+         The end LSN of the logical decoding message.
         </para>
        </listitem>
       </varlistentry>
-- 
2.48.1

