rename SnapBuild* macros in slot.c
Hi,
It seems like the same macro names for
SnapBuildOnDiskNotChecksummedSize and SnapBuildOnDiskChecksummedSize
are being used in slot.c and snapbuild.c. I think, in slot.c, we can
rename them to ReplicationSlotOnDiskNotChecksummedSize and
ReplicationSlotOnDiskChecksummedSize
similar to the other macros ReplicationSlotOnDiskConstantSize and
ReplicationSlotOnDiskV2Size.
Here's a tiny patch for the above change.
Regards,
Bharath Rupireddy.
Attachments:
v1-0001-rename-SnapBuild-macros-in-slot.c.patchapplication/octet-stream; name=v1-0001-rename-SnapBuild-macros-in-slot.c.patchDownload
From fb76fb49cd6e9816a6c3c9658e24bf8fdf610aba Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Sat, 20 Nov 2021 14:11:01 +0000
Subject: [PATCH v1] rename SnapBuild* macros in slot.c
Same macro names for SnapBuildOnDiskNotChecksummedSize and
SnapBuildOnDiskChecksummedSize are being used in slot.c and
snapbuild.c. This patch renames them, in slot.c, to
ReplicationSlotOnDiskNotChecksummedSize and ReplicationSlotOnDiskChecksummedSize
similar to the other macros.
---
src/backend/replication/slot.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index e4f5c6fb36..90ba9b417d 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -77,11 +77,11 @@ typedef struct ReplicationSlotOnDisk
#define ReplicationSlotOnDiskConstantSize \
offsetof(ReplicationSlotOnDisk, slotdata)
/* size of the part of the slot not covered by the checksum */
-#define SnapBuildOnDiskNotChecksummedSize \
+#define ReplicationSlotOnDiskNotChecksummedSize \
offsetof(ReplicationSlotOnDisk, version)
/* size of the part covered by the checksum */
-#define SnapBuildOnDiskChecksummedSize \
- sizeof(ReplicationSlotOnDisk) - SnapBuildOnDiskNotChecksummedSize
+#define ReplicationSlotOnDiskChecksummedSize \
+ sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskNotChecksummedSize
/* size of the slot data that is version dependent */
#define ReplicationSlotOnDiskV2Size \
sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskConstantSize
@@ -1571,8 +1571,8 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
SpinLockRelease(&slot->mutex);
COMP_CRC32C(cp.checksum,
- (char *) (&cp) + SnapBuildOnDiskNotChecksummedSize,
- SnapBuildOnDiskChecksummedSize);
+ (char *) (&cp) + ReplicationSlotOnDiskNotChecksummedSize,
+ ReplicationSlotOnDiskChecksummedSize);
FIN_CRC32C(cp.checksum);
errno = 0;
@@ -1787,8 +1787,8 @@ RestoreSlotFromDisk(const char *name)
/* now verify the CRC */
INIT_CRC32C(checksum);
COMP_CRC32C(checksum,
- (char *) &cp + SnapBuildOnDiskNotChecksummedSize,
- SnapBuildOnDiskChecksummedSize);
+ (char *) &cp + ReplicationSlotOnDiskNotChecksummedSize,
+ ReplicationSlotOnDiskChecksummedSize);
FIN_CRC32C(checksum);
if (!EQ_CRC32C(checksum, cp.checksum))
--
2.25.1
On Sat, Nov 20, 2021 at 7:43 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
It seems like the same macro names for
SnapBuildOnDiskNotChecksummedSize and SnapBuildOnDiskChecksummedSize
are being used in slot.c and snapbuild.c. I think, in slot.c, we can
rename them to ReplicationSlotOnDiskNotChecksummedSize and
ReplicationSlotOnDiskChecksummedSize
similar to the other macros ReplicationSlotOnDiskConstantSize and
ReplicationSlotOnDiskV2Size.
+1 for this change. This seems to be introduced by commit ec5896aed3
[1]: commit ec5896aed3c01da24c1f335f138817e9890d68b6 Author: Andres Freund <andres@anarazel.de> Date: Wed Nov 12 18:52:49 2014 +0100
SnapBuildOnDisk* unless I am missing something.
[1]: commit ec5896aed3c01da24c1f335f138817e9890d68b6 Author: Andres Freund <andres@anarazel.de> Date: Wed Nov 12 18:52:49 2014 +0100
commit ec5896aed3c01da24c1f335f138817e9890d68b6
Author: Andres Freund <andres@anarazel.de>
Date: Wed Nov 12 18:52:49 2014 +0100
Fix several weaknesses in slot and logical replication on-disk
serialization.
--
With Regards,
Amit Kapila.
On 2021-Nov-22, Amit Kapila wrote:
+1 for this change. This seems to be introduced by commit ec5896aed3
[1] and I think it is just a typo to name these macros starting with
SnapBuildOnDisk* unless I am missing something.
Yeah, it looks pretty weird. +1 for the change on consistency grounds.
--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
On Mon, Nov 22, 2021 at 7:47 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2021-Nov-22, Amit Kapila wrote:
+1 for this change. This seems to be introduced by commit ec5896aed3
[1] and I think it is just a typo to name these macros starting with
SnapBuildOnDisk* unless I am missing something.Yeah, it looks pretty weird. +1 for the change on consistency grounds.
Okay, I will push this tomorrow unless I see any objections.
--
With Regards,
Amit Kapila.
On Tue, Nov 23, 2021 at 8:12 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
On Mon, Nov 22, 2021 at 7:47 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2021-Nov-22, Amit Kapila wrote:
+1 for this change. This seems to be introduced by commit ec5896aed3
[1] and I think it is just a typo to name these macros starting with
SnapBuildOnDisk* unless I am missing something.Yeah, it looks pretty weird. +1 for the change on consistency grounds.
Okay, I will push this tomorrow unless I see any objections.
Pushed!
--
With Regards,
Amit Kapila.