mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +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:
@@ -1149,7 +1149,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
|
||||
/* write out tail end of mapping file (again) */
|
||||
errno = 0;
|
||||
pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
|
||||
if (pg_pwrite(fd, data, len, xlrec->offset) != len)
|
||||
if (pwrite(fd, data, len, xlrec->offset) != len)
|
||||
{
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
if (errno == 0)
|
||||
|
@@ -718,7 +718,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
|
||||
|
||||
errno = 0;
|
||||
pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
|
||||
if (pg_pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
|
||||
if (pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
|
||||
{
|
||||
pgstat_report_wait_end();
|
||||
slru_errcause = SLRU_READ_FAILED;
|
||||
@@ -873,7 +873,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
|
||||
|
||||
errno = 0;
|
||||
pgstat_report_wait_start(WAIT_EVENT_SLRU_WRITE);
|
||||
if (pg_pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
|
||||
if (pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
|
||||
{
|
||||
pgstat_report_wait_end();
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
|
@@ -2189,7 +2189,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
|
||||
INSTR_TIME_SET_CURRENT(start);
|
||||
|
||||
pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE);
|
||||
written = pg_pwrite(openLogFile, from, nleft, startoffset);
|
||||
written = pwrite(openLogFile, from, nleft, startoffset);
|
||||
pgstat_report_wait_end();
|
||||
|
||||
/*
|
||||
@@ -3011,7 +3011,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
|
||||
* enough.
|
||||
*/
|
||||
errno = 0;
|
||||
if (pg_pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
|
||||
if (pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
|
||||
{
|
||||
/* if write didn't set errno, assume no disk space */
|
||||
save_errno = errno ? errno : ENOSPC;
|
||||
|
@@ -1514,7 +1514,7 @@ WALRead(XLogReaderState *state,
|
||||
|
||||
/* Reset errno first; eases reporting non-errno-affecting errors */
|
||||
errno = 0;
|
||||
readbytes = pg_pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
|
||||
readbytes = pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
|
||||
|
||||
#ifndef FRONTEND
|
||||
pgstat_report_wait_end();
|
||||
|
@@ -3260,7 +3260,7 @@ retry:
|
||||
readOff = targetPageOff;
|
||||
|
||||
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
|
||||
r = pg_pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
|
||||
r = pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
|
||||
if (r != XLOG_BLCKSZ)
|
||||
{
|
||||
char fname[MAXFNAMELEN];
|
||||
|
@@ -1822,7 +1822,7 @@ basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
|
||||
int rc;
|
||||
|
||||
pgstat_report_wait_start(WAIT_EVENT_BASEBACKUP_READ);
|
||||
rc = pg_pread(fd, buf, nbytes, offset);
|
||||
rc = pread(fd, buf, nbytes, offset);
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (rc < 0)
|
||||
|
@@ -915,7 +915,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli)
|
||||
/* OK to write the logs */
|
||||
errno = 0;
|
||||
|
||||
byteswritten = pg_pwrite(recvFile, buf, segbytes, (off_t) startoff);
|
||||
byteswritten = pwrite(recvFile, buf, segbytes, (off_t) startoff);
|
||||
if (byteswritten <= 0)
|
||||
{
|
||||
char xlogfname[MAXFNAMELEN];
|
||||
|
@@ -2063,7 +2063,7 @@ FileRead(File file, char *buffer, int amount, off_t offset,
|
||||
|
||||
retry:
|
||||
pgstat_report_wait_start(wait_event_info);
|
||||
returnCode = pg_pread(vfdP->fd, buffer, amount, offset);
|
||||
returnCode = pread(vfdP->fd, buffer, amount, offset);
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (returnCode < 0)
|
||||
@@ -2145,7 +2145,7 @@ FileWrite(File file, char *buffer, int amount, off_t offset,
|
||||
retry:
|
||||
errno = 0;
|
||||
pgstat_report_wait_start(wait_event_info);
|
||||
returnCode = pg_pwrite(VfdCache[file].fd, buffer, amount, offset);
|
||||
returnCode = pwrite(VfdCache[file].fd, buffer, amount, offset);
|
||||
pgstat_report_wait_end();
|
||||
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
|
@@ -1429,7 +1429,7 @@ AddToDataDirLockFile(int target_line, const char *str)
|
||||
len = strlen(destbuffer);
|
||||
errno = 0;
|
||||
pgstat_report_wait_start(WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE);
|
||||
if (pg_pwrite(fd, destbuffer, len, 0) != len)
|
||||
if (pwrite(fd, destbuffer, len, 0) != len)
|
||||
{
|
||||
pgstat_report_wait_end();
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
|
Reference in New Issue
Block a user