From 1ce643471d5f48f0a78302afa0aaad49c293b30c Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Wed, 20 Jul 2022 17:25:11 +0900
Subject: [PATCH] Improve description of XLOG_RUNNING_XACTS.

Previously, the description of XLOG_RUNNING_XACTS showed only
top-transaction XIDs and whether subtransactions are overflowed.
This commit improves it to show individual subtransaction XIDs.

This impacts the format of pg_waldump or anything using these
description routines, so no backpatch is done.
---
 src/backend/access/rmgrdesc/standbydesc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..426aabfbb5 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -32,7 +32,13 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
 			appendStringInfo(buf, " %u", xlrec->xids[i]);
 	}
 
-	if (xlrec->subxid_overflow)
+	if (xlrec->subxcnt > 0)
+	{
+		appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
+		for (i = 0; i < xlrec->subxcnt; i++)
+			appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
+	}
+	else if (xlrec->subxid_overflow)
 		appendStringInfoString(buf, "; subxid ovf");
 }
 
-- 
2.24.3 (Apple Git-128)

