Coverage Report

Created: 2025-06-13 06:06

/src/postgres/src/backend/access/rmgrdesc/logicalmsgdesc.c
Line
Count
Source (jump to first uncovered line)
1
/*-------------------------------------------------------------------------
2
 *
3
 * logicalmsgdesc.c
4
 *    rmgr descriptor routines for replication/logical/message.c
5
 *
6
 * Portions Copyright (c) 2015-2025, PostgreSQL Global Development Group
7
 *
8
 *
9
 * IDENTIFICATION
10
 *    src/backend/access/rmgrdesc/logicalmsgdesc.c
11
 *
12
 *-------------------------------------------------------------------------
13
 */
14
#include "postgres.h"
15
16
#include "replication/message.h"
17
18
void
19
logicalmsg_desc(StringInfo buf, XLogReaderState *record)
20
0
{
21
0
  char     *rec = XLogRecGetData(record);
22
0
  uint8   info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
23
24
0
  if (info == XLOG_LOGICAL_MESSAGE)
25
0
  {
26
0
    xl_logical_message *xlrec = (xl_logical_message *) rec;
27
0
    char     *prefix = xlrec->message;
28
0
    char     *message = xlrec->message + xlrec->prefix_size;
29
0
    char     *sep = "";
30
31
0
    Assert(prefix[xlrec->prefix_size - 1] == '\0');
32
33
0
    appendStringInfo(buf, "%s, prefix \"%s\"; payload (%zu bytes): ",
34
0
             xlrec->transactional ? "transactional" : "non-transactional",
35
0
             prefix, xlrec->message_size);
36
    /* Write message payload as a series of hex bytes */
37
0
    for (int cnt = 0; cnt < xlrec->message_size; cnt++)
38
0
    {
39
0
      appendStringInfo(buf, "%s%02X", sep, (unsigned char) message[cnt]);
40
0
      sep = " ";
41
0
    }
42
0
  }
43
0
}
44
45
const char *
46
logicalmsg_identify(uint8 info)
47
0
{
48
0
  if ((info & ~XLR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
49
0
    return "MESSAGE";
50
51
0
  return NULL;
52
0
}