Re: Clang compiler warning on 9.3 HEAD

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Will Leinweber <will(at)heroku(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clang compiler warning on 9.3 HEAD
Date: 2013-04-11 15:12:03
Message-ID: 20130411151203.GB30671@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> > Now, it annoys me that we now have three places that know about object
> > types supported by event triggers: there's a large struct of command tag
> > substrings (event_trigger_support), then there's these two functions.
> > It might be better to add ObjectType and ObjectClass entries to the
> > struct, so that only the struct needs to know about that. The problem
> > is that these two functions would have to walk the struct every time,
> > instead of being a simple switch.
>
> Yeah. For the moment I think efficiency trumps having the information
> in just one place, ie I agree with doing it like this. If we find we're
> constantly forgetting to fix the functions when we need to, it'd be time
> enough to revisit the decision.

Makes sense.

> One thing you could do that might make it less likely we'd miss things
> is to have the switches explicitly cover all the possible enum members,
> instead of defaulting the majority of them as you do here. I know when
> I think about adding a new object type, I tend to choose the most
> similar existing type and grep for references to it. Likely you could
> even draft the code so that most compilers would warn about an enum
> value not covered in the switch.

I removed the default case, and my compiler is quiet about the current
coding and makes noise if I add a new value to the enums. So I guess
we're covered.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-04-11 15:27:34 Re: Nearing beta?
Previous Message Alvaro Herrera 2013-04-11 15:10:07 Re: ObjectClass/ObjectType mixup