Deduplicate min restart_lsn calculation code

Started by Bharath Rupireddyalmost 5 years ago3 messageshackers
Jump to latest
#1Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com

Hi,

It seems like the two functions ReplicationSlotsComputeRequiredLSN and
ReplicationSlotsComputeLogicalRestartLSN more or less does the same
thing which makes me optimize (saving 40 LOC) it as attached. I'm
pretty much okay if it gets rejected on the grounds that it creates a
lot of diff with the older versions and the new API may not look
nicer, still I want to give it a try.

Thoughts?

Regards,
Bharath Rupireddy.

Attachments:

v1-0001-deduplicate-min-restart_lsn-calculation-code.patchapplication/octet-stream; name=v1-0001-deduplicate-min-restart_lsn-calculation-code.patchDownload+30-72
#2Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Bharath Rupireddy (#1)
Re: Deduplicate min restart_lsn calculation code

On 2022-Jan-06, Bharath Rupireddy wrote:

Hi,

It seems like the two functions ReplicationSlotsComputeRequiredLSN and
ReplicationSlotsComputeLogicalRestartLSN more or less does the same
thing which makes me optimize (saving 40 LOC) it as attached. I'm
pretty much okay if it gets rejected on the grounds that it creates a
lot of diff with the older versions and the new API may not look
nicer, still I want to give it a try.

Thoughts?

Hmm, it seems sensible to me. But I would not have the second boolean
argument in the new function, and instead have the caller save the
return value in a local variable to do the XLogSetReplicationSlotMinimumLSN
step separately. Then the new function API is not so strange.

--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/
"Linux transformó mi computadora, de una `máquina para hacer cosas',
en un aparato realmente entretenido, sobre el cual cada día aprendo
algo nuevo" (Jaime Salinas)

#3Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Alvaro Herrera (#2)
Re: Deduplicate min restart_lsn calculation code

On Thu, Jan 6, 2022 at 11:54 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

On 2022-Jan-06, Bharath Rupireddy wrote:

Hi,

It seems like the two functions ReplicationSlotsComputeRequiredLSN and
ReplicationSlotsComputeLogicalRestartLSN more or less does the same
thing which makes me optimize (saving 40 LOC) it as attached. I'm
pretty much okay if it gets rejected on the grounds that it creates a
lot of diff with the older versions and the new API may not look
nicer, still I want to give it a try.

Thoughts?

Hmm, it seems sensible to me. But I would not have the second boolean
argument in the new function, and instead have the caller save the
return value in a local variable to do the XLogSetReplicationSlotMinimumLSN
step separately. Then the new function API is not so strange.

Thanks for taking a look at it. Here's the v2 patch, please review.

Regards,
Bharath Rupireddy.

Attachments:

t45333_3
v2-0001-deduplicate-min-restart_lsn-calculation-code.patchapplication/octet-stream; name=v2-0001-deduplicate-min-restart_lsn-calculation-code.patchDownload+43-72