Tom Lane wrote:
> "Heikki Linnakangas" <heikki@enterprisedb.com> writes:
>> This is right after a for-loop, which exits when i = maxoff + 1. So the
>> first if-statement could be written as "if (newitemoff > maxoff)". If
>> that's true, newitemonleft shouldn't be true, because that would mean
>> that we've split a page so that all items went to the left page, and the
>> right page is empty.
>
> No, it would mean that we split the page in such a way that only the new
> item is going to the right page. Probably not hard to duplicate if you
> use near-maximal-sized keys.
In that case, newitemleft would be false, right?
I'm saying the piece marked with X> below is unreachable:
> /* cope with possibility that newitem goes at the end */
> if (i <= newitemoff)
> {
> if (newitemonleft)
> {
X> _bt_pgaddtup(rel, leftpage, newitemsz, newitem, leftoff,
X> "left sibling");
X> itup_off = leftoff;
X> itup_blkno = BufferGetBlockNumber(buf);
X> leftoff = OffsetNumberNext(leftoff);
> }
> else
> {
> _bt_pgaddtup(rel, rightpage, newitemsz, newitem, rightoff,
> "right sibling");
> itup_off = rightoff;
> itup_blkno = BufferGetBlockNumber(rbuf);
> rightoff = OffsetNumberNext(rightoff);
> }
> }
-- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com