PostgreSQL Source Code  git master
message.h File Reference
#include "access/xlog.h"
#include "access/xlogdefs.h"
#include "access/xlogreader.h"
Include dependency graph for message.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_logical_message
 

Macros

#define SizeOfLogicalMessage   (offsetof(xl_logical_message, message))
 
#define XLOG_LOGICAL_MESSAGE   0x00
 

Typedefs

typedef struct xl_logical_message xl_logical_message
 

Functions

XLogRecPtr LogLogicalMessage (const char *prefix, const char *message, size_t size, bool transactional)
 
void logicalmsg_redo (XLogReaderState *record)
 
void logicalmsg_desc (StringInfo buf, XLogReaderState *record)
 
const char * logicalmsg_identify (uint8 info)
 

Macro Definition Documentation

◆ SizeOfLogicalMessage

#define SizeOfLogicalMessage   (offsetof(xl_logical_message, message))

Definition at line 31 of file message.h.

Referenced by LogLogicalMessage().

◆ XLOG_LOGICAL_MESSAGE

#define XLOG_LOGICAL_MESSAGE   0x00

Typedef Documentation

◆ xl_logical_message

Function Documentation

◆ logicalmsg_desc()

void logicalmsg_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 19 of file logicalmsgdesc.c.

References appendStringInfo(), xl_logical_message::message_size, xl_logical_message::transactional, XLOG_LOGICAL_MESSAGE, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

20 {
21  char *rec = XLogRecGetData(record);
22  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
23 
24  if (info == XLOG_LOGICAL_MESSAGE)
25  {
26  xl_logical_message *xlrec = (xl_logical_message *) rec;
27 
28  appendStringInfo(buf, "%s message size %zu bytes",
29  xlrec->transactional ? "transactional" : "nontransactional",
30  xlrec->message_size);
31  }
32 }
unsigned char uint8
Definition: c.h:357
#define XLogRecGetData(decoder)
Definition: xlogreader.h:283
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:279
bool transactional
Definition: message.h:23
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37

◆ logicalmsg_identify()

const char* logicalmsg_identify ( uint8  info)

Definition at line 35 of file logicalmsgdesc.c.

References XLOG_LOGICAL_MESSAGE, and XLR_INFO_MASK.

36 {
37  if ((info & ~XLR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
38  return "MESSAGE";
39 
40  return NULL;
41 }
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37

◆ logicalmsg_redo()

void logicalmsg_redo ( XLogReaderState record)

Definition at line 80 of file message.c.

References elog, PANIC, XLOG_LOGICAL_MESSAGE, XLogRecGetInfo, and XLR_INFO_MASK.

81 {
82  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
83 
84  if (info != XLOG_LOGICAL_MESSAGE)
85  elog(PANIC, "logicalmsg_redo: unknown op code %u", info);
86 
87  /* This is only interesting for logical decoding, see decode.c. */
88 }
unsigned char uint8
Definition: c.h:357
#define PANIC
Definition: elog.h:53
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:279
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define elog(elevel,...)
Definition: elog.h:228
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37

◆ LogLogicalMessage()

XLogRecPtr LogLogicalMessage ( const char *  prefix,
const char *  message,
size_t  size,
bool  transactional 
)

Definition at line 46 of file message.c.

References Assert, xl_logical_message::dbId, GetCurrentTransactionId(), IsTransactionState(), xl_logical_message::message_size, MyDatabaseId, xl_logical_message::prefix_size, SizeOfLogicalMessage, xl_logical_message::transactional, unconstify, XLOG_INCLUDE_ORIGIN, XLOG_LOGICAL_MESSAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLogSetRecordFlags().

Referenced by pg_logical_emit_message_bytea().

48 {
49  xl_logical_message xlrec;
50 
51  /*
52  * Force xid to be allocated if we're emitting a transactional message.
53  */
54  if (transactional)
55  {
58  }
59 
60  xlrec.dbId = MyDatabaseId;
61  xlrec.transactional = transactional;
62  xlrec.prefix_size = strlen(prefix) + 1;
63  xlrec.message_size = size;
64 
66  XLogRegisterData((char *) &xlrec, SizeOfLogicalMessage);
67  XLogRegisterData(unconstify(char *, prefix), xlrec.prefix_size);
68  XLogRegisterData(unconstify(char *, message), size);
69 
70  /* allow origin filtering */
72 
73  return XLogInsert(RM_LOGICALMSG_ID, XLOG_LOGICAL_MESSAGE);
74 }
#define SizeOfLogicalMessage
Definition: message.h:31
#define XLOG_INCLUDE_ORIGIN
Definition: xlog.h:228
TransactionId GetCurrentTransactionId(void)
Definition: xact.c:422
void XLogSetRecordFlags(uint8 flags)
Definition: xloginsert.c:397
bool transactional
Definition: message.h:23
#define unconstify(underlying_type, expr)
Definition: c.h:1194
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
Oid MyDatabaseId
Definition: globals.c:85
#define Assert(condition)
Definition: c.h:739
bool IsTransactionState(void)
Definition: xact.c:355
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37
void XLogBeginInsert(void)
Definition: xloginsert.c:120