PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
logicalmsgdesc.c File Reference
#include "postgres.h"
#include "replication/message.h"
Include dependency graph for logicalmsgdesc.c:

Go to the source code of this file.

Functions

void logicalmsg_desc (StringInfo buf, XLogReaderState *record)
 
const char * logicalmsg_identify (uint8 info)
 

Function Documentation

◆ logicalmsg_desc()

void logicalmsg_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 19 of file logicalmsgdesc.c.

20{
21 char *rec = XLogRecGetData(record);
22 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
23
24 if (info == XLOG_LOGICAL_MESSAGE)
25 {
27 char *prefix = xlrec->message;
28 char *message = xlrec->message + xlrec->prefix_size;
29 char *sep = "";
30
31 Assert(prefix[xlrec->prefix_size - 1] == '\0');
32
33 appendStringInfo(buf, "%s, prefix \"%s\"; payload (%zu bytes): ",
34 xlrec->transactional ? "transactional" : "non-transactional",
35 prefix, xlrec->message_size);
36 /* Write message payload as a series of hex bytes */
37 for (int cnt = 0; cnt < xlrec->message_size; cnt++)
38 {
39 appendStringInfo(buf, "%s%02X", sep, (unsigned char) message[cnt]);
40 sep = " ";
41 }
42 }
43}
uint8_t uint8
Definition: c.h:500
Assert(PointerIsAligned(start, uint64))
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
bool transactional
Definition: message.h:23
char message[FLEXIBLE_ARRAY_MEMBER]
Definition: message.h:27
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415

References appendStringInfo(), Assert(), buf, xl_logical_message::message, xl_logical_message::message_size, xl_logical_message::prefix_size, xl_logical_message::transactional, XLOG_LOGICAL_MESSAGE, XLogRecGetData, and XLogRecGetInfo.

◆ logicalmsg_identify()

const char * logicalmsg_identify ( uint8  info)

Definition at line 46 of file logicalmsgdesc.c.

47{
48 if ((info & ~XLR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
49 return "MESSAGE";
50
51 return NULL;
52}
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References XLOG_LOGICAL_MESSAGE, and XLR_INFO_MASK.