mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Allow pgoutput to send logical decoding messages.
The output plugin accepts a new parameter (messages) that controls if logical decoding messages are written into the replication stream. It is useful for those clients that use pgoutput as an output plugin and needs to process messages that were written by pg_logical_emit_message(). Although logical streaming replication protocol supports logical decoding messages now, logical replication does not use this feature yet. Author: David Pirotte, Euler Taveira Reviewed-by: Euler Taveira, Andres Freund, Ashutosh Bapat, Amit Kapila Discussion: https://postgr.es/m/CADK3HHJ-+9SO7KuRLH=9Wa1rAo60Yreq1GFNkH_kd0=CdaWM+A@mail.gmail.com
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
#define LOGICALREP_IS_REPLICA_IDENTITY 1
|
||||
|
||||
#define MESSAGE_TRANSACTIONAL (1<<0)
|
||||
#define TRUNCATE_CASCADE (1<<0)
|
||||
#define TRUNCATE_RESTART_SEQS (1<<1)
|
||||
|
||||
@@ -361,6 +362,33 @@ logicalrep_read_truncate(StringInfo in,
|
||||
return relids;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write MESSAGE to stream
|
||||
*/
|
||||
void
|
||||
logicalrep_write_message(StringInfo out, TransactionId xid, XLogRecPtr lsn,
|
||||
bool transactional, const char *prefix, Size sz,
|
||||
const char *message)
|
||||
{
|
||||
uint8 flags = 0;
|
||||
|
||||
pq_sendbyte(out, LOGICAL_REP_MSG_MESSAGE);
|
||||
|
||||
/* encode and send message flags */
|
||||
if (transactional)
|
||||
flags |= MESSAGE_TRANSACTIONAL;
|
||||
|
||||
/* transaction ID (if not valid, we're not streaming) */
|
||||
if (TransactionIdIsValid(xid))
|
||||
pq_sendint32(out, xid);
|
||||
|
||||
pq_sendint8(out, flags);
|
||||
pq_sendint64(out, lsn);
|
||||
pq_sendstring(out, prefix);
|
||||
pq_sendint32(out, sz);
|
||||
pq_sendbytes(out, message, sz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write relation description to the output stream.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user