mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Simplify some logic in CreateReplicationSlot()
This refactoring reduces the code in charge of creating replication
slots from two "if" block to a single one, making it slightly cleaner.
This change is possible since 1d04a59be3
, that has removed the
intermediate code that existed between the two "if" blocks in charge of
initializing the output message buffer.
Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+PtnJzqKT41Zt8pChRzba=QgCqjtfYvcf84NMj3VFJoKfw@mail.gmail.com
This commit is contained in:
@ -1061,9 +1061,25 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
|
|||||||
ReplicationSlotCreate(cmd->slotname, false,
|
ReplicationSlotCreate(cmd->slotname, false,
|
||||||
cmd->temporary ? RS_TEMPORARY : RS_PERSISTENT,
|
cmd->temporary ? RS_TEMPORARY : RS_PERSISTENT,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
if (reserve_wal)
|
||||||
|
{
|
||||||
|
ReplicationSlotReserveWal();
|
||||||
|
|
||||||
|
ReplicationSlotMarkDirty();
|
||||||
|
|
||||||
|
/* Write this slot to disk if it's a permanent one. */
|
||||||
|
if (!cmd->temporary)
|
||||||
|
ReplicationSlotSave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LogicalDecodingContext *ctx;
|
||||||
|
bool need_full_snapshot = false;
|
||||||
|
|
||||||
|
Assert(cmd->kind == REPLICATION_KIND_LOGICAL);
|
||||||
|
|
||||||
CheckLogicalDecodingRequirements();
|
CheckLogicalDecodingRequirements();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1076,12 +1092,6 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
|
|||||||
ReplicationSlotCreate(cmd->slotname, true,
|
ReplicationSlotCreate(cmd->slotname, true,
|
||||||
cmd->temporary ? RS_TEMPORARY : RS_EPHEMERAL,
|
cmd->temporary ? RS_TEMPORARY : RS_EPHEMERAL,
|
||||||
two_phase);
|
two_phase);
|
||||||
}
|
|
||||||
|
|
||||||
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
|
* Do options check early so that we can bail before calling the
|
||||||
@ -1175,16 +1185,6 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
|
|||||||
if (!cmd->temporary)
|
if (!cmd->temporary)
|
||||||
ReplicationSlotPersist();
|
ReplicationSlotPersist();
|
||||||
}
|
}
|
||||||
else if (cmd->kind == REPLICATION_KIND_PHYSICAL && reserve_wal)
|
|
||||||
{
|
|
||||||
ReplicationSlotReserveWal();
|
|
||||||
|
|
||||||
ReplicationSlotMarkDirty();
|
|
||||||
|
|
||||||
/* Write this slot to disk if it's a permanent one. */
|
|
||||||
if (!cmd->temporary)
|
|
||||||
ReplicationSlotSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(xloc, sizeof(xloc), "%X/%X",
|
snprintf(xloc, sizeof(xloc), "%X/%X",
|
||||||
LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush));
|
LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush));
|
||||||
|
Reference in New Issue
Block a user