Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite83aa9f

Browse files
committed
Simplify some logic in CreateReplicationSlot()
This refactoring reduces the code in charge of creating replicationslots from two "if" block to a single one, making it slightly cleaner.This change is possible since1d04a59, that has removed theintermediate code that existed between the two "if" blocks in charge ofinitializing the output message buffer.Author: Peter SmithDiscussion:https://postgr.es/m/CAHut+PtnJzqKT41Zt8pChRzba=QgCqjtfYvcf84NMj3VFJoKfw@mail.gmail.com
1 parent7c3fb50 commite83aa9f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

‎src/backend/replication/walsender.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,25 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
10611061
ReplicationSlotCreate(cmd->slotname, false,
10621062
cmd->temporary ?RS_TEMPORARY :RS_PERSISTENT,
10631063
false);
1064+
1065+
if (reserve_wal)
1066+
{
1067+
ReplicationSlotReserveWal();
1068+
1069+
ReplicationSlotMarkDirty();
1070+
1071+
/* Write this slot to disk if it's a permanent one. */
1072+
if (!cmd->temporary)
1073+
ReplicationSlotSave();
1074+
}
10641075
}
10651076
else
10661077
{
1078+
LogicalDecodingContext*ctx;
1079+
boolneed_full_snapshot= false;
1080+
1081+
Assert(cmd->kind==REPLICATION_KIND_LOGICAL);
1082+
10671083
CheckLogicalDecodingRequirements();
10681084

10691085
/*
@@ -1076,12 +1092,6 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
10761092
ReplicationSlotCreate(cmd->slotname, true,
10771093
cmd->temporary ?RS_TEMPORARY :RS_EPHEMERAL,
10781094
two_phase);
1079-
}
1080-
1081-
if (cmd->kind==REPLICATION_KIND_LOGICAL)
1082-
{
1083-
LogicalDecodingContext*ctx;
1084-
boolneed_full_snapshot= false;
10851095

10861096
/*
10871097
* Do options check early so that we can bail before calling the
@@ -1175,16 +1185,6 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
11751185
if (!cmd->temporary)
11761186
ReplicationSlotPersist();
11771187
}
1178-
elseif (cmd->kind==REPLICATION_KIND_PHYSICAL&&reserve_wal)
1179-
{
1180-
ReplicationSlotReserveWal();
1181-
1182-
ReplicationSlotMarkDirty();
1183-
1184-
/* Write this slot to disk if it's a permanent one. */
1185-
if (!cmd->temporary)
1186-
ReplicationSlotSave();
1187-
}
11881188

11891189
snprintf(xloc,sizeof(xloc),"%X/%X",
11901190
LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp