nbtree: Refactor "fastpath" and _bt_search() code - Mailing list pgsql-hackers

From Peter Geoghegan
Subject nbtree: Refactor "fastpath" and _bt_search() code
Date
Msg-id CAH2-Wzk59cxKJRd=rfbyub6-V4yWRjsOYRkUNHBLT1P1GdtCQQ@mail.gmail.com
Whole thread Raw
List pgsql-hackers
I have another refactoring patch for nbtinsert.c that is a little
bigger than the commits I've pushed recently. I thought I should run
it by -hackers before proceeding with commit, even though it seems
like a very clear improvement to me.

Attached patch creates a _bt_search() wrapper that is local to
nbtinsert.c -- _bt_search_insert(). This contains all the logic needed
to handle the "fastpath" rightmost leaf page caching optimization
added by commit 2b272734, avoiding any direct knowledge of the
optimization within the high level _bt_doinsert() function. This is
more or less how things were before 2b272734. This is certainly a
readability win.

It's also useful to have our leaf page buffer acquired within a
dedicated function that knows about the BTInsertState struct. That
makes the "ownership" of the buffer less ambiguous, and provides a
single reference point for other code that sets up the fastpath
optimization that will now actually be used in _bt_search_insert().

-- 
Peter Geoghegan

Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: [PATCH] Use PKG_CHECK_MODULES to detect the libxml2 library
Next
From: Justin Pryzby
Date:
Subject: Re: Berserk Autovacuum (let's save next Mandrill)