Dead code in _bt_split?
| От | Heikki Linnakangas |
|---|---|
| Тема | Dead code in _bt_split? |
| Дата | |
| Msg-id | 45786C60.70200@enterprisedb.com обсуждение исходный текст |
| Ответы |
Re: Dead code in _bt_split?
|
| Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: