Simplify if/else logic of walsender CreateReplicationSlot

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Simplify if/else logic of walsender CreateReplicationSlot
Date: 2023-11-20 07:01:42
Message-ID: CAHut+PtnJzqKT41Zt8pChRzba=QgCqjtfYvcf84NMj3VFJoKfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While reviewing another patch I was looking at the walsender's static
function CreateReplicationSlot

I found that the current logic seemed to have some unnecessary if/else
checking which can be simplified.

~~

To summarise:

CURRENT
if (cmd->kind == REPLICATION_KIND_PHYSICAL)
{
...
}
else
{
...
}
if (cmd->kind == REPLICATION_KIND_LOGICAL)
{
...
}
else if (cmd->kind == REPLICATION_KIND_PHYSICAL && reserve_wal)
{
...
}

SUGGESTION
if (cmd->kind == REPLICATION_KIND_PHYSICAL)
{
...
if (reserve_wal)
{
...
}
}
else /* REPLICATION_KIND_LOGICAL */
{
...
}

~~~

PSA a small patch for making this change.

(I ran make check-world after this change and it was successful)

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment Content-Type Size
v1-0001-Simplify-if-else-logic-of-walsender-CreateReplica.patch application/octet-stream 2.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-11-20 07:27:48 Re: meson documentation build open issues
Previous Message Peter Eisentraut 2023-11-20 07:00:09 Re: Remove MSVC scripts from the tree