From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Jesper Pedersen <jesper.pedersen@redhat.com>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: Oskari Saarenmaa <os@ohmu.fi>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Tobias Oberstein <tobias.oberstein@gmail.com>
Subject: Re: pread() and pwrite()
Date: Mon, 05 Nov 2018 12:23:52 -0500
Message-ID: <1791.1541438632@sss.pgh.pa.us> (raw)
In-Reply-To: <20181105155918.jg36uj4rtnxwqtzt@alvherre.pgsql>
References: <20181105155918.jg36uj4rtnxwqtzt@alvherre.pgsql>
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> 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.
Yeah. I think the patch as presented is OK; it uses pread/pwrite only
inside fd.c, which is a reasonably non-leaky abstraction. But there's
definitely a hazard of somebody submitting a patch that depends on
using pread/pwrite elsewhere, and then that maybe not working.
What I suggest is that we *not* try to make this a completely transparent
substitute. Instead, make the functions exported by src/port/ be
"pg_pread" and "pg_pwrite", and inside fd.c we'd write something like
#ifdef HAVE_PREAD
#define pg_pread pread
#endif
and then refer to pg_pread/pg_pwrite in the body of that file. That
way, if someone refers to pread and expects standard functionality
from it, they'll get a failure on platforms not supporting it.
FWIW, I tested the given patches on HPUX 10.20; they compiled cleanly
and pass the core regression tests.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, thomas.munro@enterprisedb.com, jesper.pedersen@redhat.com, magnus@hagander.net, os@ohmu.fi, tobias.oberstein@gmail.com
Subject: Re: pread() and pwrite()
In-Reply-To: <1791.1541438632@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox