Re: define bool in pgtypeslib_extern.h
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Amit Kapila <amit.kapila16@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Michael Meskes <meskes@postgresql.org>
Date: 2019-10-26T20:12:20Z
Lists: pgsql-hackers
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
Commits
-
Fix ecpglib.h to declare bool consistently with c.h.
- 7a0574b50ee9 13.0 landed
-
Move declaration of ecpg_gettext() to a saner place.
- c8cb98ec41f0 13.0 landed
- baa483984fde 9.6.16 landed
- b705d639146c 9.5.20 landed
- b20233aac743 9.4.25 landed
- 89f56fc223f9 11.6 landed
- 831ca9513c59 10.11 landed
- 101654987344 12.1 landed
-
Sync our DTrace infrastructure with c.h's definition of type bool.
- d4d0cd6ee23e 12.1 landed
- ff43b3e88ece 13.0 landed
-
Get rid of useless/dangerous redefinition of bool in ECPG.
- 4a61aa4a945f 12.1 landed
- 1408d5d86992 13.0 landed