Re: Fix for seg picksplit function

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема Re: Fix for seg picksplit function
Дата
Msg-id AANLkTik2Uf_G=stpnuFK4fDjC0G0K_Mf_L0uScRv9ObM@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Fix for seg picksplit function  (Alexander Korotkov <aekorotkov@gmail.com>)
Ответы Re: Fix for seg picksplit function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Wed, Nov 10, 2010 at 4:53 PM, Alexander Korotkov <aekorotkov@gmail.com> wrote:
Hmm, the second for loop in gseg_picksplit uses "i < maxoff" whereas the
other one uses <=.  The first is probably correct; if the second is also
correct it merits a comment on the discrepancy (To be honest, I'd get
rid of the "-1" in computing maxoff and use < in both places, given that
offsets are 1-indexed).  Also, the second one is using i++ to increment;
probably should be OffsetNumberNext just to stay consistent with the
rest of the code.
Actually I can't understand the purpose of FirstOffsetNumber and OffsetNumberNext macros. When I wrote the patch I though about sortItems as about "clean from all these strange things" array, that's why I didn't use OffsetNumberNext there. :)
I see only way to save logic of these macros is to use array starting from FirstOffsetNumber index like in gbt_num_picksplit.  
For example, if we assume, that OffsetNumberNext can do something other that just increment, that we shouldn't use it in loop on sortItems, but should do following things:
1) Do additional loop first to calculate actual items count. (Because we don't know how OffsetNumberNext increases the index. Probably it can increase it by various value.)
2) Fill sortItems using separate index.

----
With best regards,
Alexander Korotkov.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: Fix for seg picksplit function
Следующее
От: Yeb Havinga
Дата:
Сообщение: Re: Fix for seg picksplit function