Commit ab9c4338 authored by Andres Freund's avatar Andres Freund

Don't build full initial logical decoding snapshot if NOEXPORT_SNAPSHOT.

Earlier commits (56e19d93 and 2bef06d5) make it cheaper to
create a logical slot if not exporting the initial snapshot.  If
NOEXPORT_SNAPSHOT is specified, we can skip the overhead, not just
when creating a slot via sql (which can't export snapshots).  As
NOEXPORT_SNAPSHOT has only recently been introduced, this shouldn't be
backpatched.
parent 56e19d93
...@@ -873,6 +873,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd) ...@@ -873,6 +873,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
if (cmd->kind == REPLICATION_KIND_LOGICAL) if (cmd->kind == REPLICATION_KIND_LOGICAL)
{ {
LogicalDecodingContext *ctx; LogicalDecodingContext *ctx;
bool need_full_snapshot = false;
/* /*
* Do options check early so that we can bail before calling the * Do options check early so that we can bail before calling the
...@@ -884,6 +885,8 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd) ...@@ -884,6 +885,8 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
ereport(ERROR, ereport(ERROR,
(errmsg("CREATE_REPLICATION_SLOT ... EXPORT_SNAPSHOT " (errmsg("CREATE_REPLICATION_SLOT ... EXPORT_SNAPSHOT "
"must not be called inside a transaction"))); "must not be called inside a transaction")));
need_full_snapshot = true;
} }
else if (snapshot_action == CRS_USE_SNAPSHOT) else if (snapshot_action == CRS_USE_SNAPSHOT)
{ {
...@@ -906,10 +909,11 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd) ...@@ -906,10 +909,11 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
ereport(ERROR, ereport(ERROR,
(errmsg("CREATE_REPLICATION_SLOT ... USE_SNAPSHOT " (errmsg("CREATE_REPLICATION_SLOT ... USE_SNAPSHOT "
"must not be called in a subtransaction"))); "must not be called in a subtransaction")));
need_full_snapshot = true;
} }
ctx = CreateInitDecodingContext(cmd->plugin, NIL, ctx = CreateInitDecodingContext(cmd->plugin, NIL, need_full_snapshot,
true, /* build snapshot */
logical_read_xlog_page, logical_read_xlog_page,
WalSndPrepareWrite, WalSndWriteData); WalSndPrepareWrite, WalSndWriteData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment