pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Michael Meskes <meskes@postgresql.org>
Subject: Re: define bool in pgtypeslib_extern.h
Date: Sat, 26 Oct 2019 16:12:20 -0400
Message-ID: <25666.1572120740@sss.pgh.pa.us> (raw)
In-Reply-To: <877e4rmi2y.fsf@news-spur.riddles.org.uk>
References: <CAA4eK1LmaKO7Du9M9Lo=kxGU8sB6aL8fa3sF6z6d5yYYVe3BuQ@mail.gmail.com>
	<16583.1572010913@sss.pgh.pa.us>
	<18578.1572020755@sss.pgh.pa.us>
	<CAA4eK1LUFKhiq4vfrvG089wtSvnbfAs3sdTFdbuq428bQ7wCzg@mail.gmail.com>
	<32373.1572110364@sss.pgh.pa.us>
	<877e4rmi2y.fsf@news-spur.riddles.org.uk>

Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>  Tom> I'm inclined to think that we need to make ecpglib.h's
>  Tom> bool-related definitions exactly match c.h,

> I'm wondering whether we should actually go the opposite way and say
> that c.h's "bool" definition should be backend only, and that in
> frontend code we should define a PG_bool type or something of that ilk
> for when we want "PG's 1-byte bool" and otherwise let the platform
> define "bool" however it wants.

> And we certainly shouldn't be defining "bool" in something that's going
> to be included in the user's code the way that ecpglib.h is.

The trouble here is the hazard of creating an ABI break, if we modify
ecpglib.h in a way that causes its "bool" references to be interpreted
differently than they were before.  I don't think we want that (although
I suspect we have inadvertently caused ABI breaks already on platforms
where this matters).

In practice, since v11 on every modern platform, the exported ecpglib
functions have supposed that "bool" is _Bool, because they were compiled
in files that included c.h before ecpglib.h.  I assert furthermore that
clients might well have included <stdbool.h> before ecpglib.h and thereby
been fully compatible with that.  If we start having ecpglib.h include
<stdbool.h> itself, we'll just be eliminating a minor header inclusion
order hazard.  It's also rather hard to argue that including <stdbool.h>
automatically is really likely to break anything that was including
ecpglib.h already, since that file was already usurping those symbols.
Except on platforms where sizeof(_Bool) isn't 1, but things are already
pretty darn broken there.

I think it's possible to construct a counterexample that will fail
for *anything* we can do here.  I'm not inclined to uglify things like
mad to reduce the problem space from 0.1% to 0.01% of use-cases, or
whatever the numbers would be in practice.

			regards, tom lane





view thread (15+ messages)  latest in thread

Message-ID: <25666.1572120740@sss.pgh.pa.us>
Permalink:  ../25666.1572120740@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25666.1572120740@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew@tao11.riddles.org.uk, amit.kapila16@gmail.com, pgsql-hackers@lists.postgresql.org, meskes@postgresql.org
  Subject: Re: define bool in pgtypeslib_extern.h
  In-Reply-To: <25666.1572120740@sss.pgh.pa.us>

* 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