Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.
Дата
Msg-id 21330.1424473164@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-committers
Andres Freund <andres@2ndquadrant.com> writes:
> Even after that I get:
> /home/andres/src/postgresql/src/backend/utils/adt/tsrank.c:201:2: warning: flexible array initialization is a GNU
extension
>       [-Wgnu-flexible-array-initializer]
>         {0}
>         ^
> /home/andres/src/postgresql/src/include/tsearch/ts_type.h:66:15: note: initialized flexible array member 'pos' is
here
>         WordEntryPos pos[FLEXIBLE_ARRAY_MEMBER];
>                      ^

I cleaned that up, and also committed most of Michael's other changes.

What remains is the patch that flexible-izes HeapTupleHeaderData.t_bits.
I think we should do that, but I'm not happy with the widespread
changes like this:

-            MAXALIGN(sizeof(HeapTupleHeaderData));
+            MAXALIGN(offsetof(HeapTupleHeaderData, t_bits));

I think this coding exposes much more knowledge about the innards of
HeapTupleHeaderData than we really want floating around in the places
that currently use sizeof(HeapTupleHeaderData).  Most of them are not
that excited about having an exact answer anyway, and to the extent
that it does need to be exact this would not give the same result as
before.

A relevant technique that's been used in a lot of our code is to define
an intermediate macro, along the lines of

#define SizeofHeapTupleHeader offsetof(HeapTupleHeaderData, t_bits)

or maybe it would better be called HeapTupleHeaderFixedSize or
HeapTupleHeaderOverhead.  Not sure what reads most nicely.

            regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix statically allocated struct with FLEXIBLE_ARRAY_MEMBER membe
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.