pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix ecpglib.h to declare bool consistently with c.h.
Date: Tue, 12 Nov 2019 18:00:19 +0000
Message-ID: <E1iUaSh-0004oe-Cy@gemulon.postgresql.org> (raw)

Fix ecpglib.h to declare bool consistently with c.h.

This completes the task begun in commit 1408d5d86, to synchronize
ECPG's exported definitions with the definition of bool used by
c.h (and, therefore, the one actually in use in the ECPG library).
On practically all modern platforms, ecpglib.h will now just
include <stdbool.h>, which should surprise nobody anymore.
That removes a header-inclusion-order hazard for ECPG clients,
who previously might get build failures or unexpected behavior
depending on whether they'd included <stdbool.h> themselves,
and if so, whether before or after ecpglib.h.

On platforms where sizeof(_Bool) is not 1 (only old PPC-based
Mac systems, as far as I know), things are still messy, as
inclusion of <stdbool.h> could still break ECPG client code.
There doesn't seem to be any clean fix for that, and given the
probably-negligible population of users who would care anymore,
it's not clear we should go far out of our way to cope with it.
This change at least fixes some header-inclusion-order hazards
for our own code, since c.h and ecpglib.h previously disagreed
on whether bool should be char or unsigned char.

To implement this with minimal invasion of ECPG client namespace,
move the choice of whether to rely on <stdbool.h> into configure,
and have it export a configuration symbol PG_USE_STDBOOL.

ecpglib.h no longer exports definitions for TRUE and FALSE,
only their lowercase brethren.  We could undo that if we get
push-back about it.

Ideally we'd back-patch this as far as v11, which is where c.h
started to rely on <stdbool.h>.  But the odds of creating problems
for formerly-working ECPG client code seem about as large as the
odds of fixing any non-working cases, so we'll just do this in HEAD.

Discussion: https://postgr.es/m/CAA4eK1LmaKO7Du9M9Lo=kxGU8sB6aL8fa3sF6z6d5yYYVe3BuQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7a0574b50ee9c2b96ce94c29e031c103285c0b1d

Modified Files
--------------
configure                                    |  6 +++++
configure.in                                 |  7 +++++
src/backend/utils/fmgr/dfmgr.c               |  2 +-
src/include/c.h                              |  9 ++++---
src/include/pg_config.h.in                   |  3 +++
src/include/pg_config.h.win32                |  3 +++
src/interfaces/ecpg/include/ecpg_config.h.in |  3 +++
src/interfaces/ecpg/include/ecpglib.h        | 38 ++++++++++++++++++----------
src/pl/plperl/plperl.h                       |  4 +--
src/tools/msvc/Solution.pm                   |  1 +
10 files changed, 55 insertions(+), 21 deletions(-)



Message-ID: <E1iUaSh-0004oe-Cy@gemulon.postgresql.org>
Permalink:  ../E1iUaSh-0004oe-Cy@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iUaSh-0004oe-Cy@gemulon.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix ecpglib.h to declare bool consistently with c.h.
  In-Reply-To: <E1iUaSh-0004oe-Cy@gemulon.postgresql.org>
  References: <E1iUaSh-0004oe-Cy@gemulon.postgresql.org>

* 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