Обсуждение: Why does PageIndexTupleDelete insist tuple size be maxaligned?

Поиск
Список
Период
Сортировка

Why does PageIndexTupleDelete insist tuple size be maxaligned?

От
Tom Lane
Дата:
While perusing the proposed PageIndexTupleOverwrite patch, I noticed
that PageIndexTupleDelete throws an error if size != MAXALIGN(size),
where "size" is the ItemIdGetLength value.  This seems wrong now that
I look at it, because PageAddItem does not insist on tuple sizes being
maxaligned.  It does maxalign the amount of space actually allocated,
but what it stores into the ItemId length field is the pre-alignment
tuple size.

Also, PageRepairFragmentation and PageIndexMultiDelete are on board
with having to maxalign ItemIdGetLength values.  The latter makes
things particularly problematic here, because depending on how many
tuples are to be deleted, we might or might not enforce the restriction
about size being maxaligned.

So I think this is wrong, or at least trouble waiting to happen.
It probably works because all index AMs using these functions maxalign
their claimed tuple sizes before calling any bufpage.c functions,
but since we don't do that for heap tuples, it seems wrong to insist
that index AMs do so.

Barring objection, I plan to modify PageIndexTupleDelete to not expect
maxalignment of the stored size.
        regards, tom lane