1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

SnapBuildRestoreContents() void * argument for binary data

Change internal snapbuild API function to take void * for binary data
instead of char *.  This removes the need for numerous casts.

Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://www.postgresql.org/message-id/flat/fd1fcedb-3492-4fc8-9e3e-74b97f2db6c7%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2024-09-24 12:18:31 +02:00
parent a4e986ef5a
commit ebdccead16

View File

@ -173,7 +173,7 @@ static void SnapBuildWaitSnapshot(xl_running_xacts *running, TransactionId cutof
/* serialization functions */ /* serialization functions */
static void SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn); static void SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn);
static bool SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn); static bool SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn);
static void SnapBuildRestoreContents(int fd, char *dest, Size size, const char *path); static void SnapBuildRestoreContents(int fd, void *dest, Size size, const char *path);
/* /*
* Allocate a new snapshot builder. * Allocate a new snapshot builder.
@ -1722,7 +1722,7 @@ SnapBuildRestoreSnapshot(SnapBuildOnDisk *ondisk, const char *path,
fsync_fname(PG_LOGICAL_SNAPSHOTS_DIR, true); fsync_fname(PG_LOGICAL_SNAPSHOTS_DIR, true);
/* read statically sized portion of snapshot */ /* read statically sized portion of snapshot */
SnapBuildRestoreContents(fd, (char *) ondisk, SnapBuildOnDiskConstantSize, path); SnapBuildRestoreContents(fd, ondisk, SnapBuildOnDiskConstantSize, path);
if (ondisk->magic != SNAPBUILD_MAGIC) if (ondisk->magic != SNAPBUILD_MAGIC)
ereport(ERROR, ereport(ERROR,
@ -1742,7 +1742,7 @@ SnapBuildRestoreSnapshot(SnapBuildOnDisk *ondisk, const char *path,
SnapBuildOnDiskConstantSize - SnapBuildOnDiskNotChecksummedSize); SnapBuildOnDiskConstantSize - SnapBuildOnDiskNotChecksummedSize);
/* read SnapBuild */ /* read SnapBuild */
SnapBuildRestoreContents(fd, (char *) &ondisk->builder, sizeof(SnapBuild), path); SnapBuildRestoreContents(fd, &ondisk->builder, sizeof(SnapBuild), path);
COMP_CRC32C(checksum, &ondisk->builder, sizeof(SnapBuild)); COMP_CRC32C(checksum, &ondisk->builder, sizeof(SnapBuild));
/* restore committed xacts information */ /* restore committed xacts information */
@ -1750,7 +1750,7 @@ SnapBuildRestoreSnapshot(SnapBuildOnDisk *ondisk, const char *path,
{ {
sz = sizeof(TransactionId) * ondisk->builder.committed.xcnt; sz = sizeof(TransactionId) * ondisk->builder.committed.xcnt;
ondisk->builder.committed.xip = MemoryContextAllocZero(context, sz); ondisk->builder.committed.xip = MemoryContextAllocZero(context, sz);
SnapBuildRestoreContents(fd, (char *) ondisk->builder.committed.xip, sz, path); SnapBuildRestoreContents(fd, ondisk->builder.committed.xip, sz, path);
COMP_CRC32C(checksum, ondisk->builder.committed.xip, sz); COMP_CRC32C(checksum, ondisk->builder.committed.xip, sz);
} }
@ -1759,7 +1759,7 @@ SnapBuildRestoreSnapshot(SnapBuildOnDisk *ondisk, const char *path,
{ {
sz = sizeof(TransactionId) * ondisk->builder.catchange.xcnt; sz = sizeof(TransactionId) * ondisk->builder.catchange.xcnt;
ondisk->builder.catchange.xip = MemoryContextAllocZero(context, sz); ondisk->builder.catchange.xip = MemoryContextAllocZero(context, sz);
SnapBuildRestoreContents(fd, (char *) ondisk->builder.catchange.xip, sz, path); SnapBuildRestoreContents(fd, ondisk->builder.catchange.xip, sz, path);
COMP_CRC32C(checksum, ondisk->builder.catchange.xip, sz); COMP_CRC32C(checksum, ondisk->builder.catchange.xip, sz);
} }
@ -1882,7 +1882,7 @@ snapshot_not_interesting:
* Read the contents of the serialized snapshot to 'dest'. * Read the contents of the serialized snapshot to 'dest'.
*/ */
static void static void
SnapBuildRestoreContents(int fd, char *dest, Size size, const char *path) SnapBuildRestoreContents(int fd, void *dest, Size size, const char *path)
{ {
int readBytes; int readBytes;