Skip to content

Commit 7d1b6bf

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 e0084c3 commit 7d1b6bf

File tree

2 files changed

+27
-46
lines changed

2 files changed

+27
-46
lines changed

doc/src/sgml/logicaldecoding.sgml

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ typedef struct OutputPluginCallbacks
367367
LogicalDecodeShutdownCB shutdown_cb;
368368
} OutputPluginCallbacks;
369369

370-
typedef void (*LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb);
370+
typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
371371
</programlisting>
372372
The <function>begin_cb</function>, <function>change_cb</function>
373373
and <function>commit_cb</function> callbacks are required,
@@ -452,11 +452,9 @@ CREATE TABLE another_catalog_table(data text) WITH (user_catalog_table = true);
452452
a replication slot is created or asked to stream changes, independent
453453
of the number of changes that are ready to be put out.
454454
<programlisting>
455-
typedef void (*LogicalDecodeStartupCB) (
456-
struct LogicalDecodingContext *ctx,
457-
OutputPluginOptions *options,
458-
bool is_init
459-
);
455+
typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx,
456+
OutputPluginOptions *options,
457+
bool is_init);
460458
</programlisting>
461459
The <literal>is_init</literal> parameter will be true when the
462460
replication slot is being created and false
@@ -491,9 +489,7 @@ typedef struct OutputPluginOptions
491489
be used to deallocate resources private to the output plugin. The slot
492490
isn't necessarily being dropped, streaming is just being stopped.
493491
<programlisting>
494-
typedef void (*LogicalDecodeShutdownCB) (
495-
struct LogicalDecodingContext *ctx
496-
);
492+
typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
497493
</programlisting>
498494
</para>
499495
</sect3>
@@ -506,10 +502,8 @@ typedef void (*LogicalDecodeShutdownCB) (
506502
start of a committed transaction has been decoded. Aborted transactions
507503
and their contents never get decoded.
508504
<programlisting>
509-
typedef void (*LogicalDecodeBeginCB) (
510-
struct LogicalDecodingContext *,
511-
ReorderBufferTXN *txn
512-
);
505+
typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx,
506+
ReorderBufferTXN *txn);
513507
</programlisting>
514508
The <parameter>txn</parameter> parameter contains meta information about
515509
the transaction, like the time stamp at which it has been committed and
@@ -527,10 +521,9 @@ typedef void (*LogicalDecodeBeginCB) (
527521
rows will have been called before this, if there have been any modified
528522
rows.
529523
<programlisting>
530-
typedef void (*LogicalDecodeCommitCB) (
531-
struct LogicalDecodingContext *,
532-
ReorderBufferTXN *txn
533-
);
524+
typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx,
525+
ReorderBufferTXN *txn,
526+
XLogRecPtr commit_lsn);
534527
</programlisting>
535528
</para>
536529
</sect3>
@@ -546,12 +539,10 @@ typedef void (*LogicalDecodeCommitCB) (
546539
several rows at once the callback will be called individually for each
547540
row.
548541
<programlisting>
549-
typedef void (*LogicalDecodeChangeCB) (
550-
struct LogicalDecodingContext *ctx,
551-
ReorderBufferTXN *txn,
552-
Relation relation,
553-
ReorderBufferChange *change
554-
);
542+
typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
543+
ReorderBufferTXN *txn,
544+
Relation relation,
545+
ReorderBufferChange *change);
555546
</programlisting>
556547
The <parameter>ctx</parameter> and <parameter>txn</parameter> parameters
557548
have the same contents as for the <function>begin_cb</function>
@@ -581,10 +572,8 @@ typedef void (*LogicalDecodeChangeCB) (
581572
from <parameter>origin_id</parameter> is of interest to the
582573
output plugin.
583574
<programlisting>
584-
typedef bool (*LogicalDecodeFilterByOriginCB) (
585-
struct LogicalDecodingContext *ctx,
586-
RepNodeId origin_id
587-
);
575+
typedef bool (*LogicalDecodeFilterByOriginCB) (struct LogicalDecodingContext *ctx,
576+
RepOriginId origin_id);
588577
</programlisting>
589578
The <parameter>ctx</parameter> parameter has the same contents
590579
as for the other callbacks. No information but the origin is

src/include/replication/output_plugin.h

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,51 +41,42 @@ 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
* Filter changes by origin.
7872
*/
79-
typedef bool (*LogicalDecodeFilterByOriginCB) (
80-
struct LogicalDecodingContext *,
73+
typedef bool (*LogicalDecodeFilterByOriginCB) (struct LogicalDecodingContext *ctx,
8174
RepOriginId origin_id);
8275

8376
/*
8477
* Called to shutdown an output plugin.
8578
*/
86-
typedef void (*LogicalDecodeShutdownCB) (
87-
struct LogicalDecodingContext *
88-
);
79+
typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
8980

9081
/*
9182
* Output plugin callbacks
@@ -100,7 +91,8 @@ typedef struct OutputPluginCallbacks
10091
LogicalDecodeShutdownCB shutdown_cb;
10192
} OutputPluginCallbacks;
10293

103-
void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
104-
void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
94+
/* Functions in replication/logical/logical.c */
95+
extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
96+
extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
10597

10698
#endif /* OUTPUT_PLUGIN_H */

0 commit comments

Comments
 (0)