From: Tom Lane <tgl@sss.pgh.pa.us>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Thom Brown <thom@linux.com>
Cc: Abhijit Menon-Sen <ams@2ndquadrant.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Haribabu Kommi <kommi.haribabu@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: [BUGS] Breakage with VACUUM ANALYSE + partitions
Date: Wed, 04 May 2016 13:31:18 -0400
Message-ID: <13345.1462383078@sss.pgh.pa.us> (raw)
In-Reply-To: <alpine.DEB.2.10.1605041750420.30701@sto>
References: <20160429235837.b63wkjw4dduf56wt@alap3.anarazel.de>
<CA+TgmoZirJKnSAkjZHt8cVRW9Y7yHyWFLNENnT-LkFtBi6oBfw@mail.gmail.com>
<20160502164111.cpupbbkab6ik7wwd@alap3.anarazel.de>
<CA+Tgmoajiv-4840wHpx0o-LJ7mqSGrnCtRH8MOoJkL2A-GF2Ww@mail.gmail.com>
<20160502165438.yu6inlsyv4babyie@alap3.anarazel.de>
<alpine.DEB.2.10.1605022146390.927@sto>
<20160502203634.hmjgdumfgqrldo6n@alap3.anarazel.de>
<alpine.DEB.2.10.1605022346490.927@sto>
<20160502221419.shvm4vuhi4jh5hoe@alap3.anarazel.de>
<alpine.DEB.2.10.1605030712070.927@sto>
<20160503234810.vzbxwxq4jincgdng@alap3.anarazel.de>
<alpine.DEB.2.10.1605040727090.27782@sto>
<6502.1462373742@sss.pgh.pa.us>
<alpine.DEB.2.10.1605041750420.30701@sto>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Fabien COELHO <coelho@cri.ensmp.fr> writes:
> I understood the point and I do not see real disadvantages. The C standard
> really says that an enum is an int, and compilers just do that.
No, it doesn't say that, and compilers don't just do that. A compiler
is specifically allowed to store an enum in char or short if the enum's
declared values would all fit into that width. (Admittedly, if you're
choosing the values as powers of 2, an OR of them would still fit; but
if you think "oh, an enum is just an int", you will get burned.)
More to the point, once you allow OR'd values then none of the practical
benefits of an enum still hold good. The typical things that I rely on
in an enum that you don't get from a collection of #define's are:
* compiler warnings if you forget some members of the enum in a switch
* debugger ability to print variables symbolically
Those benefits both go up in smoke as soon as you allow OR'd values.
At that point you might as well use the #defines rather than playing
language lawyer about whether what you're doing meets the letter of
the spec. I note that C99 specifically mentions this as something
a compiler might warn about:
-- A value is given to an object of an enumeration type
other than by assignment of an enumeration constant
that is a member of that type, or an enumeration
variable that has the same type, or the value of a
function that returns the same enumeration type
(6.7.2.2).
which certainly looks like they don't consider
"enumvar = ENUMVAL1 | ENUMVAL2" to be strictly kosher.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, coelho@cri.ensmp.fr, andres@anarazel.de, robertmhaas@gmail.com, thom@linux.com, ams@2ndquadrant.com, michael.paquier@gmail.com, kommi.haribabu@gmail.com, pgsql-hackers@postgresql.org
Subject: Re: [BUGS] Breakage with VACUUM ANALYSE + partitions
In-Reply-To: <13345.1462383078@sss.pgh.pa.us>
References: <20160429235837.b63wkjw4dduf56wt@alap3.anarazel.de> <CA+TgmoZirJKnSAkjZHt8cVRW9Y7yHyWFLNENnT-LkFtBi6oBfw@mail.gmail.com> <20160502164111.cpupbbkab6ik7wwd@alap3.anarazel.de> <CA+Tgmoajiv-4840wHpx0o-LJ7mqSGrnCtRH8MOoJkL2A-GF2Ww@mail.gmail.com> <20160502165438.yu6inlsyv4babyie@alap3.anarazel.de> <alpine.DEB.2.10.1605022146390.927@sto> <20160502203634.hmjgdumfgqrldo6n@alap3.anarazel.de> <alpine.DEB.2.10.1605022346490.927@sto> <20160502221419.shvm4vuhi4jh5hoe@alap3.anarazel.de> <alpine.DEB.2.10.1605030712070.927@sto> <20160503234810.vzbxwxq4jincgdng@alap3.anarazel.de> <alpine.DEB.2.10.1605040727090.27782@sto> <6502.1462373742@sss.pgh.pa.us> <alpine.DEB.2.10.1605041750420.30701@sto> <13345.1462383078@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