mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Generic Messages for Logical Decoding
API and mechanism to allow generic messages to be inserted into WAL that are intended to be read by logical decoding plugins. This commit adds an optional new callback to the logical decoding API. Messages are either text or bytea. Messages can be transactional, or not, and are identified by a prefix to allow multiple concurrent decoding plugins. (Not to be confused with Generic WAL records, which are intended to allow crash recovery of extensible objects.) Author: Petr Jelinek and Andres Freund Reviewers: Artur Zakirov, Tomas Vondra, Simon Riggs Discussion: 5685F999.6010202@2ndquadrant.com
This commit is contained in:
@ -9,8 +9,8 @@ top_builddir = ../../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
OBJS = brindesc.o clogdesc.o committsdesc.o dbasedesc.o genericdesc.o \
|
||||
gindesc.o gistdesc.o hashdesc.o heapdesc.o mxactdesc.o nbtdesc.o \
|
||||
relmapdesc.o replorigindesc.o seqdesc.o smgrdesc.o spgdesc.o \
|
||||
standbydesc.o tblspcdesc.o xactdesc.o xlogdesc.o
|
||||
gindesc.o gistdesc.o hashdesc.o heapdesc.o logicalmsgdesc.o \
|
||||
mxactdesc.o nbtdesc.o relmapdesc.o replorigindesc.o seqdesc.o \
|
||||
smgrdesc.o spgdesc.o standbydesc.o tblspcdesc.o xactdesc.o xlogdesc.o
|
||||
|
||||
include $(top_srcdir)/src/backend/common.mk
|
||||
|
41
src/backend/access/rmgrdesc/logicalmsgdesc.c
Normal file
41
src/backend/access/rmgrdesc/logicalmsgdesc.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* logicalmsgdesc.c
|
||||
* rmgr descriptor routines for replication/logical/message.c
|
||||
*
|
||||
* Portions Copyright (c) 2015-2016, 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;
|
||||
|
||||
appendStringInfo(buf, "%s message size %zu bytes",
|
||||
xlrec->transactional ? "transactional" : "nontransactional",
|
||||
xlrec->message_size);
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
logicalmsg_identify(uint8 info)
|
||||
{
|
||||
if ((info & ~XLR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
|
||||
return "MESSAGE";
|
||||
|
||||
return NULL;
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
#include "commands/dbcommands_xlog.h"
|
||||
#include "commands/sequence.h"
|
||||
#include "commands/tablespace.h"
|
||||
#include "replication/message.h"
|
||||
#include "replication/origin.h"
|
||||
#include "storage/standby.h"
|
||||
#include "utils/relmapper.h"
|
||||
|
Reference in New Issue
Block a user