Re: [BUGS] object_classes array is broken, again

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [BUGS] object_classes array is broken, again
Дата
Msg-id 29788.1437411581@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [BUGS] object_classes array is broken, again  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: [BUGS] object_classes array is broken, again  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [BUGS] object_classes array is broken, again  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> 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().

Ah.  I think the point of using MAX_OCLASS there was to get a warning
if the array was too short, but evidently it doesn't work like that.

> I don't see any drawwbacks to that.

+1 to this patch, in fact I think we could remove MAX_OCLASS altogether
which would be very nice for switch purposes.

Are there any other arrays that need such tests?
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Dead code in Create/RenameRole() after RoleSpec changes related to CURRENT/SESSION_USER
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] object_classes array is broken, again