Skip to content

Commit c3b5cfe

Browse files
committed
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.
1 parent 19c324d commit c3b5cfe

File tree

2 files changed

+24
-40
lines changed

2 files changed

+24
-40
lines changed

doc/src/sgml/logicaldecoding.sgml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ typedef struct OutputPluginCallbacks
366366
LogicalDecodeShutdownCB shutdown_cb;
367367
} OutputPluginCallbacks;
368368

369-
typedef void (*LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb);
369+
typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
370370
</programlisting>
371371
The <function>begin_cb</function>, <function>change_cb</function>
372372
and <function>commit_cb</function> callbacks are required,
@@ -450,11 +450,9 @@ CREATE TABLE another_catalog_table(data text) WITH (user_catalog_table = true);
450450
a replication slot is created or asked to stream changes, independent
451451
of the number of changes that are ready to be put out.
452452
<programlisting>
453-
typedef void (*LogicalDecodeStartupCB) (
454-
struct LogicalDecodingContext *ctx,
455-
OutputPluginOptions *options,
456-
bool is_init
457-
);
453+
typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx,
454+
OutputPluginOptions *options,
455+
bool is_init);
458456
</programlisting>
459457
The <literal>is_init</literal> parameter will be true when the
460458
replication slot is being created and false
@@ -489,9 +487,7 @@ typedef struct OutputPluginOptions
489487
be used to deallocate resources private to the output plugin. The slot
490488
isn't necessarily being dropped, streaming is just being stopped.
491489
<programlisting>
492-
typedef void (*LogicalDecodeShutdownCB) (
493-
struct LogicalDecodingContext *ctx
494-
);
490+
typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
495491
</programlisting>
496492
</para>
497493
</sect3>
@@ -504,10 +500,8 @@ typedef void (*LogicalDecodeShutdownCB) (
504500
start of a committed transaction has been decoded. Aborted transactions
505501
and their contents never get decoded.
506502
<programlisting>
507-
typedef void (*LogicalDecodeBeginCB) (
508-
struct LogicalDecodingContext *,
509-
ReorderBufferTXN *txn
510-
);
503+
typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx,
504+
ReorderBufferTXN *txn);
511505
</programlisting>
512506
The <parameter>txn</parameter> parameter contains meta information about
513507
the transaction, like the time stamp at which it has been committed and
@@ -525,10 +519,9 @@ typedef void (*LogicalDecodeBeginCB) (
525519
rows will have been called before this, if there have been any modified
526520
rows.
527521
<programlisting>
528-
typedef void (*LogicalDecodeCommitCB) (
529-
struct LogicalDecodingContext *,
530-
ReorderBufferTXN *txn
531-
);
522+
typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx,
523+
ReorderBufferTXN *txn,
524+
XLogRecPtr commit_lsn);
532525
</programlisting>
533526
</para>
534527
</sect3>
@@ -544,12 +537,10 @@ typedef void (*LogicalDecodeCommitCB) (
544537
several rows at once the callback will be called individually for each
545538
row.
546539
<programlisting>
547-
typedef void (*LogicalDecodeChangeCB) (
548-
struct LogicalDecodingContext *ctx,
549-
ReorderBufferTXN *txn,
550-
Relation relation,
551-
ReorderBufferChange *change
552-
);
540+
typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
541+
ReorderBufferTXN *txn,
542+
Relation relation,
543+
ReorderBufferChange *change);
553544
</programlisting>
554545
The <parameter>ctx</parameter> and <parameter>txn</parameter> parameters
555546
have the same contents as for the <function>begin_cb</function>

src/include/replication/output_plugin.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,44 +41,36 @@ typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
4141
* "is_init" will be set to "true" if the decoding slot just got defined. When
4242
* the same slot is used from there one, it will be "false".
4343
*/
44-
typedef void (*LogicalDecodeStartupCB) (
45-
struct LogicalDecodingContext *ctx,
44+
typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx,
4645
OutputPluginOptions *options,
47-
bool is_init
48-
);
46+
bool is_init);
4947

5048
/*
5149
* Callback called for every (explicit or implicit) BEGIN of a successful
5250
* transaction.
5351
*/
54-
typedef void (*LogicalDecodeBeginCB) (
55-
struct LogicalDecodingContext *,
52+
typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx,
5653
ReorderBufferTXN *txn);
5754

5855
/*
5956
* Callback for every individual change in a successful transaction.
6057
*/
61-
typedef void (*LogicalDecodeChangeCB) (
62-
struct LogicalDecodingContext *,
58+
typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
6359
ReorderBufferTXN *txn,
6460
Relation relation,
65-
ReorderBufferChange *change
66-
);
61+
ReorderBufferChange *change);
6762

6863
/*
6964
* Called for every (explicit or implicit) COMMIT of a successful transaction.
7065
*/
71-
typedef void (*LogicalDecodeCommitCB) (
72-
struct LogicalDecodingContext *,
66+
typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx,
7367
ReorderBufferTXN *txn,
7468
XLogRecPtr commit_lsn);
7569

7670
/*
7771
* Called to shutdown an output plugin.
7872
*/
79-
typedef void (*LogicalDecodeShutdownCB) (
80-
struct LogicalDecodingContext *
81-
);
73+
typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
8274

8375
/*
8476
* Output plugin callbacks
@@ -92,7 +84,8 @@ typedef struct OutputPluginCallbacks
9284
LogicalDecodeShutdownCB shutdown_cb;
9385
} OutputPluginCallbacks;
9486

95-
void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
96-
void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
87+
/* Functions in replication/logical/logical.c */
88+
extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
89+
extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
9790

9891
#endif /* OUTPUT_PLUGIN_H */

0 commit comments

Comments
 (0)