mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Restore pg_pread and friends.
Commitscf112c12
anda0dc8271
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
This commit is contained in:
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user