Re: pread() and pwrite() - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: pread() and pwrite()
Date
Msg-id 20181105155918.jg36uj4rtnxwqtzt@alvherre.pgsql
Whole thread Raw
In response to Re: pread() and pwrite()  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: pread() and pwrite()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2018-Nov-04, Thomas Munro wrote:

> Here's a patch to add Windows support by supplying
> src/backend/port/win32/pread.c.  Thoughts?

Hmm, so how easy is to detect that somebody runs read/write on fds where
pread/pwrite have occurred?  I guess for data files it's easy to detect
since you'd quickly end up with corrupted files, but what about other
kinds of files?  I wonder if we should be worrying about using this
interface somewhere other than fd.c and forgetting about the limitation.
Say, what happens if we patch some place in xlog.c after this patch gets
in, using write() instead of pwrite()?

I suppose the safest approach is to use lseek (or whatever) to fix up
the position after the pread/pwrite -- but we don't want to pay the
price on an additional syscall.  Are there any other options?  Is there
a way to prevent read/write from being used on a file handle?

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Dmitry Dolgov
Date:
Subject: Re: Flexible permissions for REFRESH MATERIALIZED VIEW
Next
From: "Bossart, Nathan"
Date:
Subject: Re: New vacuum option to do only freezing