Re: Use pread and pwrite instead of lseek + write and read

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use pread and pwrite instead of lseek + write and read
Date: 2016-08-17 10:17:35
Message-ID: CABUevEzZ=CGdmwSZwW9oNuf4pQZMExk33jcNO7rseqrAgKzj5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 17, 2016 at 11:34 AM, Victor Wagner <vitus(at)wagner(dot)pp(dot)ru> wrote:

> On Wed, 17 Aug 2016 10:58:09 +0300
> Oskari Saarenmaa <os(at)ohmu(dot)fi> wrote:
>
>
>
> >
> > The attached patch replaces FileWrite and FileRead with FileWriteAt
> > and FileReadAt and removes most FileSeek calls. FileSeek is still
> > around so we can find the end of a file, but it's not used for
> > anything else.
>
> It seems that configure test for availability of pread/pwrite functions
> and corresponding #define is needed.
>
> I don't think that all platforms, supported by PostgreSQL support this
> API. Especially, I cannot find any mention of pread/pwrite in the Win32
> except this thread on stackoverflow:
>
>
Yeah, Windows does not have those API calls, but it shouldn't be rocket
science to write a wrapper for it. The standard windows APIs can do the
same thing -- but they'll need access to the HANDLE for the file and not
the posix file descriptor.

It also has things like ReadFileScatter() (
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365469(v=vs.85).aspx)
which is not the same, but might also be interesting as a future
improvement. That's clearly something different though, and out of scope
for this one. But IIRC that functionality was actually added for the sake
of SQLServer back in the days.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message roshan_myrepublic 2016-08-17 10:21:31 How to do failover in pglogical replication?
Previous Message Aleksander Alekseev 2016-08-17 10:02:08 Re: [GENERAL] C++ port of Postgres