Thread: pgsql: btree source code cleanups: I refactored findsplitloc and

pgsql: btree source code cleanups: I refactored findsplitloc and

From
momjian@postgresql.org (Bruce Momjian)
Date:
Log Message:
-----------
btree source code cleanups:

I refactored findsplitloc and checksplitloc so that the division of
labor is more clear IMO. I pushed all the space calculation inside the
loop to checksplitloc.

I also fixed the off by 4 in free space calculation caused by
PageGetFreeSpace subtracting sizeof(ItemIdData), even though it was
harmless, because it was distracting and I felt it might come back to
bite us in the future if we change the page layout or alignments.
There's now a new function PageGetExactFreeSpace that doesn't do the
subtraction.

findsplitloc now tries the "just the new item to right page" split as
well. If people don't like the refactoring, I can write a patch to just
add that.

Heikki Linnakangas

Modified Files:
--------------
    pgsql/src/backend/access/nbtree:
        nbtinsert.c (r1.151 -> r1.152)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/nbtree/nbtinsert.c.diff?r1=1.151&r2=1.152)
    pgsql/src/backend/storage/page:
        bufpage.c (r1.70 -> r1.71)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/page/bufpage.c.diff?r1=1.70&r2=1.71)
    pgsql/src/include/storage:
        bufpage.h (r1.70 -> r1.71)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/bufpage.h.diff?r1=1.70&r2=1.71)