From 93e6e40574bccf9c6f33c520a4189d3e98e2fd1f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 15 Feb 2017 18:15:47 -0500 Subject: [PATCH] Formatting and docs corrections for logical decoding output plugins. Make the typedefs for output plugins consistent with project style; they were previously not even consistent with each other as to layout or inclusion of parameter names. Make the documentation look the same, and fix errors therein (missing and misdescribed parameters). Back-patch because of the documentation bugs. --- doc/src/sgml/logicaldecoding.sgml | 59 ++++++++++--------------- src/include/replication/output_plugin.h | 33 +++++--------- 2 files changed, 35 insertions(+), 57 deletions(-) diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml index 6e7517d04d..03c2c691d1 100644 --- a/doc/src/sgml/logicaldecoding.sgml +++ b/doc/src/sgml/logicaldecoding.sgml @@ -380,7 +380,7 @@ typedef struct OutputPluginCallbacks LogicalDecodeShutdownCB shutdown_cb; } OutputPluginCallbacks; -typedef void (*LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb); +typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb); The begin_cb, change_cb and commit_cb callbacks are required, @@ -465,11 +465,9 @@ CREATE TABLE another_catalog_table(data text) WITH (user_catalog_table = true); a replication slot is created or asked to stream changes, independent of the number of changes that are ready to be put out. -typedef void (*LogicalDecodeStartupCB) ( - struct LogicalDecodingContext *ctx, - OutputPluginOptions *options, - bool is_init -); +typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx, + OutputPluginOptions *options, + bool is_init); The is_init parameter will be true when the replication slot is being created and false @@ -504,9 +502,7 @@ typedef struct OutputPluginOptions be used to deallocate resources private to the output plugin. The slot isn't necessarily being dropped, streaming is just being stopped. -typedef void (*LogicalDecodeShutdownCB) ( - struct LogicalDecodingContext *ctx -); +typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx); @@ -519,10 +515,8 @@ typedef void (*LogicalDecodeShutdownCB) ( start of a committed transaction has been decoded. Aborted transactions and their contents never get decoded. -typedef void (*LogicalDecodeBeginCB) ( - struct LogicalDecodingContext *, - ReorderBufferTXN *txn -); +typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx, + ReorderBufferTXN *txn); The txn parameter contains meta information about the transaction, like the time stamp at which it has been committed and @@ -540,10 +534,9 @@ typedef void (*LogicalDecodeBeginCB) ( rows will have been called before this, if there have been any modified rows. -typedef void (*LogicalDecodeCommitCB) ( - struct LogicalDecodingContext *, - ReorderBufferTXN *txn -); +typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, + XLogRecPtr commit_lsn); @@ -559,12 +552,10 @@ typedef void (*LogicalDecodeCommitCB) ( several rows at once the callback will be called individually for each row. -typedef void (*LogicalDecodeChangeCB) ( - struct LogicalDecodingContext *ctx, - ReorderBufferTXN *txn, - Relation relation, - ReorderBufferChange *change -); +typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, + Relation relation, + ReorderBufferChange *change); The ctx and txn parameters have the same contents as for the begin_cb @@ -594,10 +585,8 @@ typedef void (*LogicalDecodeChangeCB) ( from origin_id is of interest to the output plugin. -typedef bool (*LogicalDecodeFilterByOriginCB) ( - struct LogicalDecodingContext *ctx, - RepNodeId origin_id -); +typedef bool (*LogicalDecodeFilterByOriginCB) (struct LogicalDecodingContext *ctx, + RepOriginId origin_id); The ctx parameter has the same contents as for the other callbacks. No information but the origin is @@ -623,15 +612,13 @@ typedef bool (*LogicalDecodeFilterByOriginCB) ( The optional message_cb callback is called whenever a logical decoding message has been decoded. -typedef void (*LogicalDecodeMessageCB) ( - struct LogicalDecodingContext *, - ReorderBufferTXN *txn, - XLogRecPtr message_lsn, - bool transactional, - const char *prefix, - Size message_size, - const char *message -); +typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, + XLogRecPtr message_lsn, + bool transactional, + const char *prefix, + Size message_size, + const char *message); The txn parameter contains meta information about the transaction, like the time stamp at which it has been committed and diff --git a/src/include/replication/output_plugin.h b/src/include/replication/output_plugin.h index 7b5870a744..08e962d0c0 100644 --- a/src/include/replication/output_plugin.h +++ b/src/include/replication/output_plugin.h @@ -41,43 +41,36 @@ typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb); * "is_init" will be set to "true" if the decoding slot just got defined. When * the same slot is used from there one, it will be "false". */ -typedef void (*LogicalDecodeStartupCB) ( - struct LogicalDecodingContext *ctx, +typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx, OutputPluginOptions *options, - bool is_init -); + bool is_init); /* * Callback called for every (explicit or implicit) BEGIN of a successful * transaction. */ -typedef void (*LogicalDecodeBeginCB) ( - struct LogicalDecodingContext *, +typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn); /* * Callback for every individual change in a successful transaction. */ -typedef void (*LogicalDecodeChangeCB) ( - struct LogicalDecodingContext *, +typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, - ReorderBufferChange *change -); + ReorderBufferChange *change); /* * Called for every (explicit or implicit) COMMIT of a successful transaction. */ -typedef void (*LogicalDecodeCommitCB) ( - struct LogicalDecodingContext *, +typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn); /* * Called for the generic logical decoding messages. */ -typedef void (*LogicalDecodeMessageCB) ( - struct LogicalDecodingContext *, +typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, @@ -88,16 +81,13 @@ typedef void (*LogicalDecodeMessageCB) ( /* * Filter changes by origin. */ -typedef bool (*LogicalDecodeFilterByOriginCB) ( - struct LogicalDecodingContext *, +typedef bool (*LogicalDecodeFilterByOriginCB) (struct LogicalDecodingContext *ctx, RepOriginId origin_id); /* * Called to shutdown an output plugin. */ -typedef void (*LogicalDecodeShutdownCB) ( - struct LogicalDecodingContext * -); +typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx); /* * Output plugin callbacks @@ -113,7 +103,8 @@ typedef struct OutputPluginCallbacks LogicalDecodeShutdownCB shutdown_cb; } OutputPluginCallbacks; -void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write); -void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write); +/* Functions in replication/logical/logical.c */ +extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write); +extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write); #endif /* OUTPUT_PLUGIN_H */ -- 2.40.0