diff options
author | Amit Kapila <akapila@postgresql.org> | 2020-12-30 16:17:26 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2020-12-30 16:17:26 +0530 |
commit | 0aa8a01d04c8fe200b7a106878eebc3d0af9105c (patch) | |
tree | 79fe885496f4d3493ae327156c0baf1aa0e1e43a /src/include/replication/logical.h | |
parent | fa744697c79189a661f802d9a979d959b4454df0 (diff) |
Extend the output plugin API to allow decoding of prepared xacts.
This adds six methods to the output plugin API, adding support for
streaming changes of two-phase transactions at prepare time.
* begin_prepare
* filter_prepare
* prepare
* commit_prepared
* rollback_prepared
* stream_prepare
Most of this is a simple extension of the existing methods, with the
semantic difference that the transaction is not yet committed and maybe
aborted later.
Until now two-phase transactions were translated into regular transactions
on the subscriber, and the GID was not forwarded to it. None of the
two-phase commands were communicated to the subscriber.
This patch provides the infrastructure for logical decoding plugins to be
informed of two-phase commands Like PREPARE TRANSACTION, COMMIT PREPARED
and ROLLBACK PREPARED commands with the corresponding GID.
This also extends the 'test_decoding' plugin, implementing these new
methods.
This commit simply adds these new APIs and the upcoming patch to "allow
the decoding at prepare time in ReorderBuffer" will use these APIs.
Author: Ajin Cherian and Amit Kapila based on previous work by Nikhil Sontakke and Stas Kelvich
Reviewed-by: Amit Kapila, Peter Smith, Sawada Masahiko, and Dilip Kumar
Discussion:
https://postgr.es/m/02DA5F5E-CECE-4D9C-8B4B-418077E2C010@postgrespro.ru
https://postgr.es/m/CAMGcDxeqEpWj3fTXwqhSwBdXd2RS9jzwWscO-XbeCfso6ts3+Q@mail.gmail.com
Diffstat (limited to 'src/include/replication/logical.h')
-rw-r--r-- | src/include/replication/logical.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/include/replication/logical.h b/src/include/replication/logical.h index 40bab7ee02d..28c9c1f474e 100644 --- a/src/include/replication/logical.h +++ b/src/include/replication/logical.h @@ -85,6 +85,11 @@ typedef struct LogicalDecodingContext bool streaming; /* + * Does the output plugin support two-phase decoding, and is it enabled? + */ + bool twophase; + + /* * State for writing output. */ bool accept_writes; @@ -120,6 +125,7 @@ extern void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart_lsn); extern void LogicalConfirmReceivedLocation(XLogRecPtr lsn); +extern bool filter_prepare_cb_wrapper(LogicalDecodingContext *ctx, const char *gid); extern bool filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, RepOriginId origin_id); extern void ResetLogicalStreamingState(void); extern void UpdateDecodingStats(LogicalDecodingContext *ctx); |