Why does PageIndexTupleDelete insist tuple size be maxaligned? - Mailing list pgsql-hackers

From Tom Lane
Subject Why does PageIndexTupleDelete insist tuple size be maxaligned?
Date
Msg-id 3814.1473366762@sss.pgh.pa.us
Whole thread Raw
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Lucas
Date:
Subject: Re: Preventing deadlock on parallel backup
Next
From: Andres Freund
Date:
Subject: CVE-2016-1238 fix breaks (at least) pg_rewind tests