Re: Use an enum for RELKIND_*?

2019-01-27 Thread Kyotaro HORIGUCHI
At Thu, 24 Jan 2019 09:37:41 -0500, Tom Lane wrote in <15760.1548340...@sss.pgh.pa.us> > Kyotaro HORIGUCHI writes: > > I might misunderstand something, but my compiler (gcc 7.3.1) > > won't be quiet about omitted value even with default:. > > ... > > I would call that a compiler bug, TBH. The

Re: Use an enum for RELKIND_*?

2019-01-24 Thread Tom Lane
Kyotaro HORIGUCHI writes: > I might misunderstand something, but my compiler (gcc 7.3.1) > won't be quiet about omitted value even with default:. > ... I would call that a compiler bug, TBH. The code is 100% correct, if you intended to allow the default case to handle some enum values, which is

Re: Use an enum for RELKIND_*?

2019-01-24 Thread Greg Stark
On Wed 16 Jan 2019, 18:10 Alvaro Herrera > Or we could do nothing, since there are no complaints about this > problem. > Unless there are objections my patch is to some add it to the xid case. The tag is pretty useless for users and it's incredibly hard to even see these rows anyways I'll take

Re: Use an enum for RELKIND_*?

2019-01-24 Thread Kyotaro HORIGUCHI
At Wed, 19 Dec 2018 09:55:22 -0500, Tom Lane wrote in <10268.1545231...@sss.pgh.pa.us> > Andres Freund writes: > > On 2018-12-18 23:17:54 -0500, Tom Lane wrote: > >> Yeah, that would sure make things better. I was considering > >> something like > >> > >>#ifndef USE_ASSERT_CHECKING > >>

Re: Use an enum for RELKIND_*?

2019-01-16 Thread Alvaro Herrera
On 2018-Dec-21, Greg Stark wrote: > But I had a second look to see if the output pointed out any actual > bugs. I found one though it's pretty minor: > > lockfuncs.c:234:3: warning: enumeration value > ‘LOCKTAG_SPECULATIVE_TOKEN’ not handled in switch [-Wswitch-enum] >switch ((LockTagType)

Re: Use an enum for RELKIND_*?

2018-12-21 Thread Greg Stark
Out of curiosity I built with -Wswitch-enum to see if it would be possible to just enable it. It looks like the main culprits are the node types and if those were switched to #defines it might be feasible to do so though it would still be a lot of hassle to add case labels all over the place. But

Re: Use an enum for RELKIND_*?

2018-12-19 Thread Tom Lane
Andres Freund writes: > On 2018-12-18 23:17:54 -0500, Tom Lane wrote: >> Yeah, that would sure make things better. I was considering >> something like >> >> #ifndef USE_ASSERT_CHECKING >> default: >> elog(ERROR, ...); >> #endif > Yea, that's the best I

Re: Use an enum for RELKIND_*?

2018-12-18 Thread Andres Freund
Hi, On 2018-12-18 23:17:54 -0500, Tom Lane wrote: > Andres Freund writes: > > It'd be nice if there were an easy way to write a switch() where the > > compiler enforces that all enum values are checked, but still had the > > possibility to have a 'default:' block for error checking... I can't >

Re: Use an enum for RELKIND_*?

2018-12-18 Thread Tom Lane
Andres Freund writes: > It'd be nice if there were an easy way to write a switch() where the > compiler enforces that all enum values are checked, but still had the > possibility to have a 'default:' block for error checking... I can't > quite come up with a good approach to emulate that though.

Re: Use an enum for RELKIND_*?

2018-12-18 Thread Andres Freund
Hi, On 2018-12-18 22:50:57 -0500, Tom Lane wrote: > Kyotaro HORIGUCHI writes: > > At Tue, 18 Dec 2018 17:13:08 -0800, Andres Freund > > wrote in <20181219011308.mopzyvc73nwjz...@alap3.anarazel.de> > >> Right now there's no easy way to use the compiler to ensure that all > >> places that need

Re: Use an enum for RELKIND_*?

2018-12-18 Thread Tom Lane
Kyotaro HORIGUCHI writes: > At Tue, 18 Dec 2018 17:13:08 -0800, Andres Freund wrote > in <20181219011308.mopzyvc73nwjz...@alap3.anarazel.de> >> Right now there's no easy way to use the compiler to ensure that all >> places that need to deal with all kinds of relkinds check a new >> relkind. I

Re: Use an enum for RELKIND_*?

2018-12-18 Thread Kyotaro HORIGUCHI
Hello. At Tue, 18 Dec 2018 17:13:08 -0800, Andres Freund wrote in <20181219011308.mopzyvc73nwjz...@alap3.anarazel.de> > Hi, > > Right now there's no easy way to use the compiler to ensure that all > places that need to deal with all kinds of relkinds check a new > relkind. I think we should

Use an enum for RELKIND_*?

2018-12-18 Thread Andres Freund
Hi, Right now there's no easy way to use the compiler to ensure that all places that need to deal with all kinds of relkinds check a new relkind. I think we should make that easier by moving RELKIND_* to an enum, with the existing letters as the value. Obviously we cannot really do that for