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