mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
Remove dead pread and pwrite replacement code.
pread() and pwrite() are in SUSv2, and all targeted Unix systems have them. Previously, we defined pg_pread and pg_pwrite to emulate these function with lseek() on old Unixen. The names with a pg_ prefix were a reminder of a portability hazard: they might change the current file position. That hazard is gone, so we can drop the prefixes. Since the remaining replacement code is Windows-only, move it into src/port/win32p{read,write}.c, and move the declarations into src/include/port/win32_port.h. No need for vestigial HAVE_PREAD, HAVE_PWRITE macros as they were only used for declarations in port.h which have now moved into win32_port.h. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Greg Stark <stark@mit.edu> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
This commit is contained in:
@@ -30,7 +30,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
|
||||
{
|
||||
#ifdef HAVE_READV
|
||||
if (iovcnt == 1)
|
||||
return pg_pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
|
||||
return pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
|
||||
if (lseek(fd, offset, SEEK_SET) < 0)
|
||||
return -1;
|
||||
return readv(fd, iov, iovcnt);
|
||||
@@ -40,7 +40,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
|
||||
|
||||
for (int i = 0; i < iovcnt; ++i)
|
||||
{
|
||||
part = pg_pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
|
||||
part = pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
|
||||
if (part < 0)
|
||||
{
|
||||
if (i == 0)
|
||||
|
Reference in New Issue
Block a user