diff options
author | Thomas Munro <tmunro@postgresql.org> | 2022-09-29 13:12:11 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2022-09-29 13:12:11 +1300 |
commit | b6d8a60aba322678585ebe11dab072a37ac32905 (patch) | |
tree | 8caea653f8704c8b3866feca1a795add503f5593 /src/backend/storage/file/fd.c | |
parent | 3a5817695a8360011864c1834f8a90ffdfc7f840 (diff) |
Restore pg_pread and friends.
Commits cf112c12 and a0dc8271 were a little too hasty in getting rid of
the pg_ prefixes where we use pread(), pwrite() and vectored variants.
We dropped support for ancient Unixes where we needed to use lseek() to
implement replacements for those, but it turns out that Windows also
changes the current position even when you pass in an offset to
ReadFile() and WriteFile() if the file handle is synchronous, despite
its documentation saying otherwise.
Switching to asynchronous file handles would fix that, but have other
complications. For now let's just put back the pg_ prefix and add some
comments to highlight the non-standard side-effect, which we can now
describe as Windows-only.
Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/20220923202439.GA1156054%40nathanxps13
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 073dab2be59..e4d954578c8 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -2053,7 +2053,7 @@ FileRead(File file, char *buffer, int amount, off_t offset, retry: pgstat_report_wait_start(wait_event_info); - returnCode = pread(vfdP->fd, buffer, amount, offset); + returnCode = pg_pread(vfdP->fd, buffer, amount, offset); pgstat_report_wait_end(); if (returnCode < 0) @@ -2135,7 +2135,7 @@ FileWrite(File file, char *buffer, int amount, off_t offset, retry: errno = 0; pgstat_report_wait_start(wait_event_info); - returnCode = pwrite(VfdCache[file].fd, buffer, amount, offset); + returnCode = pg_pwrite(VfdCache[file].fd, buffer, amount, offset); pgstat_report_wait_end(); /* if write didn't set errno, assume problem is no disk space */ @@ -3740,7 +3740,7 @@ data_sync_elevel(int elevel) } /* - * A convenience wrapper for pwritev() that retries on partial write. If an + * A convenience wrapper for pg_pwritev() that retries on partial write. If an * error is returned, it is unspecified how much has been written. */ ssize_t @@ -3760,7 +3760,7 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset) for (;;) { /* Write as much as we can. */ - part = pwritev(fd, iov, iovcnt, offset); + part = pg_pwritev(fd, iov, iovcnt, offset); if (part < 0) return -1; |