Re: Simplified version of read_binary_file (src/backend/utils/adt/genfile.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Simplified version of read_binary_file (src/backend/utils/adt/genfile.c)
Date: 2020-09-15 18:51:10
Message-ID: CAEudQAqB1-EMd7JDoxHVYnB_z8WOsEGt8WsD-VgK_63NAgJAuQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em ter., 15 de set. de 2020 às 14:54, Alvaro Herrera <
alvherre(at)2ndquadrant(dot)com> escreveu:

> I think you meant _IONBF instead of _IOFBF -- otherwise it's at odds
> with the comment you add. But what is the justification for that
> addition? I don't see us doing that anywhere else.
>
No.
_IOFBF *Full buffering:* On output, data is written once the buffer is full
(or flushed <http://www.cplusplus.com/fflush>). On Input, the buffer is
filled when an input operation is requested and the buffer is empty.
* _IONBF No buffering:* No buffer is used. Each I/O operation is written as
soon as possible. In this case, the *buffer* and *size* parameters are
ignored.
_IONBF ignores buffer and size.

Without setvbuf, fread uses an internal buffer, default 4096 bytes (OS
dependent).
If fread uses an internal buffer, then it needs a copy to the buffer
provided by the function.
setvbuf, does the same as read function low level, copies directly to the
final buffer.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2020-09-15 19:36:22 Re: recovering from "found xmin ... from before relfrozenxid ..."
Previous Message Tom Lane 2020-09-15 18:48:55 Re: Gripes about walsender command processing