diff options
author | Thomas Munro <tmunro@postgresql.org> | 2020-02-11 17:22:37 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2020-02-11 17:50:22 +1300 |
commit | 701a51fd4e01dbbd02067d8f01905a04bc571131 (patch) | |
tree | d450ebbcf4ed98d70e91ba2e9047c384227cbca1 /src/backend/access/heap/rewriteheap.c | |
parent | 2102ba4b586350957bf95b371432583239000164 (diff) | |
download | postgresql-701a51fd4e01dbbd02067d8f01905a04bc571131.tar.gz postgresql-701a51fd4e01dbbd02067d8f01905a04bc571131.zip |
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
Diffstat (limited to 'src/backend/access/heap/rewriteheap.c')
-rw-r--r-- | src/backend/access/heap/rewriteheap.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 5869922ff83..9c29bc0e0f0 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -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) |