Re: [HACKERS] Dead code in _bt_split?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Dead code in _bt_split?
Date: 2007-02-18 01:35:21
Message-ID: 200702180135.l1I1ZLC05676@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------

Heikki Linnakangas wrote:
> Tom Lane wrote:
> > While testing it I realized that there seems to be a nearby bug in
> > _bt_findsplitloc: it fails to consider the possibility of moving all the
> > extant items to the left side. It will always return a firstright <=
> > maxoff. ISTM this would mean that it could choose a bad split if the
> > incoming item goes at the end and both it and the last extant item are
> > large: in this case they should be split apart, but they won't be.
> >
> > Heikki, do you feel like looking at that, or shall I?
>
> 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.
>
> Some of the long variable names look ugly. camelCase or underscores
> between words would be more readable, but I retained the old style for
> the sake of consistency.
>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-02-18 02:02:33 Re: Chatter on DROP SOMETHING IF EXISTS
Previous Message Bruce Momjian 2007-02-18 01:34:44 Re: TODO: Allow SQL functions to reference parameters by name

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-02-18 02:04:29 Re: LIMIT/SORT optimization
Previous Message Bruce Momjian 2007-02-18 01:35:02 Re: patch for contrib/xml2