Re: object_classes array is broken, again - Mailing list pgsql-hackers

From Jim Nasby
Subject Re: object_classes array is broken, again
Date
Msg-id 558DD0BF.1000407@BlueTreble.com
Whole thread Raw
In response to object_classes array is broken, again  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: object_classes array is broken, again  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
On 6/24/15 2:11 PM, Robert Haas wrote:
> Fixing this is easy, but ISTM that we need to insert some sort of a
> guard to prevent people from continuing to forget this, because it's
> apparently quite easy to do.  Perhaps add_object_address should
> Assert(OidIsValid(object_classes[oclass])), plus a (static?) assert
> someplace checking that OidIsValid(object_classes[MAX_OCLASS - 1])?

I tried doing this and I'm getting a "static_assert expression is not an
integral constant expression" error, even when I reduce it to a simple
constant comparison. Maybe I'm just doing something dumb...

If I replace the StaticAssert with
Assert(OidIsValid(object_classes[MAX_OCLASS - 1])) it works find and
initdb will fail if that assert trips.

I've attached the broken StaticAssert version. Also added a warning
comment to the enum.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Data in Trouble? Get it in Treble! http://BlueTreble.com

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BRIN index bug due to WAL refactoring
Next
From: Jim Nasby
Date:
Subject: Re: pg_stat_*_columns?