From 0ca35b75e383272356ba49211913d8aead5ca10d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 1 Dec 2022 08:36:09 +0100 Subject: [PATCH 1/2] Update types in File API Make the argument types of the File API match stdio better: - Change the data buffer to void *, from char *. - Change FileWrite() data buffer to const on top of that. - Change amounts to size_t, from int. In passing, change the FilePrefetch() amount argument from int to off_t, to match the underlying posix_fadvise(). --- src/backend/storage/file/fd.c | 8 ++++---- src/include/storage/fd.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 4151cafec547..f6c938202309 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -1980,7 +1980,7 @@ FileClose(File file) * to read into. */ int -FilePrefetch(File file, off_t offset, int amount, uint32 wait_event_info) +FilePrefetch(File file, off_t offset, off_t amount, uint32 wait_event_info) { #if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED) int returnCode; @@ -2031,7 +2031,7 @@ FileWriteback(File file, off_t offset, off_t nbytes, uint32 wait_event_info) } int -FileRead(File file, char *buffer, int amount, off_t offset, +FileRead(File file, void *buffer, size_t amount, off_t offset, uint32 wait_event_info) { int returnCode; @@ -2039,7 +2039,7 @@ FileRead(File file, char *buffer, int amount, off_t offset, Assert(FileIsValid(file)); - DO_DB(elog(LOG, "FileRead: %d (%s) " INT64_FORMAT " %d %p", + DO_DB(elog(LOG, "FileRead: %d (%s) " INT64_FORMAT " %zu %p", file, VfdCache[file].fileName, (int64) offset, amount, buffer)); @@ -2087,7 +2087,7 @@ FileRead(File file, char *buffer, int amount, off_t offset, } int -FileWrite(File file, char *buffer, int amount, off_t offset, +FileWrite(File file, const void *buffer, size_t amount, off_t offset, uint32 wait_event_info) { int returnCode; diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index c0a212487d92..7144fc9f6050 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -102,9 +102,9 @@ extern File PathNameOpenFile(const char *fileName, int fileFlags); extern File PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode); extern File OpenTemporaryFile(bool interXact); extern void FileClose(File file); -extern int FilePrefetch(File file, off_t offset, int amount, uint32 wait_event_info); -extern int FileRead(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info); -extern int FileWrite(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info); +extern int FilePrefetch(File file, off_t offset, off_t amount, uint32 wait_event_info); +extern int FileRead(File file, void *buffer, size_t amount, off_t offset, uint32 wait_event_info); +extern int FileWrite(File file, const void *buffer, size_t amount, off_t offset, uint32 wait_event_info); extern int FileSync(File file, uint32 wait_event_info); extern off_t FileSize(File file); extern int FileTruncate(File file, off_t offset, uint32 wait_event_info); base-commit: 43351557d0d2b9c5e20298b5fee2849abef86aff -- 2.38.1