mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Use pg_pwrite() in more places.
This removes some lseek() system calls. Author: Thomas Munro Reviewed-by: Andres Freund Discussion: https://postgr.es/m/CA%2BhUKGJ%2BoHhnvqjn3%3DHro7xu-YDR8FPr0FL6LF35kHRX%3D_bUzg%40mail.gmail.com
This commit is contained in:
@@ -1156,13 +1156,6 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
|
||||
path, (uint32) xlrec->offset)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
/* now seek to the position we want to write our data to */
|
||||
if (lseek(fd, xlrec->offset, SEEK_SET) != xlrec->offset)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not seek to end of file \"%s\": %m",
|
||||
path)));
|
||||
|
||||
data = XLogRecGetData(r) + sizeof(*xlrec);
|
||||
|
||||
len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
|
||||
@@ -1170,7 +1163,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 (write(fd, data, len) != len)
|
||||
if (pg_pwrite(fd, data, len, xlrec->offset) != len)
|
||||
{
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
if (errno == 0)
|
||||
|
Reference in New Issue
Block a user