Re: Replace open mode with PG_BINARY_R/W/A macros

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: Japin Li <japinli(at)hotmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Replace open mode with PG_BINARY_R/W/A macros
Date: 2022-04-20 20:29:28
Message-ID: 2993591.1650486568@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
> On 19.04.22 16:21, Tom Lane wrote:
>> * In the other direction, decide that the PG_BINARY_X macros are
>> offering no benefit at all and just rip 'em out, writing "rb" and
>> so on in their place. POSIX specifies that the character "b" has
>> no effect on Unix-oid systems, and it has said that for thirty years
>> now, so we do not really need the platform dependency that presently
>> exists in the macro definitions. The presence or absence of "b"
>> would serve fine as an indicator of intent, and there would be one
>> less PG-specific coding convention to remember.

> I can only imagine that there must have been some Unix systems that did
> not understand the "binary" APIs required for Windows. (For example,
> neither the Linux nor the macOS open(2) man page mentions O_BINARY.)
> Otherwise, these macros don't make any sense, because then you could
> just write the thing directly on all platforms.

PG_BINARY is useful for open(). It's the PG_BINARY_R/W/A macros for
fopen() that are redundant per POSIX. Possibly someone generalized
inappropriately; or maybe long ago we supported some platform that
rejected the "b" option?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2022-04-20 20:38:33 Re: pg14 psql broke \d datname.nspname.relname
Previous Message Robert Haas 2022-04-20 20:29:04 when should we set DB_IN_PRODUCTION?