From: | "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com> |
---|---|
To: | "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Dead code in _bt_split? |
Date: | 2006-12-07 19:32:48 |
Message-ID: | 45786C60.70200@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
This piece of code in _bt_split, starting at line 859, looks curious to me:
> /* cope with possibility that newitem goes at the end */
> if (i <= newitemoff)
> {
> if (newitemonleft)
> {
> _bt_pgaddtup(rel, leftpage, newitemsz, newitem, leftoff,
> "left sibling");
> itup_off = leftoff;
> itup_blkno = BufferGetBlockNumber(buf);
> leftoff = OffsetNumberNext(leftoff);
> }
> else
> {
> _bt_pgaddtup(rel, rightpage, newitemsz, newitem, rightoff,
> "right sibling");
> itup_off = rightoff;
> itup_blkno = BufferGetBlockNumber(rbuf);
> rightoff = OffsetNumberNext(rightoff);
> }
> }
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.
Is that really dead code, or am I missing something? How about putting
an Assert in there instead?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2006-12-07 20:18:44 | Re: old synchronized scan patch |
Previous Message | Ron Mayer | 2006-12-07 19:02:33 | Re: Load distributed checkpoint |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-12-07 23:05:09 | Re: Dead code in _bt_split? |
Previous Message | Ron Mayer | 2006-12-07 19:02:33 | Re: Load distributed checkpoint |