Re: [BUGS] object_classes array is broken, again

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>, Jaimin Pan <jaimin(dot)pan(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [BUGS] object_classes array is broken, again
Date: 2015-07-20 16:33:15
Message-ID: 20150720163315.GS2301@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> > Any opinions on this idea? I don't like it all that much, but it's
> > plenty effective.
>
> I don't like it much either.
>
> What about adding StaticAsserts that lengthof() the relevant constant
> arrays is equal to MAX_OCLASS? (Or other similar ways of checking
> that they have the right number of entries.)

Well, the array itself is declared like this:
static const Oid object_classes[MAX_OCLASS] = {
so testing lengthof() of it is useless because it's a constant and the
assertion always holds. If it were declared like this instead:
static const Oid object_classes[] = {
then we could use lengthof().

I don't see any drawwbacks to that.

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

Attachment Content-Type Size
objclass-2.patch text/x-diff 1.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-07-20 16:59:41 Re: [HACKERS] object_classes array is broken, again
Previous Message gregoire.hubert 2015-07-20 15:58:38 BUG #13506: jsonb || operator does not work

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-07-20 16:38:15 Re: Typo in comment in setrefs.c
Previous Message Alvaro Herrera 2015-07-20 16:11:24 Re: All-zero page in GIN index causes assertion failure