Обсуждение: nbtree: Refactor "fastpath" and _bt_search() code

Поиск
Список
Период
Сортировка

nbtree: Refactor "fastpath" and _bt_search() code

От
Peter Geoghegan
Дата:
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

Вложения