Why does PageIndexTupleDelete insist tuple size be maxaligned?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Why does PageIndexTupleDelete insist tuple size be maxaligned?
Date: 2016-09-08 20:32:42
Message-ID: 3814.1473366762@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-09-08 20:45:29 CVE-2016-1238 fix breaks (at least) pg_rewind tests
Previous Message Lucas 2016-09-08 20:25:07 Re: Preventing deadlock on parallel backup