Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJibj-0001Eg-7U for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Nov 2018 17:24:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gJibh-0006Ej-9i for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Nov 2018 17:24:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJibg-0006Eb-Uf for pgsql-hackers@lists.postgresql.org; Mon, 05 Nov 2018 17:24:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJibZ-0007Fy-Vc for pgsql-hackers@postgresql.org; Mon, 05 Nov 2018 17:24:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wA5HNrkw001792; Mon, 5 Nov 2018 12:23:53 -0500 From: Tom Lane To: Alvaro Herrera cc: Thomas Munro , Jesper Pedersen , Magnus Hagander , Oskari Saarenmaa , Pg Hackers , Tobias Oberstein Subject: Re: pread() and pwrite() In-reply-to: <20181105155918.jg36uj4rtnxwqtzt@alvherre.pgsql> References: <20181105155918.jg36uj4rtnxwqtzt@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Mon, 05 Nov 2018 12:59:18 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1790.1541438632.1@sss.pgh.pa.us> Date: Mon, 05 Nov 2018 12:23:52 -0500 Message-ID: <1791.1541438632@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera 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