mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Add prepare API support for streaming transactions in logical replication.
Commit a8fd13cab0
added support for prepared transactions to built-in
logical replication via a new option "two_phase" for a subscription. The
"two_phase" option was not allowed with the existing streaming option.
This commit permits the combination of "streaming" and "two_phase"
subscription options. It extends the pgoutput plugin and the subscriber
side code to add the prepare API for streaming transactions which will
apply the changes accumulated in the spool-file at prepare time.
Author: Peter Smith and Ajin Cherian
Reviewed-by: Vignesh C, Amit Kapila, Greg Nancarrow
Tested-By: Haiying Tang
Discussion: https://postgr.es/m/02DA5F5E-CECE-4D9C-8B4B-418077E2C010@postgrespro.ru
Discussion: https://postgr.es/m/CAMGcDxeqEpWj3fTXwqhSwBdXd2RS9jzwWscO-XbeCfso6ts3+Q@mail.gmail.com
This commit is contained in:
@ -335,25 +335,6 @@ parse_subscription_options(ParseState *pstate, List *stmt_options,
|
||||
errmsg("subscription with %s must also set %s",
|
||||
"slot_name = NONE", "create_slot = false")));
|
||||
}
|
||||
|
||||
/*
|
||||
* Do additional checking for the disallowed combination of two_phase and
|
||||
* streaming. While streaming and two_phase can theoretically be
|
||||
* supported, it needs more analysis to allow them together.
|
||||
*/
|
||||
if (opts->twophase &&
|
||||
IsSet(supported_opts, SUBOPT_TWOPHASE_COMMIT) &&
|
||||
IsSet(opts->specified_opts, SUBOPT_TWOPHASE_COMMIT))
|
||||
{
|
||||
if (opts->streaming &&
|
||||
IsSet(supported_opts, SUBOPT_STREAMING) &&
|
||||
IsSet(opts->specified_opts, SUBOPT_STREAMING))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
/*- translator: both %s are strings of the form "option = value" */
|
||||
errmsg("%s and %s are mutually exclusive options",
|
||||
"two_phase = true", "streaming = true")));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -933,12 +914,6 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
|
||||
|
||||
if (IsSet(opts.specified_opts, SUBOPT_STREAMING))
|
||||
{
|
||||
if ((sub->twophasestate != LOGICALREP_TWOPHASE_STATE_DISABLED) && opts.streaming)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot set %s for two-phase enabled subscription",
|
||||
"streaming = true")));
|
||||
|
||||
values[Anum_pg_subscription_substream - 1] =
|
||||
BoolGetDatum(opts.streaming);
|
||||
replaces[Anum_pg_subscription_substream - 1] = true;
|
||||
|
Reference in New Issue
Block a user