PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
message.c File Reference
#include "postgres.h"
#include "miscadmin.h"
#include "access/xact.h"
#include "catalog/indexing.h"
#include "nodes/execnodes.h"
#include "replication/message.h"
#include "replication/logical.h"
#include "utils/memutils.h"
Include dependency graph for message.c:

Go to the source code of this file.

Functions

XLogRecPtr LogLogicalMessage (const char *prefix, const char *message, size_t size, bool transactional)
 
void logicalmsg_redo (XLogReaderState *record)
 

Function Documentation

void logicalmsg_redo ( XLogReaderState record)

Definition at line 85 of file message.c.

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

86 {
87  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
88 
89  if (info != XLOG_LOGICAL_MESSAGE)
90  elog(PANIC, "logicalmsg_redo: unknown op code %u", info);
91 
92  /* This is only interesting for logical decoding, see decode.c. */
93 }
unsigned char uint8
Definition: c.h:266
#define PANIC
Definition: elog.h:53
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:214
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37
#define elog
Definition: elog.h:219
XLogRecPtr LogLogicalMessage ( const char *  prefix,
const char *  message,
size_t  size,
bool  transactional 
)

Definition at line 51 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, XLOG_INCLUDE_ORIGIN, XLOG_LOGICAL_MESSAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLogSetRecordFlags().

Referenced by pg_logical_emit_message_bytea().

53 {
54  xl_logical_message xlrec;
55 
56  /*
57  * Force xid to be allocated if we're emitting a transactional message.
58  */
59  if (transactional)
60  {
63  }
64 
65  xlrec.dbId = MyDatabaseId;
66  xlrec.transactional = transactional;
67  xlrec.prefix_size = strlen(prefix) + 1;
68  xlrec.message_size = size;
69 
71  XLogRegisterData((char *) &xlrec, SizeOfLogicalMessage);
72  XLogRegisterData((char *) prefix, xlrec.prefix_size);
73  XLogRegisterData((char *) message, size);
74 
75  /* allow origin filtering */
77 
78  return XLogInsert(RM_LOGICALMSG_ID, XLOG_LOGICAL_MESSAGE);
79 }
#define SizeOfLogicalMessage
Definition: message.h:31
#define XLOG_INCLUDE_ORIGIN
Definition: xlog.h:192
TransactionId GetCurrentTransactionId(void)
Definition: xact.c:417
void XLogSetRecordFlags(uint8 flags)
Definition: xloginsert.c:397
bool transactional
Definition: message.h:23
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:76
#define Assert(condition)
Definition: c.h:675
bool IsTransactionState(void)
Definition: xact.c:350
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37
void XLogBeginInsert(void)
Definition: xloginsert.c:120