aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-04-27 15:49:22 -0700
committerAndres Freund <andres@anarazel.de>2017-04-27 15:52:31 -0700
commitab9c43381ef7a7333086107847413e0b593854d0 (patch)
treeb807768ba4eb0197a1adad6821716308daf9ae26 /src
parent56e19d938dd1457ae078304df1b9903509a0a2bf (diff)
downloadpostgresql-ab9c43381ef7a7333086107847413e0b593854d0.tar.gz
postgresql-ab9c43381ef7a7333086107847413e0b593854d0.zip
Don't build full initial logical decoding snapshot if NOEXPORT_SNAPSHOT.
Earlier commits (56e19d938dd14 and 2bef06d5164) 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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walsender.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 43c8a73f3e1..2a6c8bb62df 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -873,6 +873,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
if (cmd->kind == REPLICATION_KIND_LOGICAL)
{
LogicalDecodingContext *ctx;
+ bool need_full_snapshot = false;
/*
* Do options check early so that we can bail before calling the
@@ -884,6 +885,8 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
ereport(ERROR,
(errmsg("CREATE_REPLICATION_SLOT ... EXPORT_SNAPSHOT "
"must not be called inside a transaction")));
+
+ need_full_snapshot = true;
}
else if (snapshot_action == CRS_USE_SNAPSHOT)
{
@@ -906,10 +909,11 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
ereport(ERROR,
(errmsg("CREATE_REPLICATION_SLOT ... USE_SNAPSHOT "
"must not be called in a subtransaction")));
+
+ need_full_snapshot = true;
}
- ctx = CreateInitDecodingContext(cmd->plugin, NIL,
- true, /* build snapshot */
+ ctx = CreateInitDecodingContext(cmd->plugin, NIL, need_full_snapshot,
logical_read_xlog_page,
WalSndPrepareWrite, WalSndWriteData);